Write Docs
Pick the document type first, obey the general rules, and lint the result
before reporting it as done. One document may hold several types as
sections - a service description followed by an SOP and its known issues is
one document, not three. Where a repository states its own convention, that
convention wins over the defaults here.
General rules
- Format - Markdown. Every fenced block carries a language tag (
bash,
text, yaml, ...).
- Charset - ASCII only. No smart quotes, em dashes, non-breaking spaces
or box drawing.
- Graphics - ASCII art only.
- Lint - the document passes
markdownlint without edits:
blank line around every heading, list and fenced block, one H1, no
duplicate heading text, no trailing punctuation in headings, no trailing
whitespace, no hard tabs, file ends with a single newline.
- Language - English, unless the user asks for another language.
- Table of contents - required once a document has more than three H2
headings: a bullet list of links to the H2 headings, placed under the
intro paragraph. Service utilities are the exception - see below.
- Size - one item is at most one paragraph, three to four sentences.
Prose that overflows becomes its own section. Lists, tables and code
blocks do not count against it.
- Style - the simplest language that is still accurate: short sentences,
active voice, second person in procedures. Link every external product on
first mention.
- Runbooks - examples, tests and procedures are copy-pasteable: one
command per line, no
$ prompt inside the block, expected output shown
separately.
Document types
Pick the type before writing. If the request fits none of them, ask the user
instead of guessing.
Service utilities
Skills, agent instructions, memory and plans - documents an agent reads, not
a person.
- No table of contents, whatever the heading count.
- No runbooks: state the rule, do not demonstrate it.
Project description
- Why the project exists, which tasks and goals it serves.
- How it implements those goals.
Code description
- What the code does.
- Its main classes and methods.
- Two or three usage examples.
Service description
- Why the service is needed.
- How it is implemented.
- How to install it.
- How to integrate it.
- Examples.
SOP
- What the procedure covers.
- The procedure itself, as a copy-paste runbook.
- How to test that it worked.
Known issues
- The problem: symptom, trigger, blast radius.
- A runbook that fixes it.
Workflow
- Identify the type, asking the user when it is ambiguous.
- Read the repository's own conventions -
CLAUDE.md, GEMINI.md,
CONTRIBUTING.md, docs/README.md - before drafting. A
repository-specific template is a contract: keep its headers, field
lines and numbering.
- Extend a document that already covers the topic rather than adding a
second one.
- Draft against the general rules and the type's required content.
- Add or refresh the table of contents when the type allows one and the
document has more than three H2 headings.
- Validate, fix, revalidate.
- Commit through the repository's commit flow.
Validation
Markdown linters are rarely on PATH: they live in a project virtualenv, in
node_modules, or behind pre-commit. Find the one this repository uses,
then run it on the file. These two checks close the gap the linter leaves -
the first must print nothing, the second must show no stale link to a
document you renamed.
grep -nP '[^\x00-\x7F]' "docs/my-note.md"
grep -rn "old-basename" --include='*.md' .
1---2name: write-docs3description: Write or edit documentation - service utilities, project, code, service, SOP or known-issue notes - in a lint-clean, runbook-first house style. Use whenever documentation is created, restructured or reviewed.4---56# Write Docs78Pick the document type first, obey the general rules, and lint the result9before reporting it as done. One document may hold several types as10sections - a service description followed by an SOP and its known issues is11one document, not three. Where a repository states its own convention, that12convention wins over the defaults here.1314## General rules1516- **Format** - Markdown. Every fenced block carries a language tag (`bash`,17 `text`, `yaml`, ...).18- **Charset** - ASCII only. No smart quotes, em dashes, non-breaking spaces19 or box drawing.20- **Graphics** - ASCII art only.21- **Lint** - the document passes22 [markdownlint](https://github.com/DavidAnson/markdownlint) without edits:23 blank line around every heading, list and fenced block, one H1, no24 duplicate heading text, no trailing punctuation in headings, no trailing25 whitespace, no hard tabs, file ends with a single newline.26- **Language** - English, unless the user asks for another language.27- **Table of contents** - required once a document has more than three H228 headings: a bullet list of links to the H2 headings, placed under the29 intro paragraph. Service utilities are the exception - see below.30- **Size** - one item is at most one paragraph, three to four sentences.31 Prose that overflows becomes its own section. Lists, tables and code32 blocks do not count against it.33- **Style** - the simplest language that is still accurate: short sentences,34 active voice, second person in procedures. Link every external product on35 first mention.36- **Runbooks** - examples, tests and procedures are copy-pasteable: one37 command per line, no `$` prompt inside the block, expected output shown38 separately.3940## Document types4142Pick the type before writing. If the request fits none of them, ask the user43instead of guessing.4445### Service utilities4647Skills, agent instructions, memory and plans - documents an agent reads, not48a person.4950- No table of contents, whatever the heading count.51- No runbooks: state the rule, do not demonstrate it.5253### Project description5455- Why the project exists, which tasks and goals it serves.56- How it implements those goals.5758### Code description5960- What the code does.61- Its main classes and methods.62- Two or three usage examples.6364### Service description6566- Why the service is needed.67- How it is implemented.68- How to install it.69- How to integrate it.70- Examples.7172### SOP7374- What the procedure covers.75- The procedure itself, as a copy-paste runbook.76- How to test that it worked.7778### Known issues7980- The problem: symptom, trigger, blast radius.81- A runbook that fixes it.8283## Workflow84851. Identify the type, asking the user when it is ambiguous.862. Read the repository's own conventions - `CLAUDE.md`, `GEMINI.md`,87 `CONTRIBUTING.md`, `docs/README.md` - before drafting. A88 repository-specific template is a contract: keep its headers, field89 lines and numbering.903. Extend a document that already covers the topic rather than adding a91 second one.924. Draft against the general rules and the type's required content.935. Add or refresh the table of contents when the type allows one and the94 document has more than three H2 headings.956. Validate, fix, revalidate.967. Commit through the repository's commit flow.9798## Validation99100Markdown linters are rarely on `PATH`: they live in a project virtualenv, in101`node_modules`, or behind `pre-commit`. Find the one this repository uses,102then run it on the file. These two checks close the gap the linter leaves -103the first must print nothing, the second must show no stale link to a104document you renamed.105106```bash107grep -nP '[^\x00-\x7F]' "docs/my-note.md"108grep -rn "old-basename" --include='*.md' .109```