name: create-docs
Analyze the entire codebase and create structured documentation as follows.
This skill needs only one of two params:
new - create new AGENTS.md and specs/ from scratch; if false, update existing files in place.
review - read and follow directions in specs-reviewer.md to review and update the generated docs.
Terminate if the user does not provide one of these two params.
AGENTS.md and/or specs/ already exist. If they do, UPDATE them in place: preserve content that is still accurate, add missing sections, remove stale references to deleted files. Do NOT recreate from scratch unless the user explicitly asks for a full regeneration.AGENTS.md in the project rootMain file containing:
specs/"@specs/filename.md and brief description of what each containsAGENTS.md must be short and scannable — for every line ask: "if I remove this, would the agent make mistakes?" — if no, cut it.
specs/ in the root — separate files per concernEvery file in specs/ (including subfolders) must have as its first line:
Read this when...
Create ONLY the files that are needed among these:
file-structure.md — map of main directories and files with description of eachcommands.md — dev, build, test, deploy, lint commands (extended version vs AGENTS.md)conventions-backend.md — patterns, conventions, backend code rulesconventions-frontend.md — patterns, conventions, frontend code rulesconventions-database.md — schema, ORM, migrations, seedsapi-routes.md — interface table. For HTTP APIs: method, path, handler, description, auth. For IPC/CLI/event systems: command name, args, return type, description. Adapt the columns to the actual interface type — do not force HTTP columns onto non-HTTP projects.module-index.md — table of all modules with a tier column (see tier definition below)module-index.md — module priority mapA single table listing every module/subsystem with columns:
| Module | Path | Tier | Summary | Spec link |
Tier definition — classify each module by how heavily customized vs standard it is:
When uncertain, default to Tier 2. The tier tells the agent where to invest analysis effort and where changes are safe. Tier 1 requires full context loading; Tier 3-5 can be touched with minimal overhead.
If a docs file becomes long, split it into multiple .md files in a dedicated subfolder.
Example: specs/api/auth.md, specs/api/users.md
specs/<domain>/spec.md — per-domain business rules and data modelA domain is a subsystem that has its own data model AND non-obvious business rules — not a utility module, not a thin wrapper. Examples of domains: "collections" (tree model + sort_order + auth inheritance), "http-client" (SSRF + truncation + cancellation), "auth" (tagged union + tree-walk resolution). Examples of NON-domains: "utils" (collection of helpers), "types" (type definitions only), "theme" (configuration).
For every Tier 1 domain, create a dedicated specs/<domain>/spec.md containing:
rules/) — they are the contracts the code must respect regardless of implementation. Example: "sort_order assigned as MAX(sort_order)+1 within parent scope", "history auto-pruned to 100 newest on every insert", "folders never inherit auth (migration normalizes legacy inherit to none)"api-routes.md section or rules/ fileCreate a spec.md ONLY for domains whose business rules are non-obvious from reading the code. If a module is thin or standard, skip it — the module-index.md summary is enough.
specs/integrations/ — external system boundariesFor every integration with an external system (HTTP, DB, IPC, filesystem, third-party import/export, message queue, etc.), create one file in specs/integrations/:
index.md — table listing all integrations: name, direction (IN/OUT/BIDIRECTIONAL), protocol, implementing files, doc linkBoundary | Mechanism | Location. Examples: SSRF guard (scheme allowlist), input validation (non-empty / format check), output truncation (size cap with safe boundary), error redaction (strip sensitive data from error messages). This is the most important section — it tells the agent what NOT to relax and WHERE the guard lives.Create this folder ONLY if the project has at least one integration with a trust boundary (security, data integrity, or memory safety). If the project is pure-internal with no external I/O, skip it.
specs/rules/ — patterns and snippetsRecurring programming patterns and code snippets go as rule files in specs/rules/.
Examples: error-handling.md, api-client.md, form-validation.md, add-ipc-command.md
Each rules file describes the pattern with a minimal code example to follow. A rule file answers "how do I add/change X?" with numbered steps and inline code snippets — it is a recipe, not a description.
conventions-*.md → HOW to write code (style, naming, patterns)rules/*.md → HOW to add/change a feature (recipe with steps + snippet)<domain>/spec.md → WHAT the code must guarantee (business contracts, data model, invariants)integrations/*.md → WHERE the trust boundaries are (security, integrity, safety)module-index.md → WHICH modules exist and how critical they are (tier)conventions-backend.md, do not repeat it in spec.md — cross-link instead. If a business rule is already in spec.md, do not repeat it in rules/ — link to the spec.