Documentation
Author, audit, and maintain project documentation across every surface that matters: the agent hot path (CLAUDE.md, AGENTS.md, .claude/rules/), the human entry point (README.md), and the narrative tier (docs/).
This is the single home for "make our docs good" work — bootstrapping a new project, refreshing docs after a sprint, writing a README that converts readers into users, or auditing the whole estate for drift.
This SKILL.md is a thin index. Detailed authoring rules live in
rules/*.md and load on demand. Worked examples are in
references/*.md. Literal scaffolding skeletons are in templates/*.md.
Do not preload everything — load only what the current phase asks for.
Mode Detection
Parse $ARGUMENTS (first token) and route to one of four modes.
A second token of --auto is a cross-cutting modifier (see below).
| Mode |
Default |
Trigger |
init |
|
"init", "bootstrap", "scaffold", or $ARGUMENTS == "init" (no existing CLAUDE.md). |
update |
yes |
Default when a CLAUDE.md already exists. "update", "sync", "refresh", "drift". |
readme |
|
"readme", "write a README", "audit the README", or $ARGUMENTS == "readme". |
audit |
|
"audit", "review the docs", "doc health check", or $ARGUMENTS == "audit". |
--auto modifier — append to any mode token to enable the autonomous-workflow guardrails.
Always passed by autonomous-workflow Phase 5 as Skill("docs", "update --auto").
When --auto is present, also load auto-update-loop.md before executing the mode's phases.
Disambiguation rule when no mode token is passed:
- If
./CLAUDE.md does not exist → init.
- Else if
./README.md does not exist and the user mentioned "README" → readme.
- Else →
update.
State the detected mode in one line before continuing:
Mode: update
Target: this repo
Shared Foundations (every mode loads these)
Regardless of mode, every run is governed by three rule files.
Load them once on first need; do not reload them per phase.
| File |
What it gives you |
rules/content-routing.md |
The Content Routing Rubric — which surface owns which kind of content, and why. |
rules/placement-resolver.md |
The innermost-wins algorithm for picking the specific file (root vs nested CLAUDE.md, .claude/rules/ with paths:, etc.). |
rules/writing-style.md |
Google + Microsoft style highlights, plain-language rules, and the agent-readable docs pattern. |
Then add the rule files specific to the mode:
When invoked from a non-interactive caller (autonomous-workflow Phase 5) — passed as --auto — also load auto-update-loop.md.
That rule adds four non-negotiable gates (hot-path budget, recurrence threshold ≥ 2, removed-rules ledger, optional ablation) plus the JSON run-summary contract the caller logs.
Mode: init — bootstrap docs from scratch
Use when a project has no Claude configuration and (optionally) no documentation.
Produces a tiered setup sized to the project's complexity.
Phases
- Detect existing config. Check for
CLAUDE.md, .claude/, AGENTS.md,
README.md, docs/. If any exist, ask via AskUserQuestion:
Overwrite / Merge missing / Skip / Abort.
- Triage complexity. Count source files, directories, monorepo
packages, CI/CD presence. See
references/archetypes.md
for the small / medium / large thresholds and the per-tier file matrix.
- Detect tech stack. Package manager (pnpm / npm / yarn / bun / poetry /
cargo / go.mod), test framework, linters, monorepo signal (
nx.json,
turbo.json, pnpm-workspace.yaml).
- Scaffold the tier's files. Use
templates/claude-md.md,
templates/readme.md, and the docs/* templates listed in
rules/docs-folder.md.
- Wire
.gitignore. Add .claude/settings.local.json idempotently.
- Summarize. Print a table of created files with line counts and
audience.
Hard rules during init
- Route by kind, not by file pattern. Rules go to
CLAUDE.md /
.claude/rules/; narrative goes to docs/; marketing goes to README.md.
See rules/content-routing.md.
- CLAUDE.md ≤ 200 lines. Anthropic's own threshold — beyond it,
adherence drops measurably.
- README first viewport must answer what is this, does it solve my
problem, can I trust it? See
rules/readme.md for the
above-the-fold checklist.
- Never duplicate content between
CLAUDE.md, README.md, and docs/.
Pick one owner; link from the others.
Mode: update — sync docs with the codebase
Use after work has landed on a branch.
Detects drift, applies targeted fixes, and pushes new rules to the innermost-ancestor destination so the hot path does not bloat over time.
Argument parsing
| Argument |
Default |
Effect |
branch |
yes |
Compare current branch vs the default branch. Default for update. |
recent [N] |
|
Diff the last N commits (default 10). |
paths <glob> |
|
Limit the diff to <glob>. The Placement Resolver still decides destinations. |
nested <dir> |
|
Route all updates for changes under <dir> to <dir>/CLAUDE.md (scaffold if missing). |
pattern <glob> |
|
Discovery-driven — scan files matching <glob> for shared structure, emit one rule. |
holistic |
|
Run holistic-analysis refactor on each affected area before drafting docs updates. |
dry-run |
|
Preview only. Print proposed changes; do not write. |
all |
|
Full audit against the current codebase (no diff). Equivalent to audit mode for sync only. |
Phases
- Detect changes (see
rules/drift-detection.md §1 for git diff
commands and the area-classification table).
- Read current docs — every
CLAUDE.md, .claude/rules/*.md,
docs/**/*.md, AGENTS.md. Build a map of what's documented today.
- Drift analysis. Run deterministic checks first (dead paths,
removed commands, broken
@imports); then semantic checks (architecture
claims, style claims, stale gotchas). See rules/drift-detection.md.
- Holistic analysis (if
holistic was passed) — see
rules/drift-detection.md §4.
- Generate updates. Each proposed change is classified by content
kind, routed via
content-routing.md, and
placed via placement-resolver.md.
Priority tiers: P0 stale fixes apply immediately; P1 new patterns ask
for confirmation; P2 polish skips unless requested.
- Apply (or dry-run report).
- Summarize. Per-file table of changes plus a list of areas
intentionally skipped because Claude can infer them.
Sub-modes inside update
Mode: readme — write or audit a README
Use when the README is the asset under work.
Two sub-modes detected from context:
- No README exists or user says "write a README" → scaffold mode.
- README exists and user says "audit / review / improve" → audit mode.
Scaffold sub-mode
- Detect tech stack and project type (library / app / monorepo root /
CLI tool).
- Render
templates/readme.md with the structure from the standard-readme
spec — see rules/readme.md for the mandatory section
order and the badge selection rules.
- Apply the above-the-fold checklist before declaring done — the
first viewport must carry name, one-line tagline, hero visual or
demo, primary CTA badges, and one install line.
Audit sub-mode
- Read the README.
- Run the README audit rubric in
rules/readme.md §4.
Score each item PASS / WARN / FAIL with one line of evidence.
- End with a prioritized Top 3 fixes list — biggest reader-time
wins first.
Mode: audit — comprehensive documentation health check
Read-only by default.
Produces a structured report covering every doc surface.
Phases
- Inventory. List every documentation file across the repo.
- Per-surface audits:
- Drift checks — full set from
rules/drift-detection.md §3 (dead paths, removed commands, broken @imports, hot-path leakage).
- CI lint coverage — see
rules/maintenance.md for the recommended markdownlint / Vale / alex / lychee stack.
- Prioritized report. P0 (stale / wrong) → P1 (missing high-value content) → P2 (polish).
If the user asks to apply fixes, route to update mode with the audit findings as the input.
Definition of Done
Each mode has a closing gate. Treat any unchecked item as a defect.
init
update
readme
audit
Core Principles
- Right surface, right cost.
CLAUDE.md is auto-loaded — every
line is a recurring token cost. README.md is read once by humans
evaluating the project. docs/ is loaded on demand. Route by these
costs, not by what feels natural to write.
- Innermost-wins. Nested
CLAUDE.md files load only when the agent
is in that subtree. A rule about packages/foo/** placed in
packages/foo/CLAUDE.md costs zero tokens for someone in
packages/bar/. The same rule in root costs everyone, every turn.
- Be prescriptive, not descriptive. Tell the agent what to do; do
not explain concepts. Decision tables and numbered lists beat prose.
- Each document serves exactly one Diátaxis quadrant. Tutorial or
how-to or reference or explanation. If a doc serves two, split it.
- Never duplicate facts across surfaces. Pick one owner; link from
the others. Duplicates always drift.
- Test the docs by removal. "Would removing this cause Claude or a
reader to make a mistake?" If no, delete it.
Anti-patterns (one-liner — full list in rules/ per surface)
CLAUDE.md over 200 lines (Anthropic's own threshold — adherence drops).
- Pattern-scoped rule placed in root
CLAUDE.md instead of .claude/rules/
with paths:.
- README wall-of-badges (>10 badges); TOC for a 60-line README.
docs/ files unreferenced from anywhere (orphans).
- Same fact written in
CLAUDE.md and docs/ — one will drift.
- Narrative paragraphs ("we picked X because Y, the system grew as Z…") in
CLAUDE.md instead of docs/.
- Marketing prose ("blazingly fast," "simply," "easily") with no benchmark.
- README API reference dump — move to
docs/.
- Backslash paths anywhere.
- Time-sensitive claims ("after August 2025…") in any surface.
Cross-tool note: AGENTS.md
agents.md is the cross-tool open spec read by
Codex CLI, Cursor, Aider, Devin, GitHub Copilot, Gemini CLI, and others.
Claude Code reads CLAUDE.md, not AGENTS.md directly.
Two interop options:
- Symlink —
ln -s CLAUDE.md AGENTS.md (simplest; one source of truth).
@import — keep both files but have CLAUDE.md start with @AGENTS.md and put shared content in AGENTS.md.
For mixed-tool teams, prefer the symlink.
For Claude-Code-first teams with cross-tool readers as secondary, prefer the @import.
See rules/claude-md.md §6 for the trade-offs.
1---2name: docs3description: Authors, audits, and maintains project documentation across CLAUDE.md / .claude/rules/, AGENTS.md, README.md, and Diátaxis docs/ trees (root + nested for monorepos). Four modes: init scaffolds a tiered docs setup from scratch; update detects drift (dead @imports, renamed commands, stale narrative) and incrementally refreshes via a Placement Resolver that pushes rules to the innermost-ancestor destination; readme writes or audits a README against the standard-readme spec; audit produces a documentation health report across every surface. Routes by kind: hard rules to CLAUDE.md, path-scoped patterns to .claude/rules/, narrative to docs/, marketing to README.md. Triggers on "init claude", "bootstrap docs", "scaffold CLAUDE.md", "update docs", "sync CLAUDE.md", "docs drift", "write a README", "audit our docs", "review the README", "Diátaxis", "/docs".4license: MIT5---67# Documentation89Author, audit, and maintain project documentation across every surface that matters: the **agent hot path** (`CLAUDE.md`, `AGENTS.md`, `.claude/rules/`), the **human entry point** (`README.md`), and the **narrative tier** (`docs/`).10This is the single home for "make our docs good" work — bootstrapping a new project, refreshing docs after a sprint, writing a README that converts readers into users, or auditing the whole estate for drift.1112> **This `SKILL.md` is a thin index.** Detailed authoring rules live in13> `rules/*.md` and load on demand. Worked examples are in14> `references/*.md`. Literal scaffolding skeletons are in `templates/*.md`.15> Do not preload everything — load only what the current phase asks for.1617---1819## Mode Detection2021Parse `$ARGUMENTS` (first token) and route to one of four modes.22A second token of `--auto` is a cross-cutting modifier (see below).2324| Mode | Default | Trigger |25| --------- | ------- | -------------------------------------------------------------------------------------- |26| `init` | | "init", "bootstrap", "scaffold", or `$ARGUMENTS == "init"` (no existing CLAUDE.md). |27| `update` | **yes** | Default when a `CLAUDE.md` already exists. "update", "sync", "refresh", "drift". |28| `readme` | | "readme", "write a README", "audit the README", or `$ARGUMENTS == "readme"`. |29| `audit` | | "audit", "review the docs", "doc health check", or `$ARGUMENTS == "audit"`. |3031**`--auto` modifier** — append to any mode token to enable the autonomous-workflow guardrails.32Always passed by `autonomous-workflow` Phase 5 as `Skill("docs", "update --auto")`.33When `--auto` is present, also load [`auto-update-loop.md`](./rules/auto-update-loop.md) before executing the mode's phases.3435Disambiguation rule when no mode token is passed:36371. If `./CLAUDE.md` does not exist → `init`.382. Else if `./README.md` does not exist and the user mentioned "README" → `readme`.393. Else → `update`.4041State the detected mode in one line before continuing:4243```44Mode: update45Target: this repo46```4748---4950## Shared Foundations (every mode loads these)5152Regardless of mode, every run is governed by three rule files.53Load them once on first need; do not reload them per phase.5455| File | What it gives you |56| --------------------------------------- | ---------------------------------------------------------------------------------------------- |57| [`rules/content-routing.md`](./rules/content-routing.md) | The Content Routing Rubric — which surface owns which kind of content, and why. |58| [`rules/placement-resolver.md`](./rules/placement-resolver.md) | The innermost-wins algorithm for picking the *specific* file (root vs nested CLAUDE.md, `.claude/rules/` with `paths:`, etc.). |59| [`rules/writing-style.md`](./rules/writing-style.md) | Google + Microsoft style highlights, plain-language rules, and the agent-readable docs pattern. |6061Then add the rule files specific to the mode:6263| Mode | Additional rules to load |64| -------- | ------------------------------------------------------------------------------------------------------------------------- |65| `init` | [`claude-md.md`](./rules/claude-md.md), [`readme.md`](./rules/readme.md), [`docs-folder.md`](./rules/docs-folder.md) |66| `update` | [`drift-detection.md`](./rules/drift-detection.md), [`claude-md.md`](./rules/claude-md.md) |67| `readme` | [`readme.md`](./rules/readme.md) |68| `audit` | All of the above, plus [`maintenance.md`](./rules/maintenance.md) for CI lint stack guidance. |6970When invoked from a non-interactive caller (`autonomous-workflow` Phase 5) — passed as `--auto` — also load [`auto-update-loop.md`](./rules/auto-update-loop.md).71That rule adds four non-negotiable gates (hot-path budget, recurrence threshold ≥ 2, removed-rules ledger, optional ablation) plus the JSON run-summary contract the caller logs.7273---7475## Mode: `init` — bootstrap docs from scratch7677Use when a project has no Claude configuration and (optionally) no documentation.78Produces a tiered setup sized to the project's complexity.7980### Phases81821. **Detect existing config.** Check for `CLAUDE.md`, `.claude/`, `AGENTS.md`,83 `README.md`, `docs/`. If any exist, ask via `AskUserQuestion`:84 **Overwrite** / **Merge missing** / **Skip / Abort**.852. **Triage complexity.** Count source files, directories, monorepo86 packages, CI/CD presence. See [`references/archetypes.md`](./references/archetypes.md)87 for the small / medium / large thresholds and the per-tier file matrix.883. **Detect tech stack.** Package manager (pnpm / npm / yarn / bun / poetry /89 cargo / go.mod), test framework, linters, monorepo signal (`nx.json`,90 `turbo.json`, `pnpm-workspace.yaml`).914. **Scaffold the tier's files.** Use `templates/claude-md.md`,92 `templates/readme.md`, and the `docs/*` templates listed in93 [`rules/docs-folder.md`](./rules/docs-folder.md).945. **Wire `.gitignore`.** Add `.claude/settings.local.json` idempotently.956. **Summarize.** Print a table of created files with line counts and96 audience.9798### Hard rules during `init`99100- **Route by kind, not by file pattern.** Rules go to `CLAUDE.md` /101 `.claude/rules/`; narrative goes to `docs/`; marketing goes to `README.md`.102 See [`rules/content-routing.md`](./rules/content-routing.md).103- **CLAUDE.md ≤ 200 lines.** Anthropic's own threshold — beyond it,104 adherence drops measurably.105- **README first viewport must answer** *what is this, does it solve my106 problem, can I trust it?* See [`rules/readme.md`](./rules/readme.md) for the107 above-the-fold checklist.108- **Never duplicate** content between `CLAUDE.md`, `README.md`, and `docs/`.109 Pick one owner; link from the others.110111---112113## Mode: `update` — sync docs with the codebase114115Use after work has landed on a branch.116Detects drift, applies targeted fixes, and pushes new rules to the innermost-ancestor destination so the hot path does not bloat over time.117118### Argument parsing119120| Argument | Default | Effect |121| ----------------- | ------- | -------------------------------------------------------------------------------------------- |122| `branch` | **yes** | Compare current branch vs the default branch. Default for `update`. |123| `recent [N]` | | Diff the last N commits (default 10). |124| `paths <glob>` | | Limit the diff to `<glob>`. The Placement Resolver still decides destinations. |125| `nested <dir>` | | Route all updates for changes under `<dir>` to `<dir>/CLAUDE.md` (scaffold if missing). |126| `pattern <glob>` | | Discovery-driven — scan files matching `<glob>` for shared structure, emit one rule. |127| `holistic` | | Run `holistic-analysis refactor` on each affected area before drafting docs updates. |128| `dry-run` | | Preview only. Print proposed changes; do not write. |129| `all` | | Full audit against the current codebase (no diff). Equivalent to `audit` mode for sync only. |130131### Phases1321331. **Detect changes** (see `rules/drift-detection.md` §1 for `git diff`134 commands and the area-classification table).1352. **Read current docs** — every `CLAUDE.md`, `.claude/rules/*.md`,136 `docs/**/*.md`, `AGENTS.md`. Build a map of what's documented today.1373. **Drift analysis.** Run deterministic checks first (dead paths,138 removed commands, broken `@imports`); then semantic checks (architecture139 claims, style claims, stale gotchas). See [`rules/drift-detection.md`](./rules/drift-detection.md).1404. **Holistic analysis** (if `holistic` was passed) — see141 [`rules/drift-detection.md`](./rules/drift-detection.md) §4.1425. **Generate updates.** Each proposed change is classified by content143 kind, routed via [`content-routing.md`](./rules/content-routing.md), and144 placed via [`placement-resolver.md`](./rules/placement-resolver.md).145 Priority tiers: P0 stale fixes apply immediately; P1 new patterns ask146 for confirmation; P2 polish skips unless requested.1476. **Apply (or dry-run report).**1487. **Summarize.** Per-file table of changes plus a list of areas149 intentionally skipped because Claude can infer them.150151### Sub-modes inside `update`152153- `update nested <dir>` — see [`rules/placement-resolver.md`](./rules/placement-resolver.md) §4.154- `update pattern <glob>` — see [`rules/placement-resolver.md`](./rules/placement-resolver.md) §5.155156---157158## Mode: `readme` — write or audit a README159160Use when the README is the asset under work.161Two sub-modes detected from context:162163- **No README exists or user says "write a README"** → scaffold mode.164- **README exists and user says "audit / review / improve"** → audit mode.165166### Scaffold sub-mode1671681. Detect tech stack and project type (library / app / monorepo root /169 CLI tool).1702. Render `templates/readme.md` with the structure from the standard-readme171 spec — see [`rules/readme.md`](./rules/readme.md) for the mandatory section172 order and the badge selection rules.1733. Apply the **above-the-fold checklist** before declaring done — the174 first viewport must carry name, one-line tagline, hero visual or175 demo, primary CTA badges, and one install line.176177### Audit sub-mode1781791. Read the README.1802. Run the README audit rubric in [`rules/readme.md`](./rules/readme.md) §4.181 Score each item PASS / WARN / FAIL with one line of evidence.1823. End with a prioritized **Top 3 fixes** list — biggest reader-time183 wins first.184185---186187## Mode: `audit` — comprehensive documentation health check188189Read-only by default.190Produces a structured report covering every doc surface.191192### Phases1931941. **Inventory.** List every documentation file across the repo.1952. **Per-surface audits**:196 - `CLAUDE.md` and `.claude/rules/` — see [`rules/claude-md.md`](./rules/claude-md.md) §5.197 - `README.md` and any per-package READMEs — see [`rules/readme.md`](./rules/readme.md) §4.198 - `docs/` tree — see [`rules/docs-folder.md`](./rules/docs-folder.md) §3.1993. **Drift checks** — full set from [`rules/drift-detection.md`](./rules/drift-detection.md) §3 (dead paths, removed commands, broken `@imports`, hot-path leakage).2004. **CI lint coverage** — see [`rules/maintenance.md`](./rules/maintenance.md) for the recommended `markdownlint` / Vale / alex / lychee stack.2015. **Prioritized report.** P0 (stale / wrong) → P1 (missing high-value content) → P2 (polish).202203If the user asks to apply fixes, route to `update` mode with the audit findings as the input.204205---206207## Definition of Done208209Each mode has a closing gate. Treat any unchecked item as a defect.210211### `init`212213- [ ] Tier picked and the per-tier files matrix matches the output.214- [ ] `CLAUDE.md` ≤ 200 lines.215- [ ] `README.md` first viewport (~600 px) carries name, tagline, hero,216 primary badges, install line.217- [ ] `docs/` tree (medium / large only) has `README.md`, `architecture.md`,218 `contributing.md`, and (large only) per-package nested folders.219- [ ] `.gitignore` contains `.claude/settings.local.json`.220- [ ] No content is duplicated across `CLAUDE.md`, `README.md`, and `docs/`.221222### `update`223224- [ ] Every P0 drift item from `drift-detection.md` §3 either fixed or225 explicitly skipped with reason.226- [ ] Every new rule placed via `placement-resolver.md` — no pattern-scoped227 rule landed in root `CLAUDE.md`.228- [ ] Every `@import` added resolves to a real file.229- [ ] No content moved into `docs/` while a duplicate remains in230 `CLAUDE.md` (or vice versa).231- [ ] Summary table delivered.232233### `readme`234235- [ ] All mandatory standard-readme sections present in correct order.236- [ ] Above-the-fold checklist passes.237- [ ] Badge count between 0 and 10, and every badge represents signal238 (build / version / license / coverage / security / contributors),239 not noise (stars / forks / "made with love").240- [ ] Every relative link resolves.241242### `audit`243244- [ ] Every file in the inventory has a row in the report (PASS / WARN /245 FAIL or N/A).246- [ ] Top 3 fixes list at the end, ordered by reader-time impact.247- [ ] No file mutations — `audit` is read-only.248249---250251## Core Principles2522531. **Right surface, right cost.** `CLAUDE.md` is auto-loaded — every254 line is a recurring token cost. `README.md` is read once by humans255 evaluating the project. `docs/` is loaded on demand. Route by these256 costs, not by what feels natural to write.2572. **Innermost-wins.** Nested `CLAUDE.md` files load only when the agent258 is in that subtree. A rule about `packages/foo/**` placed in259 `packages/foo/CLAUDE.md` costs zero tokens for someone in260 `packages/bar/`. The same rule in root costs everyone, every turn.2613. **Be prescriptive, not descriptive.** Tell the agent what to do; do262 not explain concepts. Decision tables and numbered lists beat prose.2634. **Each document serves exactly one Diátaxis quadrant.** Tutorial *or*264 how-to *or* reference *or* explanation. If a doc serves two, split it.2655. **Never duplicate facts across surfaces.** Pick one owner; link from266 the others. Duplicates always drift.2676. **Test the docs by removal.** "Would removing this cause Claude or a268 reader to make a mistake?" If no, delete it.269270---271272## Anti-patterns (one-liner — full list in `rules/` per surface)273274- `CLAUDE.md` over 200 lines (Anthropic's own threshold — adherence drops).275- Pattern-scoped rule placed in root `CLAUDE.md` instead of `.claude/rules/`276 with `paths:`.277- README wall-of-badges (>10 badges); TOC for a 60-line README.278- `docs/` files unreferenced from anywhere (orphans).279- Same fact written in `CLAUDE.md` *and* `docs/` — one will drift.280- Narrative paragraphs ("we picked X because Y, the system grew as Z…") in281 `CLAUDE.md` instead of `docs/`.282- Marketing prose ("blazingly fast," "simply," "easily") with no benchmark.283- README API reference dump — move to `docs/`.284- Backslash paths anywhere.285- Time-sensitive claims ("after August 2025…") in any surface.286287---288289## Cross-tool note: AGENTS.md290291[`agents.md`](https://agents.md/) is the cross-tool open spec read by292Codex CLI, Cursor, Aider, Devin, GitHub Copilot, Gemini CLI, and others.293Claude Code reads `CLAUDE.md`, not `AGENTS.md` directly.294295Two interop options:296297- **Symlink** — `ln -s CLAUDE.md AGENTS.md` (simplest; one source of truth).298- **`@import`** — keep both files but have `CLAUDE.md` start with `@AGENTS.md` and put shared content in `AGENTS.md`.299300For mixed-tool teams, prefer the symlink.301For Claude-Code-first teams with cross-tool readers as secondary, prefer the `@import`.302See [`rules/claude-md.md`](./rules/claude-md.md) §6 for the trade-offs.