handbook-writer
Installation
SKILL.md
- Set up task management. Parallelize with sub-agents. Ensure resumability after interruption.
- Build a manifest of all input documents listing file type and size.
- Convert non-text files to readable text with minimal content loss.
Prefer existing tools (e.g.
pandoc) over AI models, which cost more tokens. Use a cheap or local multimodal model for image descriptions. Mark empty or unconvertible files as skipped. - Categorize documents into tiers by content type, size, and complexity. Store tiers in a data file.
Ask the user to clarify size thresholds (bytes, characters, tokens, or lines) or expected modules if ambiguous.
- Tier 1: Complex, small-to-medium, or high-priority documents. Use the most capable AI model.
- Tier 2: Medium documents with simple, repetitive, or low-priority content. Use a cheaper, faster model.
- Tier 3: Large or highly repetitive/low-priority documents. Use the cheapest model or programmatic summarization.
- Pre-process file types programmatically without per-file AI calls:
- Generate initial source code descriptions with language-appropriate documentation tools.
- Extract structural metadata from each file (e.g. parent class, interfaces, abstract/concrete, fields, members, properties). Define a consistent header format with a fixed item order across all description files.
- Batch-describe images via a cheap or local multimodal model.
- Produce one Markdown description file per non-skipped document.
- Write resumable pre-processing scripts with a formal execution plan.
- Mirror the original directory structure. Flatten or normalize long/incompatible paths and log the mapping.
- Run pre-processing to completion. Verify every non-skipped document has a description file.
- Post-process each description with the tier-appropriate AI model. Apply only to types that need it (e.g. source code, text). Skip data files and images already described. Track progress via task management.
- Plan information propagation based on file structure and inter-document relationships:
- Horizontal: across documents at the same abstraction level.
- Vertical: between abstraction levels.
- For source code: build a code index if none exists. Prefer existing indexing tools; fall back to TreeSitter. Keep the index simple but preserve cross-references.
- Execute the propagation plan. Add cross-references to description files. Store the reference graph in a data file.
- Cluster documents by cross-references into modules (subsystems). Store the module list in a data file. Decide whether multi-module membership is allowed based on project context and file type.
- Build a top-level
TOC.mdfrom the module list. - In a separate subdirectory, write a description file per module listing its member documents.
- For each module:
- Collect summaries from all member descriptions.
- Synthesize a module-level summary and enrich the module description.
- Re-process each member description using the enriched module context.
- For source code: ensure all fields, members, properties, and events have descriptions.
- Collect all module contexts.
Add a project-level description to
TOC.mdusing the enriched module contexts. - Evaluate completeness at project and module levels. Verify a reader can locate any description within a few steps via progressive disclosure. If not, return to step 13. Repeat up to 6 times, numbering each run. Track progress for resumability.
- Verify structure:
TOC.mdlinks to module descriptions; module descriptions link to document descriptions; all links are cross-referenced. - Add
Index.mdreferencing every document description regardless of module. Link it fromTOC.md. - Programmatically verify all references. Fix any broken links.
- Evaluate module boundaries against project context. If inadequate, ask the user for guidance and restructure. Reuse existing work by updating only the differences. After restructuring, re-verify all references.
- If module boundaries are sound, present a final summary to the user.
Keep all the data files produced during the writing process, so the user can use them to iterate on the book further.