git:20260812.5821e91 to git:20260813.a99b100

55 added, 62 removed. Audit A to A.

---
name: documentation-audit
- description: Use when documentation drift is detected, or when writing new documentation from scratch — syncs Swagger, feature docs, and general docs to the code, or drafts them when none exist. Triggers on "docs out of date", "documentation drift", "sync docs", "写文档", "写 README", "文档化这个功能", "文档同步".
+ description: Use when documentation drifts from code — syncs PRD/TECH/API/FLOW/TODO to the codebase and produces an audit report. Triggers on "docs out of date", "documentation drift", "sync docs", "文档同步", "写文档", "写 README", "文档化这个功能", "文档审计".
---
# Documentation Audit
- Comprehensive documentation sync when drift is detected. Analyzes the codebase and creates or updates all documentation artifacts to achieve full synchronization. Documentation must reflect reality — this skill brings it into alignment.
+ Sync the five formal docs (PRD/TECH/API/FLOW/TODO) to the code, then produce an audit report. Documentation must reflect reality — this skill brings drifted docs back into alignment and records what changed.
## When to use
- - API documentation drift detected (endpoints in code missing from OpenAPI/Swagger).
- - Features documentation drift detected (shipped features missing from features docs).
- - Documentation files are missing, stale, or contradict the current code.
- - Manual request to synchronize all documentation with the codebase.
- - Writing new documentation from scratch — README, feature docs, API docs (see `references/writing-docs.md`).
+ - A formal doc (PRD/TECH/API/FLOW/TODO) contradicts the current code
+ - Documentation is stale or out of sync after a feature ship
+ - Manual request to synchronize all documentation with the codebase
+ - Writing new documentation from scratch (see `references/writing-docs.md`)
- **Not for:** open source GitHub presence polishing (use `oss-polish`); designing API contracts (use `api-design`).
+ **Not for:** open source GitHub presence polishing (use `oss-polish`); designing API contracts (use `api-design`); writing the PRD/TECH themselves (use `spec`/`architecture`).
## Steps
- ### 1. Discovery — find all documentation and code artifacts
+ ### 1. Discovery — locate the five formal docs and code structure
- Locate every documentation file and identify the API framework so later phases know where to look.
+ Find every formal doc and map the codebase layout so later steps know where to look.
```bash
- # Find documentation files
- find . \( -name "*.md" -o -name "*.yaml" -o -name "*.json" \) \
- | grep -Ei "(doc|api|swagger|openapi|feature|guide|readme)" \
- | grep -v node_modules | grep -v .git
-
- # Locate API spec and features doc
- find . \( -name "openapi.yaml" -o -name "swagger.yaml" -o -name "openapi.json" \) | head -1
- find . \( -name "features.md" -o -name "FEATURES.md" \) | head -1
+ # Locate the five formal docs (project-level)
+ ls docs/PRD.md docs/TECH.md docs/TODO.md docs/API/*.md docs/FLOW/*.md 2>/dev/null
+ # Version-level variants (if multi-version project)
+ ls docs/v*/*.md 2>/dev/null
+ # Detect API framework for the API drift step
+ grep -Ei "express|fastify|@nestjs|fastapi|flask|django|gin|echo" package.json requirements.txt go.mod 2>/dev/null
```
- Detect the API framework by grepping `package.json` / `requirements.txt` / `go.mod` for `express`, `fastify`, `@nestjs`, `fastapi`, `flask`, or a Go module. The framework determines the endpoint extraction pattern.
+ Record which docs exist and which are missing. Missing docs are gaps to flag — not to create here (creation belongs to `spec`/`architecture`/`api-design`).
- ### 2. API audit — extract endpoints from code
+ ### 2. PRD & TECH drift — implementation vs spec
- Pull every route declaration from the codebase so they can be matched against the OpenAPI spec.
+ Read the code's actual behavior and compare against PRD/TECH:
- - **express / fastify:** `grep -rh "app\.\(get\|post\|put\|delete\|patch\)" --include="*.ts" --include="*.js"`
- - **nestjs:** `grep -rh "@\(Get\|Post\|Put\|Delete\|Patch\)" --include="*.ts"`
- - **fastapi / flask:** `grep -rh "@app\.\(get\|post\|put\|delete\|patch\)" --include="*.py"`
+ - **Features in code but not in PRD** — shipped without spec; flag for `spec`.
+ - **Features in PRD but not in code** — spec aspirational or feature removed; update PRD to match reality.
+ - **Components in TECH but not in code** — planned but not implemented; update TECH.
+ - **Components in code but not in TECH** — undocumented; add to TECH.
- Compare extracted endpoints against `openapi.yaml` paths. Every endpoint in code with no matching path entry is a drift gap to fix.
+ ### 3. API drift — endpoints vs docs/API/*.md
- ### 3. Features audit — extract user-facing features
+ Extract every route declaration from code and match against `docs/API/`:
- Discover features shipped in the UI so they can be documented.
+ - **express / fastify:** `grep -rh "app\.\(get\|post\|put\|delete\|patch\)" --include="*.ts" --include="*.js"`
+ - **nestjs:** `grep -rh "@\(Get\|Post\|Put\|Delete\|Patch\)" --include="*.ts"`
+ - **fastapi / flask:** `grep -rh "@app\.\(get\|post\|put\|delete\|patch\)" --include="*.py"`
- - React components in `pages/` or `views/` (`find . -path "*/pages/*" -name "*.tsx" -o -path "*/views/*" -name "*.tsx"`).
- - Feature flags (`grep -rh "featureFlag\|feature:" --include="*.ts" --include="*.tsx"`).
- - User-facing config options (`grep -rh "config\.\|settings\." --include="*.ts"`, excluding imports).
+ Every endpoint in code with no matching `docs/API/` entry is a drift gap. For each gap, add to the API doc: method, path, parameters, request/response shape, errors. If no `docs/API/` exists yet, flag for `api-design`.
- Compare discovered features against `features.md`. Every shipped feature with no entry is a drift gap.
+ ### 4. FLOW drift — data flow vs docs/FLOW/*.md
- ### 4. Generate missing documentation
+ For each business flow, trace the code path and compare against `docs/FLOW/`:
- For each gap found in phases 2–3, create or extend the relevant artifact. Templates for a new OpenAPI file (skeleton with `info`, `servers`, `paths`, `components.schemas`, `securitySchemes`) and a new features doc (overview, core features with description/how-to-use, additional features) are in `references/templates.md`. Use them as starting scaffolds, then fill in real content from the code.
+ - Function call chains in code but not in the FLOW doc — add them.
+ - FLOW doc references functions that no longer exist — update or remove.
+ - New flows with no FLOW doc — flag for creation (use the workflow-prompts FLOW prompt).
- ### 5. Update existing documentation
+ ### 5. TODO drift — code TODOs vs docs/TODO.md
- For each discovered but undocumented item, add it to the existing doc:
+ ```bash
+ grep -rn "TODO" --include="*.ts" --include="*.js" --include="*.py" --include="*.go" src/ | grep -v node_modules
+ ```
- 1. **API endpoints** — add to OpenAPI spec: path and method, parameters (from function signature), request body schema (from DTO/type), response schema (from return type), basic description.
- 2. **Features** — add to features doc: feature name, basic description, placeholder for how-to-use, note to review and enhance.
+ - TODOs in code but not in `docs/TODO.md` — add them (merged by business area).
+ - TODOs in `docs/TODO.md` already resolved in code — remove from TODO.md and delete the code TODO comment.
- ### 6. Validation
+ ### 6. Sync — fix every drift
- Validate every artifact the audit touched before reporting done.
+ For each gap found in steps 2–5, update the doc to match the code (or flag for the owning skill if creation is needed). Docs reflect reality; reality is not edited to match docs.
- ```bash
- # Validate OpenAPI is parseable YAML/JSON
- yq '.' openapi.yaml > /dev/null 2>&1 && echo "OpenAPI: Valid YAML" || echo "OpenAPI: Invalid YAML"
+ ### 7. Produce the audit report
- # Check markdown docs have section headers
- for file in docs/*.md; do [ -f "$file" ] && grep -q "^## " "$file" || echo "WARNING: $file missing section headers"; done
+ Write `docs/audit/YYYY-MM-DD-documentation.md` using the template in `references/templates.md`:
- # Completeness: endpoints documented vs endpoints in code
- ENDPOINTS_DOCUMENTED=$(yq '.paths | keys | length' openapi.yaml 2>/dev/null || echo 0)
- # Use the grep matching your detected framework (see Step 2); shown for express/fastify:
- ENDPOINTS_IN_CODE=$(grep -rh "app\.\(get\|post\|put\|delete\|patch\)" --include="*.ts" --include="*.js" | wc -l)
- ```
+ - **Scope** — which docs were audited
+ - **Before/after** — drift counts per doc type
+ - **Fixed** — every sync applied
+ - **Needs manual review** — items requiring a human decision or another skill
- If `ENDPOINTS_DOCUMENTED < ENDPOINTS_IN_CODE`, some endpoints are still undocumented — loop back to phase 5.
+ **Output:** `docs/audit/YYYY-MM-DD-documentation.md` — audit report (scope, before/after, fixed, needs review). The synced docs are the primary product; the report is the trail.
## Verify
- - [ ] All documentation files discovered (markdown, YAML, JSON)
- - [ ] API framework detected; every endpoint extracted from code
- - [ ] Every user-facing feature extracted from code
- - [ ] Missing documentation files created (OpenAPI spec, features doc)
- - [ ] Existing documentation updated to cover every endpoint and feature
- - [ ] All files validated: OpenAPI parses as YAML/JSON, markdown has section headers
- - [ ] Endpoint count in code equals endpoint count documented
- - [ ] Audit report produced (before/after counts, files created/updated, items needing manual review)
-
- **Quality standards:** every endpoint/feature listed (completeness); YAML/JSON validates (validity); required sections present (structure); clear placeholders for manual review; generated-by-skill attribution noted so reviewers know to enhance descriptions.
+ - [ ] All five formal docs discovered; missing ones flagged
+ - [ ] Every endpoint in code has a `docs/API/` entry (or flagged for `api-design`)
+ - [ ] `docs/TODO.md` matches code TODO comments (both directions)
+ - [ ] PRD/TECH reflect current implementation
+ - [ ] Audit report produced at `docs/audit/YYYY-MM-DD-documentation.md` with before/after + needs-review
## References
- - [${CLAUDE_PLUGIN_ROOT}/references/engineering-principles.md](${CLAUDE_PLUGIN_ROOT}/references/engineering-principles.md) — shared discipline (verify don't assume, surgical scope, goal-driven execution)
- - [references/templates.md](references/templates.md) — OpenAPI skeleton, features-doc template, audit-report template
+ - [${CLAUDE_PLUGIN_ROOT}/references/engineering-principles.md](${CLAUDE_PLUGIN_ROOT}/references/engineering-principles.md) — shared discipline (verify don't assume, surgical scope)
+ - [references/templates.md](references/templates.md) — audit-report template
- [references/writing-docs.md](references/writing-docs.md) — writing new documentation from scratch (README, feature docs, API docs)