Generate multi-audience documentation from any codebase — workflows for non-technical readers, architecture for developers, and AI orientation for agents. Deterministic JS scripts handle structural extraction; the agent writes the prose. Project-agnostic and self-orienting. Use when the user asks to "document this project", runs `/document-this`, runs `/document-this <file-path>`, runs `/document-this --focus "<Feature Name>"` for a deep-dive on one subsystem in a named subfolder, or wants fresh documentation reflecting the current codebase state.
67
81%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Generates documentation across three audiences from one codebase:
Scripts handle everything deterministic (directory structure, entity listing, test categorization). The agent handles everything that requires interpretation (prose, pattern recognition, workflow narratives).
/document-this # Full project documentation
/document-this <file-path> # Targeted update of affected sections only
/document-this --focus "<Feature Name>" # Deep-dive docs for a feature/subsystem into a named subfolder
/document-this --focus "<Feature Name>" <file-path> # Targeted update within a focus subfolderThe feature name is what the user types (typically Title Case, often with spaces — e.g., "Materials Management", "Billing", "Stripe Webhooks"). The subfolder name is a kebab-case slug derived from that name (materials-management/, billing/, stripe-webhooks/) — never the human-readable name verbatim. The slug may also be a simpler form of the feature name when one reads more naturally (Materials Management → materials/).
generated-docs/
├── README.md # Navigation hub: project summary + links to all docs
├── workflows.md # Non-technical: user-facing workflows from system/integration tests
├── architecture.md # Developer: stack, directory map, data model, patterns & conventions
├── ai-orientation.md # AI agents: entry points, coverage map, known gaps, glossary
└── diagrams/
├── data-model.mmd # Key entities + relationships (Mermaid erDiagram)
└── architecture.mmd # High-level component/module map (Mermaid graph TD)--focus — feature/subsystem deep divegenerated-docs/
└── <slug>/ # Kebab-case slug of the feature name
├── workflows.md # Non-technical: workflows scoped to this feature
├── architecture.md # Developer: architecture scoped to this feature
└── diagrams/
├── <slug>-architecture.mmd # Same slug as the folder, kept as prefix for global uniqueness
└── <slug>-data-model.mmdExample: /document-this --focus "Materials Management" produces generated-docs/materials/ (or materials-management/ — see slug rules below) containing workflows.md, architecture.md, and diagrams/materials-architecture.mmd + diagrams/materials-data-model.mmd.
Focus mode produces only the four files above — no README.md or ai-orientation.md inside the subfolder. The top-level docs serve those roles for the whole project; the focus subfolder is a deep dive linked from them.
<slug> is a short kebab-case form of the feature name, used for both the folder and the diagram file prefixes:
Materials Management → materials-management).Materials Management → materials, Stripe Webhooks → stripe-webhooks or stripe). Use judgment.Multiple focus subfolders can coexist (generated-docs/materials/, generated-docs/billing/, etc.). Each is independent — regenerating one does not touch the others.
Regenerating any mode overwrites only the files it produces. Use git diff generated-docs/ to review.
If generated-docs/ does not exist, create it.
All scripts live under scripts/ in this skill and emit JSON on stdout. Invoke them with node from the project root:
| Script | Purpose | Key Output Fields |
|---|---|---|
fingerprint.mjs | Language, framework, DB, dep files, config files, project name | language, database, configFiles, testLayouts |
front_matter.mjs | Current date + project name | date, projectName |
directory_tree.mjs [--depth N] | Pruned directory tree honoring .gitignore | tree |
tech_stack.mjs | Parsed dependency listing per ecosystem | ecosystems |
test_inventory.mjs | Test files grouped by system / integration / unit | files, summary |
entities.mjs | Model/entity definitions across any framework | sources, schemaFiles |
entry_points.mjs | Routes, controllers, service layer directories | routes, controllers, services |
Invocation from project root:
Replace skills/document-this/ below with the path to this skill in your installation (for example, under .claude/skills/, .github/skills/, or .rolemodel-skills/skills/).
node skills/document-this/scripts/fingerprint.mjs
node skills/document-this/scripts/front_matter.mjs
node skills/document-this/scripts/directory_tree.mjs --depth 3
node skills/document-this/scripts/tech_stack.mjs
node skills/document-this/scripts/test_inventory.mjs
node skills/document-this/scripts/entities.mjs
node skills/document-this/scripts/entry_points.mjsFallback rule: if node is not available on PATH, do not error — fall back to agent-driven extraction using Read, Glob, and Grep for the same purposes. Scripts are an optimization, not a hard dependency.
Under templates/. Each is a markdown scaffold with {{PLACEHOLDER}} tokens the agent fills:
README.template.md — navigation hub linking all generated files. Supports an optional {{FOCUS_SUBFOLDERS}} block for listing any --focus deep-dive subfolders.workflows.template.md — top-level scaffold for workflows.md.workflow-entry.template.md — one per workflow in the Workflows section.architecture.template.md — the Architecture section with explicit placeholders for stack, directory map, data model, patterns, optional JS architecture, and diagrams.ai-orientation.template.md — entry points, test coverage map (well-tested / undertested split), known gaps, glossary.focus-workflows.template.md — scaffold for a feature-scoped workflows.md inside a --focus subfolder. Same workflow-entry shape as the full version, with feature-specific intro and back-links to the top-level docs.focus-architecture.template.md — scaffold for a feature-scoped architecture.md inside a --focus subfolder. Tighter than the full architecture template — no JS-architecture section unless the feature is itself a JS subsystem.Execute in this order. Each step's output informs the next. Each phase can stand alone — you don't need to complete all phases in one run.
Run the fingerprint and tree scripts to orient yourself:
node skills/document-this/scripts/fingerprint.mjs
node skills/document-this/scripts/directory_tree.mjs --depth 3From the output, derive — do not assume:
Also read the README if one was detected.
workflows.mdGoal: Document every user-facing workflow in plain English, for a non-technical reader.
Discovery mechanism: Start from system/end-to-end and integration tests, not routes or controllers. Tests are human-authored descriptions of complete user interactions.
node skills/document-this/scripts/test_inventory.mjsThen:
templates/workflow-entry.template.mdsequenceDiagram mermaid blockPersona filter: Write as if the reader is a non-technical manager or end user. Do not assume they know what "modal", "CRUD", or "API" means.
Inclusion rule: Only document a workflow if backed by at least one system or integration test. If a workflow appears in code but has no test coverage, note it in Known Gaps instead.
No-tests case: if the project has zero system and integration tests, put a prominent note at the top of workflows.md using the {{#if NO_SYSTEM_TESTS}} block in the template.
architecture.md + diagrams/Goal: Give a developer enough orientation to understand the codebase in under 5 minutes.
node skills/document-this/scripts/tech_stack.mjs
node skills/document-this/scripts/directory_tree.mjs --depth 3
node skills/document-this/scripts/entities.mjs
node skills/document-this/scripts/entry_points.mjsCover these five things — keep each concise (not exhaustive documentation, just orientation):
components/, controllers/, src/, etc.Then create the Mermaid diagram files:
diagrams/data-model.mmd — entity relationships (erDiagram syntax), derived from entities.mjs output and schema files. Include entity names and relationships only — do not add attribute rows to the tables.diagrams/architecture.mmd — high-level module/layer map (graph TD syntax), derived from entry_points.mjs and directory treeai-orientation.mdGoal: Give an agent the fastest possible path to useful context without duplicating what's in architecture.md.
Open with:
For stack, directory structure, data model, and conventions — see Architecture.
Then include exactly these four things:
entry_points.mjs output)test_inventory.mjs)README.mdWrite a brief navigation document:
workflows.md, architecture.md, ai-orientation.md, and the diagrams--focus subfolders (one bullet per subfolder, linking to its workflows.md and architecture.md). If there are none, omit the block. Detect them by ls generated-docs/*/ for any folder that contains a workflows.md.templates/README.template.md)/document-this --focus "<Feature Name>"Use when the user wants deep documentation for a single feature or subsystem — typically because the top-level workflows.md and architecture.md only give it a paragraph of treatment and the feature is complex enough to warrant its own pair of files.
The output is a self-contained subfolder under generated-docs/<slug>/ with workflows.md, architecture.md, and diagrams/<slug>-{architecture,data-model}.mmd. Do not create a README.md or ai-orientation.md inside the subfolder.
Before reading or writing anything, identify what code, tests, models, controllers, JS modules, jobs, and config files belong to this feature. The agent does this — there is no deterministic script for "is this file part of the materials feature." Use whatever combination of these signals is appropriate:
**/*materials*, **/*billing*).MaterialList, MaterialsMemento, material_list_policy, …).test_inventory.mjs and keep only specs whose names or paths match the feature._patchMaterialMementosForCatalog belongs to the materials feature even though SystemStrategy.js doesn't).Record the scoping set as you go — you will reference it across phases. Aim for the minimum set that explains the feature end-to-end, not every file that mentions it. If a file is only tangentially related, leave it out and rely on the top-level docs to cover it.
If the scoping set is empty or trivially small (one or two files), stop and tell the user — the feature may not exist under that name, or it may already be adequately covered in the top-level docs.
<slug>/workflows.mdSame approach as the full-mode workflow discovery, but filter to the feature scope:
test_inventory.mjs, keep system/integration tests whose paths or describe/context strings reference the feature.templates/focus-workflows.template.md. Use templates/workflow-entry.template.md for individual workflow entries.sequenceDiagram for the 1–3 most central workflows.../ (e.g., [spec/system/material_lists_spec.rb](../spec/system/material_lists_spec.rb)).<slug>/architecture.md + diagrams/Cover only the slices that matter for the feature:
Then write the two diagram files:
diagrams/<slug>-data-model.mmd — entities and relationships for the feature only. May include in-memory types (e.g., MaterialSpecifierMemento), not just DB tables.diagrams/<slug>-architecture.mmd — the feature's end-to-end flow as a graph TD (sources → processing → destinations). Group with subgraph blocks by time/space boundary (build-time vs. runtime, web admin vs. background job, etc.).Use templates/focus-architecture.template.md as the scaffold. Path references back to the rest of the repo use ../.
After writing the focus subfolder, if generated-docs/README.md exists, check whether it lists this focus subfolder under "Deep dives". If not, add it. Do not regenerate the top-level workflows.md / architecture.md / ai-orientation.md as part of focus mode — if those need cross-references too, suggest the user run /document-this to refresh them.
If the top-level docs do not exist yet, the focus subfolder is the only output. The user can run /document-this later to generate the top level; that run will detect the focus subfolder and link to it from the README.
The slug is used for the subfolder name and both diagram file prefixes — all three always match.
Materials Management → materials-management, Billing → billing, Stripe Webhooks → stripe-webhooks).Materials Management → materials, Stripe Webhooks → stripe). Use judgment./document-this <file-path>When called with a path (and no --focus), do not regenerate the whole document. Instead:
Identify which sections the file is most likely to affect:
workflows.md + test coverage map in ai-orientation.mdarchitecture.md (data model) + diagrams/data-model.mmd + possibly Terminologyarchitecture.md (patterns) + possibly workflows.mdarchitecture.md (stack)architecture.md (JS Architecture section) + possibly diagrams/architecture.mmdRe-run only the relevant scripts
Regenerate only the affected sections
Ripple check: After updating, scan other sections for cross-references or dependent content that is now stale. Update those too if needed.
Do not regenerate the entire document unless the file affects all sections.
--focus: /document-this --focus "<Feature Name>" <file-path>If --focus is also passed, restrict the update to the focus subfolder:
generated-docs/<slug>/workflows.md or architecture.md (and/or the feature-prefixed diagrams) that the file affects.generated-docs/*.md files — those are out of scope for a focused update.workflows.md. Do not fabricate workflows from routes or controllers alone.workflows.md and/or architecture.md so a reader knows there's a broader context.../ for paths to files outside the subfolder. Test specs, source files, and other top-level project files all need the parent-dir prefix.materials/diagrams/materials-architecture.mmd + materials/diagrams/materials-data-model.mmd, not materials/diagrams/mat-architecture.mmd).6695348
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.