agentleFS
tiago-oliveira-catiago-oliveira-ca/zenodotus-harness/skills/documenting-code/SKILL.md

documenting-code

Skill1 starsChanged 8 days agoMITView on GitHub

The discipline for documenting production code and keeping the docs accurate — docstrings, API reference, READMEs, architecture notes, and code walkthroughs. Generate docs FROM the source of truth, document only doc-worthy changes (public API / architecture / dependencies / setup), pick the right generator and docstring convention per stack, and defend against drift (doctests → drift.lock anchors → /docs-drift). Draft, then let a human approve; leave an explicit TODO when you can't reconcile. Orchestrates zeno-doc-updater, /update-docs, /update-codemaps, zeno-stack/zeno-code-tour. Trigger on: "document this", "write docstrings", "API docs", "generate docs", "update the README", "document the code", "keep docs in sync", "docs are stale", "documentation drift", "doc coverage".

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When documenting production code, the goal is not "some prose exists" — it is docs that match the code and stay matched.

    line 16
  2. Distinctive:

    Document on a doc-worthy change.

    line 32
  3. Distinctive:

    Prefer docstrings / doc-comments at the definition over prose files that re-state code — they feed every generator, live next to what they …

    line 46
  4. Distinctive:

    Put them behind the same gate, layered:

    line 84
  5. Very specific:

    Doctests first: Prefer docstrings with runnable examples (Python doctest, Rust doc-tests) so an example that goes stale fails CI — zero …

    line 86
  6. Distinctive:

    Automation drafts; the human approves before publish: Never silently overwrite docs.

    line 99

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Documenting code — accurate docs, generated from the source of truth

When documenting production code, the goal is not "some prose exists" — it is docs that match the code and stay matched. Documentation that lies is worse than none, because it is trusted.

Iron Law: DOCS ARE GENERATED FROM THE SOURCE OF TRUTH AND VERIFIED — never hand-copied from code you hope is current. If a doc restates behavior, that behavior must be read from the code (or a generator run over it) in this pass, not remembered.

Scope boundary: this skill owns code-level docs (docstrings, API reference, README, code walkthroughs, drift). Delivery documents (BRD → PRD → FRD → ADR → SAD…) belong to the documentation dispatcher — route "write a PRD/ADR/spec" there, not here.

This skill is the discipline. The mechanical work is done by tools it orchestrates (below); its job is deciding whether, what, when, and keeping the result honest.

1. When to document (trigger table)

Document on a doc-worthy change; skip minor internal churn so docs don't turn to noise.

ChangeDocument?
New public feature / command / endpointYes
API / route / public signature changeYes
Dependency added or removedYes (setup + README)
Architecture / data-flow changeYes (codemap + notes)
Changed setup / build / run stepsYes (README / getting-started)
Internal refactor, private helper, formattingNo
Bug fix with no interface changeNo (unless it changes documented behavior)

2. Document at the source

Prefer docstrings / doc-comments at the definition over prose files that re-state code — they feed every generator, live next to what they describe, and survive refactors. Detect and match the repo's existing convention (don't introduce Google-style docstrings into a NumPy-style codebase). See the language code-standards sub-skill for that stack's docstring rules.

3. Pick the right generator + convention (drive it, don't reinvent extraction)

StackGeneratorDocstring / comment convention
PythonSphinx + autodoc, or MkDocs + mkdocstringsGoogle / NumPy / reST (match the repo)
TypeScript / JSTypeDoc (TS), JSDocTSDoc / JSDoc tags
SwiftDocC/// markup
Gogodoc / pkg.go.devdoc comments (sentence starts with the name)
Rustrustdoc/// + doc-tests
C / C++ / multi-langDoxygenDoxygen comments
JavaJavadocJavadoc tags
Rroxygen2#' tags
Oracle PL/SQLploc (npx → Markdown), or plsql-md-docJavaDoc /** */ tags on the package spec — see references/plsql-docs.md

For Oracle PL/SQL, the tag grammar, generator choice (ploc vs plsql-md-doc), and the separate schema-doc tools (SchemaSpy, DBMS_METADATA.GET_DDL) are detailed in references/plsql-docs.md. Author the docstrings per code-standards/database-data-modeling/oracle-plsql/SKILL.md §8.

Site tooling, when a docs site is wanted: default to MkDocs Material (low-friction, mkdocstrings for API docs) unless the repo's stack dictates otherwise (Starlight/Docusaurus/Fumadocs). The load-bearing pattern is docs-as-code: Markdown in the repo, built in CI, reviewed in the same PR as the code. Do not bundle or install any of these — recommend per repo.

4. Role split — produce what's needed, not everything

Different jobs, invoked on demand: reference (what each symbol does — from docstrings), tutorial (task walkthroughs — cite zeno-stack/zeno-code-tour), API (endpoints/signatures — from the generator), diagram (architecture/flow — cite puml-diagrams). Don't generate all four for a one-endpoint change.

5. Drift discipline (cheapest first — the core value)

The reason docs rot: code changes go through review, CI, and merge gates; docs go through nothing. Put them behind the same gate, layered:

  1. Doctests first. Prefer docstrings with runnable examples (Python doctest, Rust doc-tests) so an example that goes stale fails CI — zero extra infra.
  2. Anchor prose docs to code in a repo-root drift.lock (see references/drift-lock.md): each prose claim about code is bound to the symbol it describes, with a hash. On any change, the agent asks "which docs are anchored to the code I just touched?" and reconciles them.
  3. /docs-drift — on a diff, flag docs whose anchored code changed (stale) and changed public symbols with no doc anchor (undocumented). Draft the fix; refresh the anchors.

For repos that need hard guarantees, recommend (never bundle) external CI backstops: doctests, Fiberplane drift, Doc Detective.

6. Draft → review; TODO on uncertainty

Automation drafts; the human approves before publish. Never silently overwrite docs. And when you cannot confidently reconcile a doc to the code — the intent is genuinely ambiguous — leave an explicit TODO(doc-drift: <what's unclear>) rather than guessing a plausible-but-wrong description.

7. Orchestrated tools (this skill decides; these do the work)

  • /update-codemaps — structural/architecture maps → docs/CODEMAPS/.
  • /update-docs — prose/README/guide sync from sources of truth.
  • zeno-doc-updater agent — generation runs (jsdoc2md, dependency graphs, codemaps). This is the Review-gate's one hardcoded, always-available agent invocation (zeno/SKILL.md's "sanctioned exception" to registry-only selection) — this skill is where that wiring actually lives.
  • zeno-stack/zeno-code-tour — step-through .tour walkthroughs.

Related, not orchestrated: zeno-comment-analyzer — an Advisor-tier agent that audits inline comments for rot. Select it from agents/REGISTRY.md like any other specialist when comment quality is in scope; this skill doesn't invoke it automatically the way it does the four tools above.

Anti-pattern quick reference

Anti-patternInstead
Hand-writing prose that restates code from memoryGenerate from the source; read the code this pass
Documenting every internal changeFire only on the trigger table (API / arch / deps / setup)
Prose files that duplicate what docstrings should holdDocument at the definition; generate reference from it
Introducing a new docstring style into the repoMatch the convention already in use
Publishing generated docs without reviewDraft → human approves → publish
Guessing a description when intent is unclearLeave an explicit TODO(doc-drift:)
Leaving docs out of the change's verificationRun /docs-drift; reconcile anchored docs
Bundling MkDocs/Docusaurus/Mintlify as a dependencyRecommend per repo; install nothing

Rationalizations — Excuse | Reality-check

ExcuseReality-check
"The docs are probably still right""Probably" is how docs lie; read the code or run the generator
"It's a small change, skip the docs"If it touched a public API, it's doc-worthy — check the trigger table
"I'll write the README from what I remember"Memory drifts from code; generate from the source
"I'll just update the prose to match, roughly"Roughly-right docs mislead; anchor + verify, or leave a TODO

Red flags — stop before you claim the docs are done

  • You wrote a description without opening the code it describes.
  • You changed a public signature and touched no doc.
  • You're publishing generated docs no human has reviewed.
  • A doc's claim is ambiguous and you're about to guess instead of leaving a TODO.

Pre-flight checklist — run before delivering any documentation

  • The change was checked against the trigger table; docs updated only if doc-worthy.
  • Docs were generated from / verified against the current source, not memory.
  • Docstrings match the repo's existing convention for the stack.
  • Anchored docs reconciled via drift.lock / /docs-drift; examples are doctest-backed where possible.
  • Any unreconcilable doc carries an explicit TODO(doc-drift:).
  • Generated docs are presented as a draft for human review, not auto-published.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.