Documentation that sounds right
Part 4.4 uses AI for documentation, but the real skill is claim verification. If a docstring says a function validates something and the function does not, the documentation has turned a missing behavior into an official claim. Readers trust documentation precisely because it sounds sure of itself.
Key ideaThe most dangerous documentation is the documentation that sounds right. Fluent prose is not evidence; check it against the actual code and running API.
What to ask Claude to generate
Two artifacts, and one rule about what must not change.
| Documentation artifact | Expected content |
|---|---|
| Docstrings | Google-style docstrings for every public function and route handler in app/: summary, args, returns with type/shape, raises with actual exceptions, and examples for route handlers. |
| README.md | Setup, run, test, container, CI, and project conventions. Commands must match the actual repository. |
| No behavior changes | Documentation work should not change app logic unless you explicitly decide to make a code fix after verification. |
The verification checklist
The notes give six checks, in this order. The first one protects you from a documentation task that quietly became a code change.
- Inspect the diff first. Confirm Claude changed documentation only, not application logic.
- Pick at least three docstrings and compare each one to the actual function body.
- Check status transition documentation against the real status rules in the code.
- Run the app and open /docs to compare schemas, status codes and route descriptions.
- Check examples such as POST returning 201 if the implementation returns 201, DELETE returning 204 if it returns no content, and invalid input returning 422 when FastAPI or Pydantic validation applies.
- Follow the README commands from a clean mental model: could a new teammate run the app with only these instructions?
Claim vs. reality
Keep a short log of every documentation claim that did not match the code. The notes show three example rows to illustrate the kind of mismatch to look for; your own log records the real inaccuracies in your repository.
- Claude draftsdocstrings + README
- Diff checkdocs only, no logic
- Comparefunction body, /docs, status codes
- Log mismatchclaim · reality · resolution
- Fix the docsor decide on a code fix
| AI claimed | Code actually does | Resolution |
|---|---|---|
| POST /tasks returns 200. | The route returns 201 Created. | Update the docstring/README to say 201. |
| DELETE returns a JSON object. | The route returns 204 No Content. | Remove the invented response body from the docs. |
| Status can move freely between all states. | The model or service enforces specific allowed transitions. | Rewrite the status-rule explanation to match the actual code. |
Read with careIllustrative rows from the notes, not findings from any particular repository.
Read with carePrompt DOC3 tells Claude not to invent inaccuracies. If an audit finds nothing, ask for the most important claims to check by hand rather than accepting a log padded with made-up problems.
A README a new teammate can follow
Prompt DOC2 asks for ten README sections, from project overview and prerequisites to Docker, the CI summary, conventions and limitations, and a link to docs/decisions once a technical note exists. Every command must be copy-pasteable from the repo root, nothing may claim deployment, auth, a database or production readiness, and anything uncertain is marked [VERIFY]. Then you run the documented commands where you can and correct each mismatch.
- Only documentation changed in the diff.
- At least three docstrings checked against their function bodies.
- Status codes and schemas compared with the running /docs page.
- README commands run from the repo root.
- Claim-vs-reality log written from real mismatches.
Key takeaways
- Documentation work must not change logic; check the diff first.
- Compare docstrings with function bodies and the running /docs page, not with how they read.
- Watch status codes (201, 204, 422) and status-transition claims most closely.
- Log each real inaccuracy with what the code does and how you resolved it.