Documentation Loop
Keep docs in sync with the code: update affected docs when behavior changes, verified against the source.
What this Loop Engineering template does
Update the documentation so it matches the current code behavior, changing only the docs affected by the change and verifying examples against the source.
Read the code before editing docs. Only touch docs affected by the change. Do not document behavior that does not exist.
When to use it
When not to use it
Validation checks
Boundaries & stop rule
Copy the loop prompt
/goal Update the documentation so it matches the current code behavior, changing only the docs affected by the change and verifying examples against the source.Task type: CustomTarget tool: Claude CodeWork toward this goal until all validation checks pass or the stop rule is reached.Design hypothesis:This documentation loop can produce a safer result if the scope stays narrow, validation is explicit, and a checker can reject shortcut work.Smallest useful run:Run one bounded pass on the newest relevant signal before expanding scope or adding a schedule.Loop cycle:1. Discovery — Read the latest signal for this template before acting: CI output, issue detail, review comment, dataset report, or content brief.2. Handoff — Hand the work to one agent in an isolated branch, worktree, or clearly scoped session. Keep final approval with a human.3. Verification — Use an independent review pass to confirm the result, inspect the diff or artifact, and reject shortcut work.4. Persistence — Save a short run note with the signal reviewed, actions taken, validation result, and next recommended step.5. Scheduling — Run manually until the loop is reliable; only then consider a scheduled or event-triggered run.Context:Read the code before editing docs. Only touch docs affected by the change. Do not document behavior that does not exist.Validation:Docs match current code behaviorCode examples run or compileLinks and references resolveNo undocumented behavior is inventedValidation evidence:Record the original signal, checks run, final result, changed files or artifacts, and any checker rejection.Independent checker:Use an independent review pass to confirm the result, inspect the diff or artifact, and reject shortcut work.Boundaries:Do not change code to match the docsDo not invent behavior or APIsDo not rewrite unrelated docsDo not change brand or product positioningStop rule:Stop when the affected docs match the code and examples pass, or after 3 failed verification attempts.Maximum iterations: 3Budget:Example only: stop before exceeding the agreed per-run token budget.Human approval:Required before merge, deploy, delete, purchase, or external communication.Fallback:If the intended behavior is ambiguous, document what the code actually does and flag the ambiguity for a human.Loop Validation Log:- Hypothesis: This documentation loop can produce a safer result if the scope stays narrow, validation is explicit, and a checker can reject shortcut work.- Smallest useful run: Run one bounded pass on the newest relevant signal before expanding scope or adding a schedule.- Expected evidence: Record the original signal, checks run, final result, changed files or artifacts, and any checker rejection.- Actual evidence: [fill in after the run]- Passed? [yes / no / partial]- Feedback: After the run, note what the loop learned, what failed, and what should change before the next pass.- Next step: [stop / adjust the loop / run the next pass]Do not delete tests, bypass checks, or modify unrelated files just to satisfy the validation condition. If blocked, stop and summarize the blocker, attempted fixes, and recommended next action.
Failure modes to watch
Review receipt
This is a bounded review exercise for the template, not a claim about a production deployment.
Scenario
A generator gains a new human-approval field while its guide, example output, and FAQ still describe the previous format.
Baseline evidence
The documentation review maps the changed behavior to every public explanation, example, schema description, internal link, and claim about defaults or guarantees.
Validation result
The guide and example now match generated output, the FAQ explains the approval boundary, all links resolve, and a fresh run confirms the documented field appears as described.
Shortcut rejected
Updating only the changelog or copying a code comment into the guide is rejected because neither verifies the user's end-to-end experience.
Human gate
A product owner confirms that the documented approval behavior reflects policy and a reader unfamiliar with the implementation reviews the instructions for clarity.
Loop Engineering FAQ
No. When code and docs disagree, the docs follow the code. Changing behavior to match stale documentation is a forbidden action.