Topic 1 of 5 · 4 min read
Docs updated in the same change
Goal: Identify which docs a code change makes wrong and have the agent update them in the same pull request.
A code change is not finished until every doc it makes wrong is fixed in the same pull request. Docs that are updated "later" are usually never updated, and an agent will happily ship code that leaves them behind.
Check yourself · 1 of 3
A pull request changes a CLI flag from --out to --output. Where should the README fix go?
Why it matters
Readers trust the README, the API page and the quickstart more than the source, because the source is harder to read. When a default changes and the page still shows the old one, people lose an afternoon. Coding agents such as Claude Code, Codex, Cursor and Copilot make this worse in one way and better in another. They change code fast and rarely look at the docs unless told to. But they can also search a repo for every mention of a thing in seconds, which is exactly the chore humans skip. The practice is called docs as code: docs live in the repo, go through review and change with the code.
How to do it
- Ask the question in the task. Add one line to the prompt or to your
AGENTS.mdorCLAUDE.md: "If behaviour, flags, config, defaults or errors change, update every doc and example that mentions them, in this change." - Make the agent search before it writes. Have it grep for the old name, flag or default across
README.md,docs/, code comments, example files and the OpenAPI spec, and list the hits. - Review docs as part of the diff. Open the doc hunks first. Each one should match a code hunk. A code change with no doc hunk deserves a question: which docs did you check?
- Run what can run. Execute the quickstart commands and any example file. A doc example is a test nobody wrote yet.
- Add a check. A CI step that fails when
docs/links are broken or examples do not compile turns a habit into a rule.
Before and after
Task: "Make the request timeout configurable."
Weak result: the diff adds TIMEOUT_MS to config.ts and changes the default from 5000 to 10000. The README still says "requests time out after 5 seconds" and .env.example has no new key.
Fixed result: the same pull request also changes the README sentence, adds TIMEOUT_MS=10000 to .env.example, and updates the example in docs/client.md. The description lists the three doc files touched.
What goes wrong
- The agent updates only the file it was looking at. The same fact is repeated in four places, and three go stale.
- Docs are rewritten, not corrected. A tidy new paragraph hides the one changed fact and makes review harder. Ask for minimal edits.
- The agent documents what it intended, not what it built. Check each doc claim against the final code, not against the prompt.
Examples
A default changes, the README does not
The diff changes retries from 3 to 5 in client.ts. Searching for retries finds three more places: the README table, docs/errors.md ("after 3 attempts") and a code comment. The reviewer asks the agent to fix all three and paste the grep output into the pull request description. Nothing else in the docs is touched.
A CI link check as the backstop
- name: Check docs links
run: npx markdown-link-check README.md docs/*.md
The step fails when a renamed file leaves a dead link. It does not find wrong prose, so it supports the review and does not replace it.
Key points
- A change is done only when the docs it makes wrong are fixed in the same pull request.
- Put the rule in the task or in AGENTS.md so the agent searches docs, examples and config samples every time.
- Have the agent list every file that mentions the changed behaviour before it edits anything.
- In review, read the doc hunks first and match each one to a code hunk.
- Run quickstart commands and examples; an unrun example is an unchecked claim.
Common mistakes
- Treating docs as a follow-up ticket, so the code merges and the docs never catch up.
- Prompting the agent to "update the docs" without naming which behaviour changed, so it rewrites pages at random.
- Reviewing only code hunks and skipping the markdown files in the diff.
- Letting the agent rewrite whole pages when one sentence was wrong.
Check yourself · 2 of 3
An agent finished a code change. What should it do before editing any docs?
Check yourself · 3 of 3
A diff changes a default value in code but contains no markdown changes. What is the best reviewer response?
Practice items, not counted towards your mastery.
Start here
- Architectural Decision Records (adr.github.io) (opens in a new tab)DocsFree
Templates, tooling and examples for ADRs, from the community that maintains the format.
- Documenting Architecture Decisions (Michael Nygard) (opens in a new tab)ArticleFree
The original short essay: title, status, context, decision and consequences, kept small and in the repo.
- Docs as Code (Write the Docs) (opens in a new tab)ArticleFree
Treat docs like code: version control, review, automated checks and the same pull request.
More for this topic
- Documentation Best Practices (Google style guide) (opens in a new tab)ArticleFree
Keep docs minimal, fresh and close to the code, and delete what is dead.