From claw
Generates, syncs, resets, and publishes project documentation with Mermaid diagrams in docs/ folder, optimized for LLMs, bots, and humans.
npx claudepluginhub dnviti/codeclaw --plugin clawThis skill uses the workspace's default tool permissions.
> **Project configuration is authoritative.** Before executing, run `SH context` to load project configuration. If any instruction here contradicts the project configuration, the project configuration takes priority.
Generates documentation from code including API references, developer guides, READMEs, and architecture overviews. Matches existing styles and avoids overwriting in brownfield codebases.
Generates documentation for codebases—from file references and feature guides to full sites. Detects and adapts to frameworks like Fumadocs, Nextra, Docusaurus.
Share bugs, ideas, or general feedback.
Project configuration is authoritative. Before executing, run
SH contextto load project configuration. If any instruction here contradicts the project configuration, the project configuration takes priority.
You are a documentation engineer for this project. You produce and maintain precise technical documentation that is equally useful to humans, LLMs, and bots.
Always respond and work in English.
Every AskUserQuestion is a GATE — STOP and wait for user response before proceeding.
SH context → platform config, branch config as JSON. Use throughout.
SH dispatch --skill docs --args "$ARGUMENTS"
Returns flow and yolo:
"generate": Full documentation generation from codebase analysis (default)."sync": Incremental update of stale sections only."reset": Remove all generated documentation."publish": Build and publish docs as a website.Also returns yolo: true/false (see Yolo Mode in project configuration).
Generated documentation lives in docs/ with this layout:
| File | Purpose |
|---|---|
index.md | Landing page, table of contents, project summary |
architecture.md | System architecture, component diagrams (Mermaid) |
getting-started.md | Installation, prerequisites, first run |
configuration.md | Environment variables, config files, feature flags |
api-reference.md | Endpoints, functions, CLI commands |
deployment.md | Build, Docker, CI/CD, production setup |
development.md | Contributing, local dev, testing, branch strategy |
troubleshooting.md | Common errors, debugging, FAQ |
llm-context.md | Consolidated single-file for LLM/bot consumption |
.docs-manifest.json | Machine-readable manifest for staleness tracking |
Every generated doc file MUST follow these standards:
Every file starts with YAML front-matter:
---
title: Architecture
description: System architecture, component interactions, and data flow
generated-by: claw-docs
generated-at: 2026-03-16T14:30:00Z
source-files:
- src/app.ts
- src/server.ts
---
Use Mermaid for all visual explanations:
flowchart TD for component diagramsflowchart LR for request/response pipelinessequenceDiagram for API interactionsflowchart TD for infrastructure and CI/CD pipelinesstateDiagram-v2 for lifecycle statesllm-context.md as a single consolidated file containing: project summary, architecture overview, key APIs, configuration reference, and quick-start commandsFull documentation generation from codebase analysis. Creates all sections from scratch.
1. Discover codebase:
DM discover
Parse result: languages, frameworks, role_counts, entry_points, config_files, docs_exist, existing_sections.
2. If docs_exist is true and sections already generated → GATE: "Documentation already exists. Overwrite all?" / "Run /docs sync instead" / "Cancel"
2.5. Choose visual richness level.
GATE via AskUserQuestion with header "Visual Richness":
Store the selection as visual_richness_level (zero, tiny, moderate, or large) for use in all subsequent generation steps.
3. Read the project documentation for architecture and patterns.
4. Present analysis:
Codebase Analysis
- Languages: [list with file counts]
- Frameworks: [detected]
- Source files: N total (M entry points, K configs, J tests)
- Sections to generate: 9
GATE: "Proceed with documentation generation" / "Adjust scope" / "Cancel"
5. Generate each documentation section. For each section:
5a. Read all relevant source files based on their role classification from DM discover. Map roles to sections:
architecture.md ← entry_points, server, app, middleware, router filesgetting-started.md ← README, package manifests, Dockerfiles, Makefilesconfiguration.md ← config files, .env examples, environment schemasapi-reference.md ← route, controller, handler, API client filesdeployment.md ← CI/CD configs, Dockerfiles, infra files, scriptsdevelopment.md ← test files, lint configs, AGENTS.md, CONTRIBUTING.mdtroubleshooting.md ← error handling code, logging, health check filesUse only the role-classified source files returned by DM discover when assembling each section. The docs workflow is now manifest-driven and does not perform semantic re-indexing.
5b. Write the section following Documentation Standards and the visual_richness_level selected in Step 2.5.
Tier-specific formatting rules:
| Tier | Formatting |
|---|---|
| zero | Standard Markdown only. No emoji, no images, no inline HTML. Plain headings, lists, code blocks, and Mermaid diagrams only. |
| tiny | Prepend each H2 section header with a relevant Unicode emoticon (e.g., ## Configuration, ## Deployment). In index.md, include . If no logo file exists at docs/assets/logo.svg, create a simple project SVG logo using inline SVG markup (geometric shape + project initials, saved via the Write tool). |
| moderate | All of tiny, plus: use HTML <div class="callout callout-info"> / callout-warning / callout-tip blocks for important notes, tips, and warnings. Use <img> badge shields (e.g., <img src="https://img.shields.io/badge/...">) for version, status, and license indicators in index.md. Use <table> with styled headers where Markdown tables are insufficient for complex data. Use inline SVG icons for visual markers. |
| large | All of moderate, plus: wrap feature overviews in card-style <div class="card"> layouts. Use <details><summary> collapsible sections for lengthy reference content (e.g., full API listings, exhaustive config tables). Use styled headers via <h2 style="border-bottom: 2px solid #4A90D9; padding-bottom: 0.3em;">. Use <picture> elements with light/dark mode variants where applicable. Add a CSS <style> block at the top of each file defining .card, .callout, .badge classes. |
All tiers include:
docs/<section>.md using the Write tool5b. Track source files — record which source files contributed to each section for the manifest.
6. Generate index.md:
7. Generate llm-context.md:
8. Write manifest:
DM init-manifest --sections-json '[{"name":"architecture","file":"architecture.md","source_files":["src/app.ts",...]}]' --visual-richness <visual_richness_level>
Pass all sections with their contributing source files. The --visual-richness parameter persists the selected tier so that /docs sync preserves the same visual style.
9. Present report:
| Section | File | Lines | Sources |
|---|---|---|---|
| Architecture | architecture.md | N | M files |
| ... | ... | ... | ... |
Documentation generated in
docs/. Run/docs publishto create a website.
Incremental documentation update. Only regenerates stale sections based on source file changes. This flow is called automatically by /release at Stage 7h.
1. Check for existing docs:
DM list-sections
If docs_exist is false → "No documentation found. Run /docs generate first." STOP.
2. Check staleness:
DM check-staleness
2b. If called during a release (release state exists), also check tag-based diff:
RM release-state-get
DM diff-since-tag --tag <latest_tag>
Use affected_sections to supplement staleness data.
3. If all sections are current after hash-based and tag-based checks → "Documentation is up to date. No changes needed." STOP.
4. Present stale sections:
Documentation Sync — N section(s) need updating:
Section Status Changed Sources architecture stale src/app.ts, src/routes.ts api-reference stale src/controllers/auth.ts
GATE: "Update stale sections" / "Update all" / "Cancel"
5. For each stale section:
DM get-visual-richness. Apply the same tier-specific formatting rules from Generate Flow Step 5b.generated-at timestamp, source-files list6. Update manifest:
DM init-manifest --sections-json '[...]'
7. Present report:
| Section | Status |
|---|---|
| architecture | Updated (3 source files changed) |
| api-reference | Updated (1 source file changed) |
| configuration | Current (no changes) |
Remove all generated documentation files.
1. List current docs:
DM list-sections
If no docs exist → "No documentation to reset." STOP.
2. Present what will be deleted:
The following documentation files will be deleted:
- docs/architecture.md (N lines)
- docs/api-reference.md (M lines)
- ...
- docs/.docs-manifest.json
3. GATE: "Confirm reset — delete all generated docs" / "Cancel"
Yolo mode does NOT auto-select this gate. Always ask for confirmation on destructive operations.
4. Execute:
DM clean
5. Present: "Documentation reset. Run /docs generate to regenerate."
Build and publish documentation as a static website. Source is always Markdown — this flow adds a presentation layer on top.
1. Verify docs exist:
DM list-sections
If no docs → "No documentation found. Run /docs generate first." STOP.
2. Detect existing site generator:
DM detect-site-generator
3a. If generator detected:
Found [name] (config: [config_file]) Build:
[build_command]Serve:[serve_command]
GATE: "Build with [name]" / "Choose a different generator" / "Cancel"
3b. If no generator detected:
No static site generator found. Recommended: [name] — [reason] Install:
[install_command]
GATE: "Install [recommended]" / "Choose another" / "Cancel"
After installation, generate a default configuration file pointing at the docs/ directory.
4. Build: Run the generator's build command. Present output.
On failure → GATE: "Fix and retry" / "Cancel"
5. GATE: "Preview locally" / "Skip to deploy instructions"
If preview: run the serve command, present the local URL.
6. Present deployment options:
Documentation site built successfully.
Deploy options:
- GitHub Pages: push to
gh-pagesbranch or configure Actions- Manual: upload build output from
[output_dir]/The Markdown source in
docs/remains the single source of truth.
.docs-manifest.json records which source files contributed to each section and their hashes at generation time.llm-context.md file ensure any agent can consume the docs.