Prodigy Split Oversized Chapters

Orchestrate the splitting of all oversized book chapters identified in the structure analysis report. This command reads the stru…

iepathos 44 updated 24d ago
Claude CodeGeneric
View source ↗
# /prodigy-split-oversized-chapters

Orchestrate the splitting of all oversized book chapters identified in the structure analysis report. This command reads the structure report, identifies high-priority chapters that need splitting, and systematically migrates each one to multi-subsection format.

## Purpose

This command serves as an **orchestration layer** between structure analysis and the map phase. It bridges the gap between recommendations (from `/prodigy-analyze-chapter-structure`) and execution (via `/prodigy-create-chapter-subsections`).

## Variables

- `--project <name>` - Project name (e.g., "Prodigy")
- `--chapters <path>` - Path to chapter definitions JSON (e.g., "workflows/data/prodigy-chapters.json")
- `--book-dir <path>` - Book directory path (e.g., "book")
- `--structure-report <path>` - Path to structure analysis report (e.g., ".prodigy/book-analysis/structure-report.json")

## Execute

### Phase 1: Parse Parameters and Load Structure Report

**Parse Command Arguments:**
Extract all required parameters:
- `--project`: Project name for output messages
- `--chapters`: Path to chapter definitions JSON
- `--book-dir`: Book directory path
- `--structure-report`: Path to structure analysis report

**Validate Parameters:**
- Ensure all required parameters are provided
- Verify structure report file exists
- Check that chapters file exists
- Verify book directory exists

**Load Structure Report:**
1. Read the structure report JSON file
2. Parse the recommendations array
3. Extract chapters that need splitting

### Phase 2: Filter High-Priority Chapters

**Identify Chapters to Split:**

Filter recommendations based on these criteria:
- `priority == "high"` - Only high-priority oversized chapters
- `recommended_action == "split_into_subsections"` - Explicitly needs splitting
- `proposed_structure` exists - Has concrete subsection recommendations

**Build Split List:**
Create an ordered list of chapters to split:
```json
[
  {
    "chapter_id": "configuration",
    "chapter_title": "Configuration",
    "current_file": "book/src/configuration.md",
    "total_lines": 1843,
    "proposed_subsections": 8,
    "reason": "Oversized chapter with 12 substantial H2 sections"
  },
  ...
]

Handle Empty List:

  • If no chapters need splitting, print success message and exit
  • Example: "✅ All chapters are well-sized - no splitting needed"
  • This is a valid success state, not an error

Phase 3: Display Split Plan

Print Summary:

📋 Book Chapter Splitting Plan
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Project: {project-name}
Chapters to split: {count}

Chapters:
  1. Configuration (1843 lines → 8 subsections)
  2. Error Handling (600 lines → 3 subsections)
  ...

This will:
  • Create multi-subsection directory structure
  • Generate index.md for each chapter
  • Create individual subsection files
  • Update {chapters-file}
  • Update SUMMARY.md
  • Archive original files

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Phase 4: Execute Chapter Splitting

Iteration Strategy:

This phase must process ALL chapters in the split list sequentially. Use the SlashCommand tool to invoke the worker command for each chapter.

CRITICAL: You must iterate through the ENTIRE split list. Do not stop after the first chapter. Process all chapters identified in Phase 2.

For Each Chapter in Split List:

  1. Announce Current Chapter: Print to user:

    📖 Splitting chapter {N}/{total}: {chapter-title}
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    
  2. Invoke Split Command Using SlashCommand Tool: Use the SlashCommand tool to execute:

    /prodigy-create-chapter-subsections --project {project-name} --chapter {chapter-id} --chapters {chapters-file} --book-dir {book-dir} --structure-report {structure-report-path} --no-commit
    

    CRITICAL: Add --no-commit flag to prevent the worker from creating individual commits. The orchestrator will create ONE comprehensive commit at the end (Phase 7).

  3. Verify Success:

    • Check that SlashCommand completed without errors
    • Verify expected files were created (directory, index.md, subsections)
    • Confirm chapters.json was updated with new multi-subsection structure
  4. Track Progress:

    • Increment successful_splits counter
    • If error occurs, append to failures list but CONTINUE with remaining chapters
    • Do NOT abort on first failure - process all chapters
  5. Display Result:

    ✅ Successfully split {chapter-title} into {N} subsections
    

    or

    ❌ Failed to split {chapter-title}: {error-message}
    

Concrete Example:

If split list contains ["cli-reference", "analysis-guide", "configuration"], you must:

1. Print "📖 Splitting chapter 1/3: CLI Reference"
2. Call SlashCommand with: /prodigy-create-chapter-subsections --project Debtmap --chapter cli-reference --chapters workflows/data/prodigy-chapters.json --book-dir book --structure-report .prodigy/book-analysis/structure-report.json --no-commit
3. Wait for completion, check result
4. Print "✅ Successfully split CLI Reference into 4 subsections"
5. Print "📖 Splitting chapter 2/3: Analysis Guide"
6. Call SlashCommand with: /prodigy-create-chapter-subsections --project Debtmap --chapter analysis-guide ...
7. Continue until all 3 chapters processed
8. Proceed to Phase 5 verification

Required Iteration Logic:

  • Must process chapters sequentially (not in parallel, to avoid file conflicts)
  • Must NOT stop on first failure - collect all errors and continue
  • Must reach Phase 5 verification even if some splits failed
  • Must create commit (Phase 7) even if some splits failed (commit what succeeded)

Phase 5: Verify Structural Integrity

After All Splits Complete:

  1. Verify Files Created:

    • Check that all expected directories exist
    • Verify index.md files created
    • Verify subsection files created
  2. Verify Configuration Updates:

    • Parse chapters.json to ensure al

Maintain Prodigy Split Oversized Chapters?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Prodigy Split Oversized Chapters on getagentictools](https://getagentictools.com/loops/iepathos-prodigy-split-oversized-chapters?ref=badge)