Validate Jupyter notebooks (.ipynb files) for production readiness...
Comprehensive validation of Jupyter notebooks (.ipynb files) to ensure production readiness. Validates smart links, layout structure, transitions, part flow, and overall quality standards.
Use this skill when you need to:
Before running full validation, manually verify:
<!-- action-cards --> marker(#) placeholder patternThis single check catches 80% of validation failures.
What it checks:
[text](#)) have matching headingsExpected pattern:
[Link Text](#) β Finds heading containing "Link Text"
Common issues:
What it checks:
Expected structure:
Introduction (Cells 0-N)
β Transition (optional)
β Part 1 (Start β Content β Summary)
β Transition
β Part 2 (Start β Content β Summary)
...
β Conclusion
What it checks:
<!-- action-cards --> marker (REQUIRED)Expected pattern:
### Part X: Section Name
**Progress: X of Y** π΅π΅π΅βͺβͺβͺ
**Reading time: N minutes**
Contextual text explaining what's next...
<!-- action-cards -->
- [Topic 1](#)
- [Topic 2](#)
- [Topic 3](#)
β οΈ COMMON FAILURE: Missing Action Cards Marker
This is the #1 validation failure. Every transition cell between parts MUST include:
<!-- action-cards --> HTML comment marker(#) placeholder patternValidation will FAIL if:
<!-- action-cards --> markerWhen transitions are optional:
What it checks:
Expected title patterns:
### π Part 1: Topic Name
### π₯Part 2: By Your Role - Subtopic
### π―Part 3: By Your Task - Subtopic
Part structure requirements:
What it checks:
Common ordering issues:
Example of correct flow:
Part 6 Completion Cell
β immediately adjacent
Part 7 Transition Cell (with action cards)
β
Part 7 Content Cells
β
Part 7 Completion Cell
β immediately adjacent
Part 8 Transition Cell
What it checks:
<!-- action-cards --> marker present(#) placeholderQuality criteria:
What it checks:
Metadata requirements:
{
"metadata": {
"title": "Notebook Title",
"description": "Brief description",
"author": "Author Name",
"date": "YYYY-MM-DD",
"version": "X.Y",
"repo": "https://github.com/user/repo"
}
}
This is the most important validation step for missing action cards.
Find all transition cells by pattern matching:
def is_transition_cell(source):
return (
re.search(r'###.*Part \d+:', source) and
'Progress:' in source and
'π΅' in source and
'Reading time:' in source
)
Verify action card markers (REQUIRED):
has_action_cards = '<!-- action-cards -->' in source
if not has_action_cards:
issues.append({
'severity': 'ERROR',
'cell': cell_idx,
'message': f'Part {part_num} transition missing action cards marker'
})
Count links per transition (must be 3-6):
links = re.findall(r'^\s*- \[([^\]]+)\]\(#\)', source, re.MULTILINE)
if len(links) < 3:
issues.append({'severity': 'ERROR', 'message': 'Too few action cards'})
elif len(links) > 6:
issues.append({'severity': 'WARN', 'message': 'Too many action cards'})
Validate link targets - ensure all action card links resolve
Check contextual text - verify transition has explanatory text before action cards
Symptom: Link text doesn't match any heading
Fix:
# Before (broken)
[Getting Started](#) β No heading contains "Getting Started"
# After (fixed)
Heading: ### Getting Started Guide
Link: [Getting Started Guide](#)
Symptom: Part starts immediately after previous summary
Fix:
# Add transition cell with action cards
Contextual text...
<!-- action-cards -->
- [Topic 1](#)
- [Topic 2](#)
Symptom: Summary appears before content, or reference cells between parts
Fix:
# Reorder cells in notebook JSON
# Example: Move completion cell from index 64 to index 72
cells = notebook['cells']
completion_cell = cells.pop(64) # Remove from wrong position
cells.insert(72, completion_cell) # Insert at correct position
Common scenarios:
Symptom: Transition cell has no <!-- action-cards --> marker
Critical Issue: This is one of the most common validation failures. Every transition cell between parts MUST have action cards to guide readers.
Detection Pattern:
# Identifies transition cells by:
# 1. Contains "Part X:" heading
# 2. Has progress indicator (Progress: X of Y)
# 3. Has progress dots (π΅π΅...)
# 4. Has reading time estimate
# Then checks for:
# - <!-- action-cards --> marker (REQUIRED)
# - 3-6 markdown links after marker
# - Links use (#) placeholder pattern
Fix:
# Before (FAILS validation):
### Part 7: Universal Patterns
**Progress: 7 of 8** π΅π΅π΅π΅π΅π΅π΅βͺ
**Reading time: 2 minutes**
These patterns work everywhere...
# After (PASSES validation):
### Part 7: Universal Patterns
**Progress: 7 of 8** π΅π΅π΅π΅π΅π΅π΅βͺ
**Reading time: 2 minutes**
These patterns work everywhere...
<!-- action-cards -->
- [Beyond EDS](#)
- [Universal Patterns](#)
- [Apply Anywhere](#)
Why this matters:
Symptom: Parts numbered 1, 2, 4 (missing 3)
Fix: Renumber parts sequentially or add missing part
Use the /validate-notebook command:
/validate-notebook notebook-name.ipynb
Output includes:
Before deploying to production:
The validator assigns scores (0-100) in each category:
Smart Links (0-100):
Structure (0-100):
Transitions (0-100):
Part Flow (0-100):
Overall (0-100):
β Use descriptive, unique link text β Keep link text consistent with headings β Test all links before deployment β Use emojis in headings (they're ignored in matching)
β Don't use generic link text like "Click here"
β Don't hardcode cell IDs like #cell-5
β Don't create circular link references
β Validate cell order with structural checks:
# Check adjacency between key sections
part_completion_idx < part_transition_idx + 1 # Must be adjacent
part_transition_idx < next_part_start_idx # Proper sequence
β Place reference/utility cells strategically:
β Keep technical detail cells within their parent section:
β Don't place utility cells between parts β Don't split sections with unrelated content β Don't place completion cells before content
β Provide contextual text explaining what's next β Include 3-6 action cards per transition β Link to major upcoming sections β Use consistent formatting
β Don't skip transitions between major parts β Don't have too many action cards (> 6) β Don't have too few action cards (< 3)
β Number parts sequentially β Use consistent title format β Place summaries at end of parts β Keep part structure uniform
β Don't skip part numbers β Don't change title format mid-notebook β Don't place summaries before content
.claude/commands/validate-notebook.md - Command implementationblocks/ipynb-viewer/README.md - Viewer documentationdocs/for-ai/explaining-educational-notebooks.md - Notebook creation guidedocs/for-ai/explaining-presentation-notebooks.md - Presentation notebooksThe validator produces a detailed report:
NOTEBOOK VALIDATION REPORT: notebook-name.ipynb
================================================================
SUMMARY:
Total Cells: 66
Smart Links: 51 (51 valid, 0 broken)
Parts: 7 (sequential)
Transitions: 6 (all with action cards)
Overall Score: 95/100 β
PRODUCTION READY
SMART LINKS: β
PASS
β All 51 smart links resolve correctly
β No broken or orphaned links
β Action card links validated
STRUCTURE: β
PASS
β Clear introduction section (8 cells)
β 7 parts with consistent structure
β Conclusion section present
β No gaps or missing sections
TRANSITIONS: β
PASS
β 6 transition cells with action cards
β Part 6 flows naturally (no transition needed)
β All action cards have 3-6 links
β Contextual text present
PART FLOW: β
PASS
β Parts numbered 1-7 sequentially
β No gaps or duplicates
β Summaries at end of each part
β Consistent title format
CELL ORDERING: β
PASS
β All cells in logical sequence
β Summaries after content
β Transitions before parts
β No orphaned cells
PRODUCTION READINESS: β
PASS
β Metadata complete
β Repository URL set
β No test content
β Valid JSON structure
β Appropriate file size
RECOMMENDATIONS:
β’ Notebook is ready for production deployment
β’ All validation checks passed
β’ Quality score: 95/100
Note: This validator is designed for educational and navigation notebooks. Testing notebooks (test.ipynb) may have different structure requirements and are validated separately.