AI-Assisted Coding · Module 4Lesson 5

Study explanation · Lesson 05 · 15 min

Generate and verify documentation

Fluent prose is not evidence. Let Claude write Google-style docstrings and a README without touching logic, then check the claims against the function bodies, the running /docs page and real status codes, and log every mismatch.

Listen to this lesson

Hear the lesson read aloud, with each sentence highlighted as you go.

Narrated by an AI voice.

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 artifacts · Lecture notes pp. 10-11
Documentation artifactExpected content
DocstringsGoogle-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.mdSetup, run, test, container, CI, and project conventions. Commands must match the actual repository.
No behavior changesDocumentation 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.

  1. Inspect the diff first. Confirm Claude changed documentation only, not application logic.
  2. Pick at least three docstrings and compare each one to the actual function body.
  3. Check status transition documentation against the real status rules in the code.
  4. Run the app and open /docs to compare schemas, status codes and route descriptions.
  5. 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.
  6. 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.

From a fluent claim to a verified one · Lecture notes pp. 10-11
  1. Claude draftsdocstrings + README
  2. Diff checkdocs only, no logic
  3. Comparefunction body, /docs, status codes
  4. Log mismatchclaim · reality · resolution
  5. Fix the docsor decide on a code fix
Claim vs. reality log, example rows · Lecture notes p. 11
AI claimedCode actually doesResolution
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.

Built from the Module 4 lecture notes, prompt library and additional readings; page references are to the supplied PDFs.

Your study checkpoint

Ready to continue?

Mark the lesson complete once you have read it and tried its idea on something real.

Next · Lesson 6