Back to catalog

book-chapter-management

Use when restructuring book chapters with TOC ordering.

Category ✍️ Writing

Book Chapter Management

Manage book chapters as individual numbered files with a TOC for ordering, reviews folder for version control, and subagent delegation for parallel writing.

When to Use

  • Restructuring a book (reordering chapters, merging/splitting content)
  • Writing multiple chapters in parallel via subagents
  • Need version control for chapter iterations
  • Assembling a full book from individual chapter files
  • Deduplicating content compiled from separate blog posts

Architecture

book-directory/
├── toc.md                    ← Chapter order + assembly command (single source of truth)
├── 00-intro.md               ← Individual chapter files (numbered)
├── 01-chapter.md
├── 02-chapter.md
├── reviews/                  ← Version snapshots
│   ├── round-1-v1-01.md      ← Before review round 1
│   ├── round-1-v2-01.md      ← After review round 1
│   └── round-2-v1-02.md      ← Before review round 2
├── full-book.md              ← Assembled from toc.md order
├── full-book.html            ← Generated HTML
└── book.pdf                  ← Generated PDF

TOC Format

Create toc.md as the single source of truth for chapter ordering:

# Book Title — Table of Contents

Order File Title Status
0 00-intro.md Intro ✅ keep
1 01-chapter.md Chapter 1 🆕 new
2 02-chapter.md Chapter 2 ✍️ rewrite
3 03-chapter.md Chapter 3 🆕 new

Assembly Command

bash

cat 00-intro.md 01-chapter.md 02-chapter.md 03-chapter.md > full-book.md

Status markers:
  • ✅ keep — unchanged from previous version
  • 🆕 new — entirely new content
  • ✍️ rewrite — rewriting existing content

Workflow: Restructuring

1. Move Old Chapters to Reviews

# Naming: round-N-vN-XX-chapter-name.md
mv 01-old-chapter.md reviews/round-4-v1-01-old-chapter.md
mv 02-old-chapter.md reviews/round-4-v1-02-old-chapter.md

2. Create/Update toc.md

Define the new chapter order and assembly command.

3. Write New Chapters

Write individual chapter files following the TOC order.

4. Assemble Full Book

cat 00-intro.md 01-chapter.md 02-chapter.md > full-book.md

5. Generate PDF

Use the book's PDF generation script (WeasyPrint or pandoc+LaTeX).

Workflow: Inserting a New Chapter (Renumbering)

When inserting a chapter into an existing numbered sequence:

1. Write the new chapter at its target number (e.g., 03-new.md).

2. Rename files from the insertion point onward using mv, working backward to avoid collisions: mv 07-ch.md 08-ch.md, mv 06-ch.md 07-ch.md, etc.

3. Update chapter headings inside each renamed file (# Chapter N: Title).

4. Scan ALL chapter files for stale cross-references. This is the step most likely to be missed. Chapters frequently reference other chapters by number (e.g., "what I said in Chapter 3"). After renumbering, every such reference must be checked and updated. Use:

   grep -rn "Chapter [0-9]" 0.md | grep -v "^0.:# Chapter"
   

5. Update the TOC and assembly command.

6. Verify with wc -w 0.md and grep -n "^# Chapter" 0.md.

Workflow: Synthesis Chapter

When content is dispersed across multiple chapters and needs to be pulled into a single unifying chapter:

1. Read all existing chapters to identify where the target content lives. Note specific paragraphs, quotes, or data points.

2. Write the synthesis chapter that weaves the dispersed material into a coherent narrative. The new chapter should reference other chapters (cross-references) rather than duplicate their content.

3. Add cross-references in the existing chapters pointing back to the synthesis chapter (e.g., "see Chapter N for the full stack").

4. Lightly trim duplicate material in existing chapters where the synthesis chapter now covers it — but don't over-trim. Each chapter must still stand alone.

5. Renumber as needed (see Inserting workflow above).

Workflow: Blog-to-Book Deduplication

When a book is assembled from separate blog posts, repeated sentences and structural patterns survive compilation. Blog posts need self-contained context; books don't.

Detection

Run after cat assembly into full-book.md:

from collections import Counter
import re
sentences = []
for line in open('full-book.md'):
    for sent in re.split(r'(?<=[.!?])\s+', line.strip()):
        if len(sent) > 40:
            sentences.append(sent)
dups = {s: c for s, c in Counter(sentences).items() if c > 1}

Three Categories

Category What it looks like Action
Exact sentence duplicates Same sentence in 2+ chapters Keep the version with more context; rephrase the other
Meta-references "This book..." appearing in mid-chapters Change to chapter-specific ("I wrote this chapter...")
Formulaic closers "The X effect is the point" / "compounding has barely started" Keep one instance (usually the first); vary the rest

Execution Order

1. Exact duplicates first (mechanical, low risk)

2. Meta-references (light touch)

3. Formulaic closers (editorial judgment)

4. Full read-through after edits to catch rhythm breaks and transitions that now feel abrupt

Key Pitfall

Some repeated sentences serve different arguments in different chapters (e.g., "Before Hermes, I ran this on discipline alone" in WINS intro vs. Self chapter). Don't blindly delete — check whether the sentence earns its place in each context.

After Edits: Reassemble and Verify

After patching individual chapter files, reassemble and verify:

cat 00-intro.md 01-chapter.md ... > full-book-v3.md

Then verify duplicates are gone:

from collections import Counter
import re
with open('full-book-v3.md') as f:
    content = f.read()
sentences = []
for line in content.split('\n'):
    for sent in re.split(r'(?<=[.!?])\s+', line.strip()):
        if len(sent) > 40:
            sentences.append(sent)
dups = {s: c for s, c in Counter(sentences).items() if c > 1}
if dups:
    for s, c in dups.items():
        print(f'[{c}x] {s[:120]}')
else:
    print('No exact duplicates remain.')

Also verify chapter structure: grep -n "^# " full-book-v3.md — check for duplicate chapter numbers (e.g., two "Chapter 6" headings from different source files).

Workflow: Parallel Chapter Writing via Subagents

When writing multiple chapters, delegate to subagents in parallel:

Task Template for Each Chapter

goal: Write Chapter N: "Title" for [book name].

Source material: [list files to read]
Requirements: [voice, style, word count]
Structure: [section outline]
Output: Save to /path/to/0N-chapter.md

Key Points

  • Each subagent gets its own isolated context
  • Provide source material file paths (subagents read files directly)
  • Include voice/style requirements in the goal
  • Specify exact output path
  • Subagents run in parallel (up to delegation.max_concurrent_children)

After Subagents Complete

1. Verify all files exist: ls -la 0*.md

2. Check word counts: wc -w 0*.md

3. Assemble: cat 00-.md 01-.md ... > full-book.md

4. Generate PDF

Reviews Folder Convention

Naming: round-N-vN-XX-chapter-name.md
  • N = review round number
  • vN = version within that round (v1 = before fixes, v2 = after fixes)
  • XX = original chapter number
  • chapter-name = descriptive slug
Example:
reviews/
├── round-1-v1-00-intro.md
├── round-1-v2-00-intro.md
├── round-2-v1-03-moving-to-vps.md
└── round-4-v1-07-stock-screening.md

Workflow: Editorial Review (Processing Callouts)

When a chapter has [!hh] callout comments left by Joseph during review:

1. Read the full chapter first

Load the no-ai-slop skill before editing. Process ALL callouts in one pass, not one at a time.

2. Classify each callout

See references/editorial-callout-patterns.md for observed callout types and examples.

  • Resolved action (strikethrough text, "I modified X, see if it reads well"): Apply the change, remove the callout.
  • Technical question ("validate this", "what does X mean"): Verify against source material or skill files. Fix the text if inaccurate, remove the callout. If the claim is correct, remove the callout silently.
  • Structural question ("shouldn't I include X?", "is this repeated in another chapter?"): Remove the callout and flag to user as a decision point. Don't make structural decisions unilaterally.
  • Readability check ("see if it reads well"): Read the paragraph, confirm it's fine, remove the callout. If it needs work, fix it.

3. Apply no-ai-slop pass

After resolving callouts, run the no-ai-slop rules on the full chapter: em-dashes, AI words, tight paragraphs, strong verbs.

4. Cross-chapter dedup check

When callouts mention content repeated in another chapter:

  • Read the other chapter to confirm the overlap
  • Recommend trimming unique-to-this-chapter vs. duplicate content
  • Let the user decide before cutting

Pitfall

Don't answer callout questions inside the document. Resolve them by editing the text or flagging to the user in your response.

Pitfalls

1. Check for existing reviews folder. Before creating reviews/, check if it already exists. User may have created it in a previous session.

2. Don't mix chapter files with reviews. Keep the working directory clean — only current chapter files at the top level.

3. Update toc.md when reordering. The TOC is the single source of truth. If you reorder chapters, update the TOC first.

4. Verify subagent output. Subagents self-report completion. Check that files exist and have reasonable word counts before assembling.

5. Preserve YAML frontmatter. Each chapter file should have YAML frontmatter with title. The assembly command concatenates them as-is.

6. Don't regenerate PDF after every edit. Wait until all chapters in a batch are reviewed before regenerating.

7. Blog-to-book deduplication. After compiling from blog posts, scan for repeated sentences, meta-references, and formulaic closers. See workflow above.

8. Chapter numbering. When source files have their own heading numbers, they may collide after assembly (e.g., two files both labeled "Chapter 6"). Verify chapter headings are unique after reassembly.

9. Stale cross-references after renumbering. Chapters frequently reference other chapters by number in examples, hypothetical callouts, or inline prose (e.g., "what I said in Chapter 3"). After inserting or renumbering, scan every file for these references. They don't show up as heading collisions — they just silently point at the wrong chapter. Use grep -rn "Chapter [0-9]" 0.md | grep -v "^0:# Chapter" to find them.

10. Verify technical claims in editorial callouts. When a [!hh] callout says "validate this" or questions a technical claim, check the actual source (skill files, config, logs) before removing the callout. Don't assume the draft is correct just because it reads well. The transcript-routing cost claim (36 cents vs. 8-12 cents) needed verification against the youtube-content skill, for example.

11. Cross-chapter content duplication. When a callout flags content repeated in another chapter, read both chapters before recommending cuts. Some repetition serves different arguments (standalone article vs. connected book). Recommend, don't cut — the user decides what earns its place in each context.