writing-docstrings

writing-docstrings is a skill for Claude Code from gg-mo/repo-hygiene. It costs 53 tokens per session (1,034 once invoked), scanned A, original, MIT.

A repository rule for documenting functions, methods, classes, and source files with docstrings. A docstring records the parts of a code contract that are not obvious from the code's name or type information.

In plain words
What is it for?
Use it when adding or changing code, creating source files, or reviewing work before committing it.
Why use it?
It helps future readers understand expected behavior, inputs, results, errors, and important side effects without reading the entire implementation. It also keeps documentation requirements consistent across the repository.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the repo-hygiene plugin — 9 skills, 1 hook shipped together

Good fit Use it when adding or changing code, creating source files, or reviewing work before committing it.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/gg-mo/repo-hygiene/writing-docstrings
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add gg-mo/repo-hygiene --skill writing-docstrings
Clone the repo
git clone --depth 1 https://github.com/gg-mo/repo-hygiene

Made for: Claude Code.

Or install repo-hygiene, the plugin that ships this one along with the rest of its 9 skills, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for writing-docstrings

README.md
[![agentmods](https://agentmods.dev/badge/skills/gg-mo/repo-hygiene/writing-docstrings/github.svg)](https://agentmods.dev/skills/gg-mo/repo-hygiene/writing-docstrings)
Your own site
<a href="https://agentmods.dev/skills/gg-mo/repo-hygiene/writing-docstrings"><img src="https://agentmods.dev/badge/skills/gg-mo/repo-hygiene/writing-docstrings/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for writing-docstrings

Your own site · 80×15
<a href="https://agentmods.dev/skills/gg-mo/repo-hygiene/writing-docstrings"><img src="https://agentmods.dev/badge/skills/gg-mo/repo-hygiene/writing-docstrings.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 53 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,034 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00053 $0.01034
Opus 5 $0.00026 $0.00517
Sonnet 5 $0.00011 $0.00207
Haiku 4.5 $0.00005 $0.00103

Measured 10d ago against content hash 303116aa0700, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

writing-docstrings scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/writing-docstrings/SKILL.md · 117 lines

How it starts

The opening of the file, as written. The whole thing — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Writing Docstrings

Overview

In a repo using repo-hygiene, docstrings on functions/classes and headers on source files are required. This OVERRIDES the default "no comments unless WHY is non-obvious" stance. The override exists because docstrings ARE the API contract — a future reader (human or agent) shouldn't have to read the body to know what to expect.

Core principle: A docstring earns its place by telling the reader something the signature does NOT tell them.

When To Use

  • Writing a new function, method, or class
  • Modifying a function's signature, return type, or contract
  • Creating a new source file (write a header)
  • Reviewing your own code before commit

What Earns a Docstring Its Place

A good docstring covers what the signature CAN'T:

  1. Contract — one-sentence promise, present tense
  2. Parameters — only those whose meaning isn't obvious from type/name
  3. Returns — only if non-obvious from the return type
  4. Raises / errors — failure modes the caller must handle
  5. Caveats — non-obvious behavior, side effects, performance, thread-safety

Skip anything the signature already conveys. The goal is information, not ceremony.

Before / After

Restates the signature (worthless):

def parse_date(raw: str) -> datetime:
    """Parse a string and return a datetime."""
    return datetime.strptime(raw, "%Y-%m-%d")

Empty ceremony:

def parse_date(raw: str) -> datetime:
    """
    :param raw: the raw string
    :returns: the parsed datetime
    """

Pins what the signature can't:

def parse_date(raw: str) -> datetime:
    """Parse a YYYY-MM-DD date. Raises ValueError on any other format."""
    return datetime.strptime(raw, "%Y-%m-%d")

File Headers

Every source file gets a header explaining its role. A header that just paraphrases the filename is worse than no header.

Paraphrases filename:

"""user_repository.py — the user repository."""

Read the full file on GitHub · 117 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 117 lines · 53 tokens per session scan A 303116aa0700

Subscribe to this mod's changes

writing-docstrings is a skill published in the GitHub repository gg-mo/repo-hygiene (3 stars, last pushed 4mo ago), licensed MIT. It adds 53 tokens to every session and 1,034 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

new-skill

Scaffold a new brooks-lint analysis skill so it passes npm run validate and npm run evals on the first try — generates skills/{name}/SKILL.md (with the mandatory "Do NOT trigger for:" clause and a Process section citing guide step ranges) plus skills/{name}/{name}-guide.md (sequentially numbered steps), then appends…

hyhmrright/brooks-lint · 145 tokens

brooks-sweep

Full-sweep mode: runs a unified analysis across all quality dimensions — code decay, architecture, tech debt, and test quality — then applies fixes directly to the codebase. Safe changes are auto-applied; risky changes are confirmed before execution. Drawing on twelve classic engineering books. Triggers when: user…

hyhmrright/brooks-lint · 178 tokens

chief-strategy-officer

Owns where the business plays and how it wins over a multi-year horizon — portfolio choices, corporate development, strategic partnerships, and planning under uncertainty. Use this for a decision about which markets or businesses to be in, whether to build, buy, or partner, how to allocate capital across business…

cbrock84/headcount · 93 tokens

chief-revenue-officer

Owns the revenue engine end to end: sales, monetization, pricing, customer success, retention, and partnerships. Use this for pricing and packaging decisions, sales strategy and coverage, forecast and pipeline health, churn and expansion, partner and channel strategy, or when marketing-sourced demand is not…

cbrock84/headcount · 80 tokens

ai-ml-governance

Governs models and AI systems in production — intended use, evaluation, monitoring, human oversight, documentation, and the decision to deploy or retire. Use this before deploying a model or AI feature, when defining evaluation criteria, when a model's behavior has drifted, when assessing AI risk or regulatory…

cbrock84/headcount · 83 tokens

paid-advertising

Plans, runs, and optimizes paid acquisition across search, social, and display — account structure, targeting, creative, bidding, budget, and the analysis that says whether to scale or stop. Use this to set up or restructure campaigns, write and iterate ad creative, diagnose rising costs or falling performance, decide…

cbrock84/headcount · 78 tokens