# Review AI-generated docstrings beyond coverage counts

Canonical: https://githtml.com/guides/review-ai-docstring-coverage-quality
Published: 2026-11-23
Publisher: WaveTech LLC / gitHtml

Review AI-generated docstrings by whether they explain the function's contract, not by how many functions now contain text. Verify parameters, return values, exceptions, side effects, and caller obligations against the implementation. Remove comments that merely restate names, and keep uncertainty visible when the code does not establish the guarantee the draft wants to describe.

## Choose which behavior needs explanation

Start with the public or maintenance-critical surface rather than asking for a docstring on every trivial helper. Identify the questions a caller cannot answer from the signature alone: units, ownership, accepted ranges, ordering, mutation, or failure conditions. A sentence such as processes the data adds little when the function is already named process_data. Do not reward coverage metrics that encourage empty repetition. Record the language's docstring conventions and the project's style, but treat those conventions as structure rather than proof of accuracy. A well-formatted paragraph can still omit the one condition that prevents misuse.

## Trace each substantive assertion to evidence

Compare the generated parameter descriptions with actual parsing and validation. Check whether the function mutates inputs, performs I/O, caches results, or raises errors through called code. The scaffold below captures those assertions without requiring a long essay for every function. Distinguish documented guarantees from incidental implementation details that may change. If a return value can be absent or partial, say under which conditions. Do not infer thread safety, determinism, or performance from a short implementation. Use tests as evidence for specific cases, not as a blanket guarantee. Keep examples safe and independently verified when they are intended to run.

````text
Symbol and audience:
Caller questions:
Parameters and units:
Return conditions:
Exceptions:
Mutation / I/O / ownership:
Evidence:
Redundant prose to remove:
Unresolved contract questions:
````

## Review the rendered reference and maintenance cost

Generate the project's reference locally if docstrings feed published API pages, then inspect representative entries in context. Repeated boilerplate can make the output harder to scan even when each function technically has documentation. Remove redundant prose and keep the contract details near the relevant parameter or result. Check that the docstring changes did not introduce executable doctest failures or other tooling effects. Record unresolved behavioral questions for the maintainer rather than fabricating answers. The best outcome may be fewer, better docstrings that explain the difficult contracts, with simple internal helpers left self-explanatory. Quality should be measured by reduced ambiguity for callers, not by a larger word count. For overloaded terms, use the project's established vocabulary consistently. A fresh synonym can make an otherwise accurate docstring imply a different lifecycle state or ownership relationship than neighboring API entries.

1. Prioritize public or difficult contracts and identify questions signatures do not answer.
2. Verify every substantive assertion against implementation and focused tests.
3. Remove name-restating boilerplate and avoid unsupported guarantees.
4. Inspect generated reference pages and relevant example tests after the edit.

## Sources and further reading

- [PEP 257: Docstring conventions](https://peps.python.org/pep-0257/)
- [Google Technical Writing: Using LLMs](https://developers.google.com/tech-writing/two/llms)

## Related guides

- [Check an AI plan’s file map before code changes begin](https://githtml.com/guides/review-ai-plan-file-change-map)
- [Turn an AI plan into acceptance criteria you can check](https://githtml.com/guides/acceptance-criteria-ai-plan-reading)
- [Read an AI implementation plan before approving the work](https://githtml.com/guides/review-ai-implementation-plan-before-approving)
- [Simplify AI-written documentation without changing the technical contract](https://githtml.com/guides/review-ai-audience-rewrite-accuracy)

Editorial approach: https://githtml.com/guides/about
