file-text Documentation Audit
Audit and maintain documentation coverage across any codebase using the three-layer system (README.md for humans, AGENTS.md for AI agents, CLAUDE.md as pointer). Finds gaps, stale references, and JSDoc coverage issues. Can generate missing docs. Use when adding features, before shipping, or periodically to maintain coverage.
Install this skill
git submodule add https://github.com/modh-labs/playbook.git .playbookOne submodule installs all 17 skills. Reference .playbook/skills/doc-audit/SKILL.md from your AGENTS.md.
Documentation Audit Skill
When This Skill Activates
- Auditing documentation coverage across a codebase
- Generating missing documentation for undocumented directories
- Checking if existing docs reference files that no longer exist
- Periodic maintenance to keep documentation accurate
- Before shipping a feature to ensure docs are complete
Invocation Modes
/doc-audit— Full codebase audit (coverage report)/doc-audit route [path]— Audit a specific route/doc-audit lib [path]— Audit a specific library/doc-audit fix [path]— Generate missing docs for a specific directory/doc-audit validate— Check existing docs against code for staleness
Three-Layer Documentation System
Every meaningful directory in a codebase should have up to three documentation files:
| File | Audience | Content |
|---|---|---|
| README.md | Humans (engineers) | JTBD, features, quick start, architecture |
| AGENTS.md | AI agents (all tools) | Standards, conventions, file structure, imports, pitfalls |
| CLAUDE.md | Claude Code | Always exactly @AGENTS.md (import directive) |
Why Three Files?
- README.md answers "what does this do and how do I get started?"
- AGENTS.md answers "what are the rules and patterns I must follow here?"
- CLAUDE.md is Claude Code's native import syntax — it tells Claude to read AGENTS.md
- Every other AI tool (Cursor, Codex, Devin, Gemini CLI) reads AGENTS.md natively
One source of truth (AGENTS.md) with universal coverage across 20+ AI tools.
Directory Classification
Not every directory needs documentation. Classify first:
| Type | Rule | Documentation |
|---|---|---|
| Route | Has page.tsx or route handler | README.md + AGENTS.md + CLAUDE.md |
| Package | Top-level under packages/ or similar | README.md + AGENTS.md + CLAUDE.md |
| App | Top-level application directory | README.md + AGENTS.md + CLAUDE.md |
| Shared lib | 3+ files, non-obvious patterns | AGENTS.md + CLAUDE.md (README.md optional) |
| Trivial | fonts/, data/, __tests__/, 1-2 obvious files | SKIP |
Audit Algorithm
Step 1: Discovery
Walk all directories and classify each using the rules above.
Step 2: Coverage Check
For each non-trivial directory, check:
-
AGENTS.mdexists and is non-empty -
CLAUDE.mdexists and contains exactly@AGENTS.md -
README.mdexists (required for routes + packages, optional for libs) - Route-specific:
error.tsxexists - Route-specific:
loading.tsxexists
Step 3: Staleness Detection
For each existing AGENTS.md:
- Parse "Key Files" section (the tree structure)
- Compare listed files against actual directory contents
- Flag phantom references — files in docs but not on disk
- Flag undocumented files — files on disk but not in docs
- Check that linked reference docs still exist
Step 4: JSDoc Coverage (Optional)
For critical-path files, check exported functions for JSDoc:
Tier 1 (always JSDoc): Repositories, server actions, services, webhook handlers, workflow files Tier 2 (non-obvious only): Shared utilities where function name alone is insufficient Tier 3 (skip): React components, simple CRUD, constants, tests
Step 5: Report
Output a structured coverage report:
=== Documentation Coverage Report ===
Overall: [X]% covered ([N]/[M] directories)
CRITICAL GAPS (directories with no AGENTS.md):
✗ [path] — no AGENTS.md, no README.md
STALE DOCS (AGENTS.md references non-existent files):
⚠ [path]/AGENTS.md — references [file] (deleted)
MISSING CLAUDE.md:
⚠ [path] — has AGENTS.md but no CLAUDE.md
JSDOC GAPS:
✗ [path] — [N]/[M] exports missing JSDoc
COVERAGE BY AREA:
Routes: [X]/[Y] ([Z]%)
Libraries: [X]/[Y] ([Z]%)
Packages: [X]/[Y] ([Z]%)
Templates
Route AGENTS.md
# [Route Name] Feature Guide
## Purpose
[One-line description]
## Key Components
| Component | Purpose |
|-----------|---------|
| `ComponentName` | [what it does] |
## Data Flow
1. [Step 1]
2. [Step 2]
## Repositories Used
- `repository.ts` — [purpose]
## Common Tasks
### [Typical modification]
1. [Step]
## Key Files
[actual tree structure from ls]
## Related
- [Links to workflow/pattern docs]
Library AGENTS.md
# [Library Name]
## Purpose
[One sentence]
## Exports
| Export | Purpose |
|--------|---------|
| `functionName()` | [what it does] |
## Usage
[code example]
## Rules
- Always [do X]
- Never [do Y]
## Related
- [Link to canonical doc]
Package README.md
# @scope/[package-name]
[One paragraph: what this package provides]
## Installation
[How to install/import]
## API
[Public exports with brief descriptions]
## Development
[Build, test, generate commands]
Fix Mode
When invoked with fix [path]:
- Read all source files in the directory
- Classify the directory type (route, lib, package)
- Generate README.md using the appropriate template
- Generate AGENTS.md using the appropriate template, populated from source code
- Create CLAUDE.md with
@AGENTS.md
Rules for Generation
- MUST populate "Key Files" with actual directory contents
- MUST populate component/export tables with actual names from source
- MUST link to canonical docs rather than duplicating content
- MUST NOT add docs to trivial directories
- MUST NOT auto-delete stale docs — flag and require human confirmation
Core Principles
Link, Never Duplicate
Route-level docs LINK to canonical references — they never re-explain system logic.
## Related Workflows
- [Call Lifecycle](../docs/workflows/call-lifecycle.md)
NOT:
## How Calls Work
[200 lines duplicating the workflow doc]
Single Source of Truth
Each piece of knowledge lives in ONE place. Other docs link to it.
JSDoc Complements, Not Replaces
JSDoc on functions answers "what does this function do?" — not "how does the whole system work?" For system-level understanding, link to higher-level docs.
JSDoc Convention
Tags for Workflow Functions
/**
* [One-line description]
*
* @workflow docs/workflows/[workflow].md
* @lifecycle-stage [kebab-case-stage]
* @param paramName - [description]
* @returns [description]
*/
Don't JSDoc the Obvious
// BAD
/** Creates a lead. */
export async function createLead(data: CreateLeadInput) { ... }
// GOOD — name is self-documenting
export async function createLead(data: CreateLeadInput) { ... }
Validate Mode
When invoked with validate:
- Find all AGENTS.md files in the codebase
- For each, run staleness detection
- Find all CLAUDE.md files, verify each contains
@AGENTS.md - Check that documentation indexes match actual files
- Output a staleness report with specific files and line numbers
Related Skills
Background Job Right Sizing
Choose the LIGHTEST durable mechanism a background/async/side-effect job actually needs, instead of reaching for a full workflow engine by reflex. A four-rung ladder — in-process fire-and-forget → durable queue → workflow engine → dedicated orchestrator — routed by four axes: durability, step count, concurrency shape, and cross-app/bus membership. Activates when adding any background job, emitting a side-effect from a request handler, choosing between Vercel Queues / Workflows / Inngest / Temporal / SQS, or auditing an existing job fleet for over-engineering ("do we still need the orchestrator for this?").
Workflow / ProcessworkflowBug Cleanup Triage
Framework for backlog bug cleanup sessions. Triage is three sequential activities — Linear hygiene, root-cause investigation, and code fixing — that must be executed in order as a hard phase gate. Includes git log pre-flight, Sentry module-tag verification, and umbrella breakdown auto-detection. Use when planning to clean up N bugs from a backlog, before dispatching research agents, or when a ticket has been In Progress for weeks without shipping.
Workflow / ProcessworkflowCI Pipeline Standards
Enforce CI pipeline conventions. Use when adding CI checks, modifying GitHub Actions workflows, or discussing CI vs deployment. Prevents deployment steps in CI and ensures the extensible step pattern is followed.
Workflow / Process