pipelines / techdoc.yaml
Technical docs written from the code
Built to spend as little on agents as it can. Scripts collect what needs no judgment, a plan picks only the pages whose code changed, one agent per group writes them with a fresh context, and a cheaper model reviews against the code.
// the steps
What runs, in order.
- 01-gate
freeNo new commit outside docs/ since the last run: stop.
- 02-checks · 03-facts
scriptsRun the project's checks and extract components, routes, env vars and CI into summaries agents can read.
- 04-plan
agent · midDecides the components and which pages to regenerate.
- 05-group
foreach · agentOne agent per group of components, up to 20, each writing only its pages.
- 06-assemble
agent · midOverview, getting started, maintenance and an index, validated by a script.
- 07-review
review · cheapAnother model checks the pages against the code. A blocking issue is fixed and reviewed again, two rounds max.
- 99-pr
scriptA pull request with the docs.
// the file
The whole pipeline.
Shipped with caffeine as an example. Copy it to ~/.caffeine/pipelines/, list it on a target in workspace.yaml, then caffeine run techdoc.
description: "Write or update docs/techdoc/ with a skill, as a pull request" branch_prefix: caffeine/techdoc max_budget_usd: 3 # per agent step skills: [team-techdoc] # every agent step gets the skill's rules and reads its files cache: - name: cargo-target dir: CARGO_TARGET_DIR key: "{{os}}-{{arch}}-{{hash:Cargo.lock,rust-toolchain.toml,rust-toolchain}}" restore: ["{{os}}-{{arch}}-"] steps: - name: 01-gate # no new commit outside docs/ since the last run: stop, free run: caffeine gate changed --cmd "git log -1 --format=%H -- . ':(exclude)docs'" --key code-head - name: 02-checks # the checks of the skill's checks.md, as a script run: python3 {{pack}}/checks/run_checks.py .agent/checks timeout: 5400 verify: test -s .agent/checks/INDEX.md - name: 03-facts # components, dependencies, routes, env vars, CI, hooks run: python3 {{pack}}/checks/repo_facts.py .agent/facts verify: test -s .agent/facts/repo.md - name: 04-plan # which pages exist, and which to regenerate prompt: prompts/techdoc/plan.md model: mid max_turns: 25 timeout: 900 allowed_tools: [Read, Glob, Grep, Write] verify: caffeine scope '.agent/**' && python3 {{pack}}/checks/plan_tool.py check - name: 05-split # one plan file per group, and `groups=` for the next step run: python3 {{pack}}/checks/plan_tool.py split - name: 05-group # one agent per group with pages to regenerate foreach: vars.groups foreach_max: 20 prompt: prompts/techdoc/group.md model: mid max_turns: 80 timeout: 2400 continue_on_error: true # the assembly reports a page that failed allowed_tools: [Read, Write, Edit, Glob, Grep, "Bash(python3 *techdoc.py merge *)"] verify: caffeine scope 'docs/techdoc/**' && python3 {{pack}}/checks/plan_tool.py written {{item}} - name: 06-assemble # overview, getting started, maintenance, meta.json, report prompt: prompts/techdoc/assemble.md model: mid max_turns: 40 timeout: 1800 allowed_tools: [Read, Write, Edit, Glob, Grep, "Bash(python3 *techdoc.py merge *)", "Bash(python3 *techdoc.py check *)"] verify: caffeine scope 'docs/techdoc/**' && python3 {{skill.team-techdoc}}/scripts/techdoc.py check docs/techdoc - name: 07-review # another model checks the pages against the code review: prompts/techdoc/review.md model: cheap max_turns: 50 # 20+ pages to check: the default 30 ends before the verdict inputs: [.agent/checks/INDEX.md, .agent/facts/repo.md] allowed_tools: [Read, Grep, Glob, Write] fix: # a blocking issue: `mid` fixes it, then the review runs again model: mid prompt: prompts/techdoc/fix.md rounds: 2 max_turns: 30 allowed_tools: [Read, Edit, Glob, Grep, "Bash(python3 *techdoc.py check *)"] verify: caffeine scope 'docs/techdoc/**' && python3 {{skill.team-techdoc}}/scripts/techdoc.py check docs/techdoc - name: 99-pr run: caffeine pr