This skill generates comprehensive documentation from code implementations, including API references, user guides, and architecture notes to support
npx playbooks add skill matthew-plusprogramming/monorepo --skill docs
Before beginning work, read these files for project-specific guidelines:
.claude/memory-bank/best-practices/spec-authoring.md.claude/memory-bank/best-practices/typescript.mdGenerate documentation artifacts from implemented code. Create durable external context that survives beyond the current session.
Documentation is mandatory for oneoff-spec. Run after security review, before commit.
For public endpoints and methods:
## methodName
Brief description of what it does.
### Parameters
| Name | Type | Required | Description |
| ------ | ------ | -------- | ---------------------------- |
| param1 | string | Yes | What this parameter controls |
### Returns
`ReturnType` - Description of return value
### Errors
| Error | When |
| ----------------- | -------------------- |
| InvalidInputError | When param1 is empty |
### Example
\`\`\`typescript
const result = await service.methodName('value');
\`\`\`
For user-facing features:
## Feature Name
What this feature does and why you'd use it.
### Getting Started
Step-by-step instructions for basic usage.
### Configuration
Available options and what they control.
### Examples
Common use cases with code/UI examples.
### Troubleshooting
Common issues and how to resolve them.
For complex systems:
## Component Name
### Purpose
Why this component exists and what problem it solves.
### Design Decisions
Key decisions and their rationale.
### Data Flow
How data moves through the component.
### Dependencies
What this component depends on and why.
# Check what was implemented from spec group
cat .claude/specs/groups/<spec-group-id>/manifest.json
cat .claude/specs/groups/<spec-group-id>/spec.md
# Find modified files from implementation evidence or git diff
git diff --name-only main..HEAD
# Identify public interfaces
grep -r "export" src/ --include="*.ts" | grep -E "(class|interface|function|const)"
Determine documentation needs:
Critical: Document what the code DOES, not what the spec SAYS.
# Read actual implementation
cat src/services/feature.ts
# Check for edge cases in tests
cat src/services/__tests__/feature.test.ts
# Look for error handling
grep -A5 "catch\|throw\|Error" src/services/feature.ts
Follow documentation standards:
docs/
├── api/ # API reference
│ └── services/
│ └── auth.md
├── guides/ # User guides
│ └── authentication.md
├── architecture/ # Internal architecture
│ └── auth-system.md
└── README.md # Project overview
For inline documentation:
Run the diagram generator to ensure all Mermaid diagrams are fresh:
node .claude/scripts/docs-generate.mjs
This produces .mmd files in .claude/docs/structured/generated/ for all available YAML sources (architecture, flows, ERD, state, security, deployment, C4 component). Missing sources are skipped silently.
When spec authoring is complete for a linked PRD, trigger Phase 2 enrichment of the PRD Report:
prd reference in manifest.jsondata-models.yaml.claude/prds/<prd-id>/report.md using template at .claude/templates/prd-report.template.md# Check code examples compile (if applicable)
npx tsc --noEmit docs/examples/*.ts
# Ensure consistent formatting
npx prettier --check docs/**/*.md
Update manifest.json with documentation status:
{
"convergence": {
"docs_generated": true
},
"decision_log": [
{
"timestamp": "<ISO timestamp>",
"actor": "agent",
"action": "docs_generated",
"details": "API docs + user guide created, 3 examples verified"
}
]
}
Add documentation log to spec group:
## Documentation Log
- 2026-01-08: Documentation complete
- API docs: docs/api/services/auth.md
- User guide: docs/guides/authentication.md
- Atomic specs documented: as-001, as-002, as-003
- Examples verified: 3 code samples tested
Assess which categories apply to the project, then generate documentation for each applicable category.
| Category | When Required | Contents |
| -------------------------------- | --------------------------- | ------------------------------------------------------------------------ |
| High-Level Overview | All projects | Project purpose, quick start, workspace listing |
| System Architecture | Multi-component projects | Data flow diagrams, service boundaries, component relationships |
| API Documentation - Public | Projects with public APIs | Endpoints, authentication, request/response examples, error codes |
| API Documentation - Internal | Projects with internal APIs | Internal endpoints, service-to-service contracts |
| Operations Guide | Production systems | Deployment procedures, monitoring, troubleshooting, emergency procedures |
| Frontend Documentation | UI projects | Component overview, state management, routing, key patterns |
| Setup/Installation | All projects | Environment setup, dependencies, local development |
| Contributing Guide | Shared/open projects | Branch strategy, PR process, code review expectations |
Conditional Requirements:
Follow these established patterns based on documentation type:
README Structure:
API Documentation Pattern:
Operations Guide Pattern:
Documentation Index Pattern:
Every code example must:
Bad:
const result = doThing(params); // params undefined
Good:
import { AuthService } from '@/services/auth';
const authService = new AuthService();
const result = await authService.logout();
// result: { success: true }
Bad (leaks implementation):
The logout method clears the localStorage key 'auth_token'
and sets the BehaviorSubject to false.
Good (describes behavior):
The logout method ends the current session and redirects
to the login page. Any cached credentials are cleared.
| Doc Type | Audience | Tone | Detail Level |
| ------------- | ------------------ | ---------------------- | ------------ |
| API Reference | Developers | Technical, precise | High |
| User Guide | End users | Friendly, task-focused | Medium |
| Architecture | Future maintainers | Explanatory | High |
## Documentation Complete
**Spec Group**: .claude/specs/groups/<spec-group-id>/
**Atomic Specs Documented**:
- as-001: Logout Button UI
- as-002: Token Clearing
- as-003: Post-Logout Redirect
**Artifacts Created**:
- docs/api/services/auth.md (API reference)
- docs/guides/authentication.md (user guide)
**Coverage**:
- Public methods documented: 5/5
- Examples included: 3
- Error conditions documented: 4
**Validation**:
- Code examples: verified
- Links: verified
- Formatting: consistent
**Manifest Updated**: convergence.docs_generated: true
Before docs:
/security review passedAfter docs:
/manual-test <spec-group-id> — Bounded exploratory verification (5 happy + 3 failure + 2 adjacent, then stop). Advisory by default; mandatory when any active spec declares runtime_validation_required: true. Final step before commit for spec-based workflows. See .claude/skills/manual-test/SKILL.md./manual-test findings are reviewed.Documentation followed by /manual-test is the final pre-commit step for substantial changes in spec-based workflows.
After generating documentation artifacts, check whether the implementation touched modules defined in the project's structured documentation system.
.claude/docs/structured/architecture.yaml exists, read it to get the list of modules and their path globs.git diff --name-only or the spec's Implementation Evidence to get the list of files modified in this session.path glob pattern.architecture.yaml or any relevant flow files (in .claude/docs/structured/flows/) were also modified in this session.When structured docs may need updating, include this in your output:
### Structured Documentation Review
The following modules had implementation changes but no corresponding structured doc updates:
- **module-name**: Files matching `path/glob/**` were modified
- Consider: Update architecture.yaml description or responsibilities
- Consider: Add/update flow steps if behavior changed
- Consider: Add new glossary terms if new concepts introduced
Run `node .claude/scripts/docs-validate.mjs` to check for cross-reference issues.
.claude/docs/structured/architecture.yaml does not exist (structured docs not adopted)The spec says what SHOULD happen. The code says what DOES happen. Document reality.
You generate documentation only. If you find:
Match existing documentation style in the project. Follow established patterns.
Input: New logout endpoint implementation
Output:
# AuthService.logout()
Terminates the current user session and clears authentication state.
## Signature
\`\`\`typescript
async logout(): Promise<void>
\`\`\`
## Behavior
1. Calls server to invalidate session
2. Clears local authentication token
3. Updates auth state to unauthenticated
4. Triggers redirect to login page
## Errors
| Error | Cause |
| -------------- | ---------------------- |
| `NetworkError` | Cannot reach server |
| `LogoutError` | Server rejected logout |
## Example
\`\`\`typescript
import { authService } from '@/services/auth';
try {
await authService.logout();
// User is now logged out, redirect handled automatically
} catch (error) {
if (error instanceof NetworkError) {
showToast('Check your connection and try again');
}
}
\`\`\`
Input: New dashboard feature
Output:
# Using the Dashboard
The dashboard provides an overview of your daily tasks and priorities.
## Getting Started
1. Log in to your account
2. Click "Dashboard" in the navigation menu
3. Your daily briefing appears automatically
## Features
### Daily Briefing
Shows your priorities for today, including:
- Urgent emails requiring response
- Upcoming calendar events
- Tasks due today
### Quick Actions
- **Snooze**: Postpone an item to later
- **Complete**: Mark a task as done
- **Delegate**: Assign to someone else
## Customization
Access Settings → Dashboard to configure:
- Briefing time (default: 9:00 AM)
- Priority thresholds
- Notification preferences
Input: New notification service
Output:
# Notification Service Architecture
## Purpose
Centralizes all user notifications across channels (email, SMS, push).
## Design Decisions
**Why a separate service?**
- Decouples notification logic from business logic
- Enables channel-agnostic notification requests
- Supports future channels without core changes
**Why queue-based?**
- Handles burst traffic gracefully
- Enables retry logic for failed deliveries
- Provides delivery tracking
## Data Flow
\`\`\`
Business Logic → NotificationService.send()
↓
Queue (Redis)
↓
Channel Adapters (Email, SMS, Push)
↓
Delivery Status → Database
\`\`\`
## Dependencies
- **Redis**: Message queue
- **Telnyx**: SMS delivery
- **SendGrid**: Email delivery
- **Firebase**: Push notificationsWeekly roundup of top Claude Code skills, MCP servers, and AI coding tips.