Skip to content
Back to skills

Writing Docstrings

ASecurity

Use when writing, rewriting, or auditing Python docstrings that a documentation site is generated from, or when docstrings are long, narrate the code, or leave a reader of the generated reference unable to find their way. Triggers - "audit the docstrings", "docstring slop", "docstrings as documentation", "the API reference reads badly", "rewrite these docstrings".

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 7, 2026
documentationpythonapidocumentation

Works with

  • api

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned November 7, 2026

npx -y skills add ahgraber/skills --skill writing-docstrings --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Writing Docstrings?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Writing Docstrings
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ahgraber-writing-docstrings/badge)](https://www.skillsdirectory.com/skills/ahgraber-writing-docstrings)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: writing-docstrings
description: Use when writing, rewriting, or auditing Python docstrings that a documentation site is generated from, or when docstrings are long, narrate the code, or leave a reader of the generated reference unable to find their way. Triggers - "audit the docstrings", "docstring slop", "docstrings as documentation", "the API reference reads badly", "rewrite these docstrings".
---

# Writing Docstrings

Docstrings that a site is generated from are the product's documentation.
Each one states what a reader needs, in a fixed place, in plain language.

## When to Use

- A documentation site (great-docs, quartodoc, mkdocstrings, Sphinx autodoc) renders the package's docstrings.
- An audit of docstrings for length, body narration, rationale, history, or vague wording.
- A rewrite of docstrings after an API change, where the reference must stay accurate.
- A new public function, class, or module needs a docstring that matches the rest.

## When Not to Use

- Comments inside a body, or slop in code: use `simplify`.
- Narrative documentation pages, tutorials, or a docs site built from prose: use `scaffold-docs`.
- Commit messages: use `commit-message`.

## Invocation Notice

- Tell the user when this skill is running: `writing-docstrings`.
  Skip the notice when the user asked for the skill by name or slash command; spelling and spacing need not match.
  A phrase from this skill's own trigger list is not a name — naming the work is not naming the skill.

## Workflow

1. Find what the site renders.
   Read the docs configuration for the parser and for the objects that get pages.
   A docstring of an object without a page is a maintainer note, not documentation.
   When the configuration does not settle it, probe the renderer with a throwaway package (`references/renderer-probe.md`).
2. Classify each docstring by level: landing page, module page, class, function or method, or not rendered.
   The level sets the register and the shape (`references/shape.md`).
3. Calibrate with the user before any bulk edit.
   Bring three docstrings at a time, of different levels or kinds.
   For each, quote it, give a verdict, name what fails, and show the rewrite.
   Use length only as a first filter: a long docstring can be all contract, and a short one can be too dense to read.
   Continue until the user agrees with the verdicts.
4. Write or rewrite to the shape and the register (`references/register.md`).
   Verify every fact against the code before you state it; read the body, the tests, or run it.
   Add a missing contract fact, such as a default or an error, when a reader needs it.
5. For more than about 30 docstrings, run the work in parallel with separate review sweeps (`references/parallel-run.md`).
6. Rebuild the site, or the renderer probe, and check that sections, links, and examples render.

## Output

- Rewritten docstrings, each true against the code and placed in the shape for its level.
- Body comments for rationale that guards against a wrong fix; other rationale deleted.
- Documentation-site configuration changes, when module pages or sections need them.

## References

- `references/shape.md`: the labeled sections and the shape for each level.
- `references/register.md`: reference and explanation registers, plain language, and what to keep and cut.
- `references/examples.md`: calibrated before-and-after examples.
- `references/renderer-probe.md`: how to check what a renderer does with a docstring.
- `references/parallel-run.md`: writer brief, batching, and review sweeps.

Files in this skill

  • SKILL.md3.5 KB
  • references/examples.md5.7 KB
  • references/parallel-run.md1.9 KB
  • references/register.md3.1 KB
  • references/renderer-probe.md2.3 KB
  • references/shape.md2.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in documentation →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.