Documentation / Context / Memory Audit
A periodic, sign-off-gated pass that keeps a project's docs, agent-context files,
persistent memory, and showcase docs accurate and token-efficient. Use
extended thinking — this is an analysis task before it's an editing task.
Operating principles (the "why")
- Optimize the hot path first. The most expensive tokens are in files the
agent loads every turn (
CLAUDE.md/AGENTS.md, the memory index) or every
resume (a status/handoff file). Slimming those beats slimming an on-demand
reference doc. Triage every file by load frequency: always-loaded → on-resume
→ on-demand → archival.
- Spend audit tokens the same way. Read hot-path files fully; spot-check
on-demand files against their drift-prone claims; review archives at index
level only. Reuse the project's own doc map instead of re-deriving the
landscape. Verify with the cheapest sufficient probe — grep for the symbol
instead of reading the file; query the registry instead of a changelog.
- Accuracy beats completeness. A doc that contradicts the code actively
misleads the agent. Never trust a doc's claim about code; verify it against
source.
- Preserve, don't destroy. Cull verbose detail by moving it to an
archive/history file and recording in the archive's index what was preserved
where. The hot-path file keeps a compact one-line-per-item record.
- One source of truth. If two files state the same fact, the hot-path file
defers (links) to the authoritative one instead of duplicating it.
- Respect the project's cadence. Follow documented working agreements
(plan → sign-off → build). Default: present findings + plan, get sign-off,
then execute. If the invoking request pre-authorized the full pass (or the
session is non-interactive), proceed — and record in the final report the
decisions a sign-off would have covered.
- Measure. Quantify the savings (chars before → after; tokens ≈ chars/4)
so the win is concrete.
Process
1 — Discover & read
- Map the landscape:
README, CLAUDE.md/AGENTS.md (including leaf
copies in subdirectories — glob for them), everything under docs/**, any
status / handoff / backlog / changelog / decision-log files, and the agent
memory directory + its index.
- Hunt for local-only docs. Check
.gitignore and .git/info/exclude for
doc-shaped exclusions and check the project's memory for designated doc sets
— these never appear in git status, so they rot fastest.
- Classify each file by load frequency (always / on-resume / on-demand /
archival) and audience (agent-facing / outward-facing / showcase), then
read at tiered depth — don't skim the hot path; you can't spot duplication
or drift you haven't read.
2 — Analyze (change nothing yet)
Run the seven hunts — full mechanics, examples, and the
standing-instruction placement sub-rules live in
references/hunts.md; read it before the pass:
- Code↔doc drift — spot-check the rot-prone claims against source.
- Duplication / bloat — the same fact in multiple files; regrown
append-logs; backlogs re-describing shipped work.
- Archivable content — completed plans, superseded audits, history.
- Backlog gaps — untracked TODOs, known-but-unfiled issues.
- Currency & status drift — claims that rot with zero repo changes;
quickstart commands, badges, links, external gates.
- Showcase-doc lag — stamp-vs-git-log diff; numeric/superlative claims.
- Standing-instruction budget & placement — measure the always-loaded
set against the adapter's
contextBudget (defaults in hunts.md) and apply
the placement rules (prime directive · thin pointers · cache stability ·
leaf files · load-when precision).
Litmus tests: "Would an agent that loaded only this file be misled?" →
drift, or it needs a pointer. "Is this fact derivable from the code, git
history, or the onboarding doc?" → don't repeat it. "If two files disagree,
which is authoritative?" → that one stays; the other defers.
3 — Plan + sign-off
Present findings grouped (drift / bloat / archive / backlog / showcase), each
with a concrete fix and a recommendation. Ask about the genuine decisions
only (how aggressively to slim, archive vs delete for borderline content).
Wait for sign-off unless pre-authorized — then take the recommended option and
say so in the report.
4 — Execute
Fix drift first → slim hot-path files (move verbose detail verbatim to the
archive; refresh index/map files) → enforce budget & placement fixes → add the
agreed backlog items → refresh showcase docs in-register and stamp the set →
repair memory (collapse per-step changelogs into pointers; keep only durable
non-derivable facts; fix cross-links). Per-fix patterns are in hunts.md.
5 — Verify
- Internal links/anchors resolve;
git status scope is exactly what you
intended (local-only files never show there — re-list them directly).
- Report measured savings (before → after) and the showcase claims updated.
- Anything code-adjacent changed → run the project's gate. Markdown is usually
outside it — the link/scope/measurement checks are the real verification.
- Commit/push only when asked. Local-only showcase docs are saved, never
committed.
Notes & gotchas
- Budgets come from the adapter —
.claude/ai-dev-kit.config.json →
contextBudget overrides the defaults in hunts.md; where absent, use the
defaults and say so.
- Agent memory lives outside the repo (typically
~/.claude/projects/<project-slug>/memory/ with a MEMORY.md index). It is
not in git — edit it directly; the index is loaded every session, so its
lines and each file's description must stay accurate.
- The biggest recurring win is a status/handoff or memory file that has
quietly regrown a verbose per-step log — keep a compact record, move prose
to the archive, restate the "no append-log" rule where it'll be seen.
- Dual-home rule: this skill's canonical source is the ai-dev-kit repo's
skills/doc-audit/; the project copy (.claude/skills/doc-audit/) and the
global copy (~/.claude/skills/doc-audit/) are both installer output — edit
kit source in a clone and re-run its installer per the kit README (installed
versions: .claude/ai-dev-kit.installed.json), never edit the installed
copies (install.mjs --check guards drift). Project-specific designations —
which files form the showcase set, where they live — belong in that
project's memory, not in this file.
- Never name a project's local-only docs inside committed files (including
the in-repo copy of this skill) — the exclusion exists to keep them out of a
public repo; the project's memory carries the pointer.
1---2name: doc-audit3description: Audit and optimize a project's documentation, agent-context files, persistent memory, and showcase docs for accuracy and token efficiency — code↔doc drift, duplication, archiving, memory slimming, showcase currency, standing-instruction budgets. Use when asked to review/clean up docs, context, or memory — or as a periodic maintenance pass to keep them lean and accurate.4---56# Documentation / Context / Memory Audit78A periodic, sign-off-gated pass that keeps a project's docs, agent-context files,9persistent memory, and showcase docs **accurate** and **token-efficient**. Use10extended thinking — this is an analysis task before it's an editing task.1112## Operating principles (the "why")1314- **Optimize the hot path first.** The most expensive tokens are in files the15 agent loads *every turn* (`CLAUDE.md`/`AGENTS.md`, the memory index) or *every16 resume* (a status/handoff file). Slimming those beats slimming an on-demand17 reference doc. Triage every file by load frequency: always-loaded → on-resume18 → on-demand → archival.19- **Spend audit tokens the same way.** Read hot-path files fully; spot-check20 on-demand files against their drift-prone claims; review archives at index21 level only. Reuse the project's own doc map instead of re-deriving the22 landscape. Verify with the cheapest sufficient probe — grep for the symbol23 instead of reading the file; query the registry instead of a changelog.24- **Accuracy beats completeness.** A doc that contradicts the code actively25 misleads the agent. Never trust a doc's claim about code; verify it against26 source.27- **Preserve, don't destroy.** Cull verbose detail by *moving* it to an28 archive/history file and recording in the archive's index what was preserved29 where. The hot-path file keeps a compact one-line-per-item record.30- **One source of truth.** If two files state the same fact, the hot-path file31 *defers* (links) to the authoritative one instead of duplicating it.32- **Respect the project's cadence.** Follow documented working agreements33 (plan → sign-off → build). Default: present findings + plan, get sign-off,34 then execute. If the invoking request pre-authorized the full pass (or the35 session is non-interactive), proceed — and record in the final report the36 decisions a sign-off would have covered.37- **Measure.** Quantify the savings (chars before → after; tokens ≈ chars/4)38 so the win is concrete.3940## Process4142### 1 — Discover & read4344- Map the landscape: `README`, `CLAUDE.md`/`AGENTS.md` (including **leaf**45 copies in subdirectories — glob for them), everything under `docs/**`, any46 status / handoff / backlog / changelog / decision-log files, and the agent47 **memory** directory + its index.48- **Hunt for local-only docs.** Check `.gitignore` and `.git/info/exclude` for49 doc-shaped exclusions and check the project's memory for designated doc sets50 — these never appear in `git status`, so they rot fastest.51- Classify each file by **load frequency** (always / on-resume / on-demand /52 archival) and **audience** (agent-facing / outward-facing / showcase), then53 read at tiered depth — don't skim the hot path; you can't spot duplication54 or drift you haven't read.5556### 2 — Analyze (change nothing yet)5758Run the **seven hunts** — full mechanics, examples, and the59standing-instruction placement sub-rules live in60[references/hunts.md](references/hunts.md); read it before the pass:61621. **Code↔doc drift** — spot-check the rot-prone claims against source.632. **Duplication / bloat** — the same fact in multiple files; regrown64 append-logs; backlogs re-describing shipped work.653. **Archivable content** — completed plans, superseded audits, history.664. **Backlog gaps** — untracked TODOs, known-but-unfiled issues.675. **Currency & status drift** — claims that rot with zero repo changes;68 quickstart commands, badges, links, external gates.696. **Showcase-doc lag** — stamp-vs-git-log diff; numeric/superlative claims.707. **Standing-instruction budget & placement** — measure the always-loaded71 set against the adapter's `contextBudget` (defaults in hunts.md) and apply72 the placement rules (prime directive · thin pointers · cache stability ·73 leaf files · load-when precision).7475Litmus tests: *"Would an agent that loaded only this file be misled?"* →76drift, or it needs a pointer. *"Is this fact derivable from the code, git77history, or the onboarding doc?"* → don't repeat it. *"If two files disagree,78which is authoritative?"* → that one stays; the other defers.7980### 3 — Plan + sign-off8182Present findings grouped (drift / bloat / archive / backlog / showcase), each83with a **concrete fix** and a recommendation. Ask about the genuine decisions84only (how aggressively to slim, archive vs delete for borderline content).85Wait for sign-off unless pre-authorized — then take the recommended option and86say so in the report.8788### 4 — Execute8990Fix drift first → slim hot-path files (move verbose detail **verbatim** to the91archive; refresh index/map files) → enforce budget & placement fixes → add the92agreed backlog items → refresh showcase docs in-register and stamp the set →93repair memory (collapse per-step changelogs into pointers; keep only durable94non-derivable facts; fix cross-links). Per-fix patterns are in hunts.md.9596### 5 — Verify9798- Internal links/anchors resolve; `git status` scope is exactly what you99 intended (local-only files never show there — re-list them directly).100- Report measured savings (before → after) and the showcase claims updated.101- Anything code-adjacent changed → run the project's gate. Markdown is usually102 outside it — the link/scope/measurement checks are the real verification.103- **Commit/push only when asked.** Local-only showcase docs are saved, never104 committed.105106## Notes & gotchas107108- **Budgets come from the adapter** — `.claude/ai-dev-kit.config.json` →109 `contextBudget` overrides the defaults in hunts.md; where absent, use the110 defaults and say so.111- **Agent memory lives outside the repo** (typically112 `~/.claude/projects/<project-slug>/memory/` with a `MEMORY.md` index). It is113 not in git — edit it directly; the index is loaded every session, so its114 lines and each file's `description` must stay accurate.115- **The biggest recurring win** is a status/handoff or memory file that has116 quietly regrown a verbose per-step log — keep a compact record, move prose117 to the archive, restate the "no append-log" rule where it'll be seen.118- **Dual-home rule:** this skill's canonical source is the ai-dev-kit repo's119 `skills/doc-audit/`; the project copy (`.claude/skills/doc-audit/`) and the120 global copy (`~/.claude/skills/doc-audit/`) are both installer output — edit121 kit source in a clone and re-run its installer per the kit README (installed122 versions: `.claude/ai-dev-kit.installed.json`), never edit the installed123 copies (`install.mjs --check` guards drift). Project-specific designations —124 *which* files form the showcase set, where they live — belong in that125 project's memory, not in this file.126- **Never name a project's local-only docs inside committed files** (including127 the in-repo copy of this skill) — the exclusion exists to keep them out of a128 public repo; the project's memory carries the pointer.