Documentation Generator
Restructure project documentation for clarity and accessibility.
Repo Sync Before Edits (mandatory)
Before making any changes, sync with the remote to avoid conflicts:
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin
git pull --rebase origin "$branch"
If the working tree is dirty, stash first, sync, then pop. If origin is missing or conflicts occur, stop and ask the user before continuing.
Workflow
0. Create Feature Branch
Before making any changes:
- Check the current branch - if already on a feature branch for this task, skip
- Check the repo for branch naming conventions (e.g.,
feat/, feature/, etc.)
- Create and switch to a new branch following the repo's convention, or fallback to:
feat/docs-generator
1. Analyze Project
Scan the project to understand its shape.
Use sub-agents for parallel discovery. Launch multiple Agent tool calls concurrently to keep the main context clean:
- Agent 1 — Stack detection: Scan for
package.json, pyproject.toml, Cargo.toml, go.mod, pom.xml, and identify the project type (library, API, web app, CLI, microservices), architecture (monorepo, multi-package, single module), and primary language(s). Return a structured summary.
- Agent 2 — Existing docs inventory: List all existing documentation files (README.md, docs/, CONTRIBUTING.md, CHANGELOG.md, etc.) and summarize their current state — present, missing, or outdated. Return a checklist.
- Agent 3 — User personas & project purpose: Read the main entry point, existing README, and any project description fields to determine the project's purpose, key features, and target user personas (end users, developers, operators). Return a short summary.
Collect the results from all three agents before proceeding.
2. Restructure Documentation
Use sub-agents for parallel file creation. The documentation targets below are independent of each other. Dispatch them concurrently using the Agent tool, then collect results:
- Agent A — Root README.md: Streamline as the project's front door using the project summary from Step 1. Include:
- Project name + one-line description
- Badges (build status, version, license)
- Key features (bullet list, 3-5 items)
- Quickstart (install + first use in < 5 min)
- Modules/components summary with links
- Contributing link + License
- Agent B — Component READMEs: Add per module/package/service documentation using the architecture info from Step 1. Include:
- Purpose and responsibilities
- Setup instructions specific to the component
- Testing commands
- Agent C — docs/ directory: Create only the files that are relevant to the project type identified in Step 1. Target structure:
docs/
├── architecture.md # System design, component diagrams
├── api-reference.md # Endpoints, authentication, examples
├── database.md # Schema, migrations, ER diagrams
├── deployment.md # Production setup, infrastructure
├── development.md # Local setup, contribution workflow
├── troubleshooting.md # Common issues and solutions
└── user-guide.md # End-user documentation
Each agent should return the path(s) of files it created or updated.
Not every project needs all of these. A CLI tool likely needs a user-guide but not an api-reference. A library needs api-reference but not deployment. Use judgment.
3. Create Diagrams
Use Mermaid for visual documentation embedded directly in markdown:
- Architecture diagrams: Show components and their relationships
- Data flow diagrams: Show how data moves through the system
- Database schemas: ER diagrams for relational models
Example:
```mermaid
graph TD
A["Client"] --> B["API Gateway"]
B --> C["Auth Service"]
B --> D["Core Service"]
D --> E["Database"]
```
4. Quality Checklist
After generating docs, verify:
Guidelines
- Keep docs concise and scannable — prefer bullet lists and tables over prose
- Adapt structure to project type (skip categories that don't apply)
- Maintain cross-references between related docs
- Remove redundant or outdated content
- Use real examples from the codebase, not generic placeholders
1---2name: docs-generator3description: Restructure project documentation for clarity and accessibility. Use when users ask to "organize docs", "generate documentation", "improve doc structure", "restructure README", "write docs", "create README", "document my code", "add API docs", "document this project", "help with documentation", or need to reorganize scattered documentation into a coherent structure. Analyzes project type and creates appropriate documentation hierarchy. Trigger this skill whenever the user needs documentation created, reorganized, or improved — even if they just say something like "this project needs docs" or "the README is a mess".4---56# Documentation Generator78Restructure project documentation for clarity and accessibility.910## Repo Sync Before Edits (mandatory)1112Before making any changes, sync with the remote to avoid conflicts:1314```bash15branch="$(git rev-parse --abbrev-ref HEAD)"16git fetch origin17git pull --rebase origin "$branch"18```1920If the working tree is dirty, stash first, sync, then pop. If `origin` is missing or conflicts occur, stop and ask the user before continuing.2122## Workflow2324### 0. Create Feature Branch2526Before making any changes:271. Check the current branch - if already on a feature branch for this task, skip282. Check the repo for branch naming conventions (e.g., `feat/`, `feature/`, etc.)293. Create and switch to a new branch following the repo's convention, or fallback to: `feat/docs-generator`3031### 1. Analyze Project3233Scan the project to understand its shape.3435**Use sub-agents for parallel discovery.** Launch multiple Agent tool calls concurrently to keep the main context clean:3637- **Agent 1 — Stack detection**: Scan for `package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `pom.xml`, and identify the project type (library, API, web app, CLI, microservices), architecture (monorepo, multi-package, single module), and primary language(s). Return a structured summary.38- **Agent 2 — Existing docs inventory**: List all existing documentation files (README.md, docs/, CONTRIBUTING.md, CHANGELOG.md, etc.) and summarize their current state — present, missing, or outdated. Return a checklist.39- **Agent 3 — User personas & project purpose**: Read the main entry point, existing README, and any project description fields to determine the project's purpose, key features, and target user personas (end users, developers, operators). Return a short summary.4041Collect the results from all three agents before proceeding.4243### 2. Restructure Documentation4445**Use sub-agents for parallel file creation.** The documentation targets below are independent of each other. Dispatch them concurrently using the Agent tool, then collect results:4647- **Agent A — Root README.md**: Streamline as the project's front door using the project summary from Step 1. Include:48 - Project name + one-line description49 - Badges (build status, version, license)50 - Key features (bullet list, 3-5 items)51 - Quickstart (install + first use in < 5 min)52 - Modules/components summary with links53 - Contributing link + License54- **Agent B — Component READMEs**: Add per module/package/service documentation using the architecture info from Step 1. Include:55 - Purpose and responsibilities56 - Setup instructions specific to the component57 - Testing commands58- **Agent C — docs/ directory**: Create only the files that are relevant to the project type identified in Step 1. Target structure:59 ```60 docs/61 ├── architecture.md # System design, component diagrams62 ├── api-reference.md # Endpoints, authentication, examples63 ├── database.md # Schema, migrations, ER diagrams64 ├── deployment.md # Production setup, infrastructure65 ├── development.md # Local setup, contribution workflow66 ├── troubleshooting.md # Common issues and solutions67 └── user-guide.md # End-user documentation68 ```6970Each agent should return the path(s) of files it created or updated.7172Not every project needs all of these. A CLI tool likely needs a user-guide but not an api-reference. A library needs api-reference but not deployment. Use judgment.7374### 3. Create Diagrams7576Use Mermaid for visual documentation embedded directly in markdown:77- **Architecture diagrams**: Show components and their relationships78- **Data flow diagrams**: Show how data moves through the system79- **Database schemas**: ER diagrams for relational models8081Example:8283 ```mermaid84 graph TD85 A["Client"] --> B["API Gateway"]86 B --> C["Auth Service"]87 B --> D["Core Service"]88 D --> E["Database"]89 ```9091### 4. Quality Checklist9293After generating docs, verify:94- [ ] All internal links work (no broken references)95- [ ] Code examples are accurate and runnable96- [ ] No duplicate information across files97- [ ] Consistent formatting and heading levels98- [ ] Existing content preserved (enhanced, not replaced)99100### Guidelines101102- Keep docs concise and scannable — prefer bullet lists and tables over prose103- Adapt structure to project type (skip categories that don't apply)104- Maintain cross-references between related docs105- Remove redundant or outdated content106- Use real examples from the codebase, not generic placeholders