Agent skill
section-merger
Deterministically merge per-section files under `sections/` into `output/DRAFT.md`, preserving outline order and weaving transitions from `outline/transitions.md`. **Trigger**: merge sections, merge draft, combine section files, sections/ -> output/DRAFT.md, 合并小节, 拼接草稿. **Use when**: you have per-unit prose files under `sections/` and want a single `output/DRAFT.md` for polishing/review/LaTeX. **Skip if**: section files are missing or still contain scaffolding markers (fix `subsection-writer` first). **Network**: none. **Guardrail**: deterministic merge only (no new facts/citations); preserve section order from `outline/outline.yml`.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/section-merger
SKILL.md
Section Merger
Goal: assemble a paper-like output/DRAFT.md from:
sections/(per-section/per-subsection prose)outline/transitions.md(short hand-offs; generated bytransition-weaver)- By default,
section-mergerinserts only within-chapter H3→H3 transitions (keeps flow without adding narrator paragraphs between chapters). - Optional: if you want between-H2 transitions inserted too, create
outline/transitions.insert_h2.okin the workspace. - Format contract: only lines matching
- 3.1 → 3.2: <text>are injected by default (within-chapter H3 → next H3); keep<text>as one sentence. - Treat transitions as injected draft text: run
post-merge-voice-gateafter merging, and route fixes back tooutline/transitions.md(do not patch the merged draft). - Keep transitions paper-like (argument bridges), not title narration (avoid "From X to Y" / "Now we turn to").
- If transitions feel templated, fix
outline/subsection_briefs.jsonl(bridge_terms/contrast_hook) and regenerate viatransition-weaver.
- By default,
Evidence-first visuals (outline/tables.md, outline/timeline.md, outline/figures.md) are intermediate artifacts by default. If you want them in the final PDF, weave them into the relevant prose sections intentionally (instead of auto-injecting them as top-level ToC chapters).
This skill is deterministic: it does not rewrite content or invent prose; it only merges already-generated content.
Inputs
outline/outline.yml(drives section/subsection order)outline/transitions.md(required; generated bytransition-weaver)- Optional (diagnostics):
sections/sections_manifest.jsonl - Optional context:
GOAL.md
Outputs
output/DRAFT.mdoutput/MERGE_REPORT.md
Workflow (deterministic)
- Read
GOAL.md(if present) and use its first non-heading line as the draft title. - Read
outline/outline.ymlto determine the expected section/subsection order. - Merge the per-unit files under
sections/. - Insert transitions from
outline/transitions.md(within-chapter H3→H3 by default; between-H2 only ifoutline/transitions.insert_h2.okexists). - Write
output/DRAFT.mdand a deterministicoutput/MERGE_REPORT.md(missing files, ordering).
Script
Quick Start
python .codex/skills/section-merger/scripts/run.py --helppython .codex/skills/section-merger/scripts/run.py --workspace workspaces/<ws>
All Options
--workspace <dir>: workspace root--unit-id <U###>: unit id (optional; for logs)--inputs <semicolon-separated>: override inputs (rare; prefer defaults)--outputs <semicolon-separated>: override outputs (rare; prefer defaults)--checkpoint <C#>: checkpoint id (optional; for logs)
Examples
- Standard merge (outline + transitions + section files):
python .codex/skills/section-merger/scripts/run.py --workspace workspaces/<ws>
Troubleshooting
Issue: merge report says a subsection file is missing
Likely cause:
- A required
sections/*.mdfile has not been written yet (checksections/sections_manifest.jsonlif present to see which units exist).
Fix:
- Write the missing units under
sections/(typically viasubsection-writer) and rerun merge.
Didn't find tool you were looking for?