Backend Documentation
Create objective Markdown documentation for backend systems from code evidence. Generate only the document type the user selects; do not create a full documentation set unless explicitly requested.
Document Selection
If the user does not specify the document type, ask them to choose one or more:
| User need |
Template |
| Architecture and backend design |
templates/architecture-design.md |
| Developer onboarding |
templates/developer-onboarding.md |
| Gap analysis and improvement opportunities |
templates/gap-analysis.md |
| API contracts and endpoint behavior |
templates/api-contracts.md |
| Bounded context map and DDD documentation |
templates/bounded-context-map.md |
If the user asks for "backend docs" without a target path, create the selected file under docs/backend/ using the template name as the filename. If the repository has a stronger docs convention, follow that convention instead.
Argument rules:
- Treat
--mode as the selected document type.
- Treat
--backendPath as the backend path, module, bounded context, route group, or scope to inspect.
- Treat
--outputPath as the requested Markdown destination.
- If
--mode is missing, infer the document type from the user's wording or ask them to choose.
Selection rules:
- Choose
bounded-context-map.md when the request mentions bounded context, domain map, subdomain, ubiquitous language, context boundary, DDD mapping, or documentation recommendations for a domain area.
- Choose
gap-analysis.md when the main outcome is risks, smells, violations, or improvement opportunities, even if DDD is one of the lenses.
- Choose
architecture-design.md when the main outcome is how the backend is structured or why it is designed that way.
- Ask a clarifying question only when two document types would produce materially different outputs and the prompt does not imply a stronger reader need.
Workflow
Step 1: Confirm Scope
Identify the target backend, module, service, bounded context, or route group. If the request is broad, document only the highest-value slice first and note what remains out of scope.
Capture:
- Document type and target reader.
- Target path or docs convention.
- Backend stack and runtime if discoverable.
- Whether the document should describe current state, proposed design, or both.
Step 2: Discover Rules and Existing Docs
Read references/discovery-workflow.md, then inspect project rules before reading implementation details.
Prioritize:
- Project instructions:
AGENTS.md, CLAUDE.md, .cursor/rules/, .windsurf/rules/, CONTRIBUTING.md.
- Existing docs:
docs/, ADRs, RFCs, architecture notes, onboarding docs.
- Code contracts: route definitions, schemas, generated OpenAPI setup, database schemas, migrations, jobs, queues, integrations, tests.
If project rules conflict with this skill, project rules win.
Step 3: Gather Evidence From Code
Trace the backend from entry points to behavior. Use file references rather than pasting large code blocks.
Look for:
- App bootstrapping, dependency injection, routing, middleware, auth, and tenancy.
- Controllers, handlers, use cases, services, domain models, repositories, data access, and external clients.
- API request and response schemas, error shapes, status codes, generated documentation, and client contracts.
- Database tables, relationships, migrations, transactions, backfills, and unsafe migration patterns.
- Background jobs, webhooks, queues, event flows, scheduled tasks, retries, idempotency, and failure handling.
- Tests, observability, runbooks, feature flags, rollback paths, and operational risks.
Document facts as "Observed" and label conclusions as "Inference" when they are not directly stated in code or docs.
Step 4: Load Only Relevant References
Use progressive disclosure:
- For documentation structure and brevity, read
references/documentation-principles.md.
- For backend evidence collection and source-skill routing, read
references/source-skill-map.md.
- For architecture, API, DDD, coupling, data, and quality checks, read
references/backend-quality-lenses.md.
- For Hono, Zod/OpenAPI, Drizzle, schema validation, generated API docs, or migration evidence, read
references/framework-contract-notes.md.
- For the selected document shape, read only the matching template in
templates/.
Step 5: Write the Markdown Document
Use the selected template as the structure. Keep the document compact and useful to the target reader.
Each generated document should:
- Start with scope, audience, and last-reviewed date.
- Cite concrete code or docs evidence with file paths and line numbers when available.
- Separate current state from recommendations.
- Prefer tables for inventories, risks, APIs, gaps, and next actions.
- Include diagrams only when they clarify relationships or runtime flow.
- Mark unknowns and assumptions instead of inventing missing details.
- End with a short maintenance note explaining when the document should be updated.
Step 6: Validate Before Finishing
Before final response:
- Re-read the generated or edited document.
- Check that the selected template was followed.
- Check that every non-obvious claim has evidence or is labeled as inference.
- Check that no unrelated templates were generated.
- Check links and file paths.
- If validation commands exist for docs formatting or markdown linting, run the project-preferred command.
Output Rules
- Write in the user's language unless the repository has a documented docs language.
- Use concise technical prose. Avoid promotional language and generic claims.
- Do not duplicate large source code blocks. Link to source paths instead.
- Do not silently create ADRs, RFCs, or TDDs unless the user selected that form or the repository convention requires it.
- Do not implement backend changes while documenting. If gaps are found, record them as recommendations.
Examples
Architecture and Design
User says: "Document the backend architecture for the billing service."
Action: Select templates/architecture-design.md, inspect project rules and billing code, map components and runtime flows, then write one Markdown document with current architecture, decisions, risks, and improvement opportunities.
Onboarding
User says: "Create onboarding docs so a new backend dev can understand this API."
Action: Select templates/developer-onboarding.md, identify setup commands and core flows from project docs and code, then write a practical guide that gets the reader from local setup to safe first contribution.
Gap Analysis
User says: "Find backend documentation gaps and architecture smells in this module."
Action: Select templates/gap-analysis.md, apply project rules plus DDD, coupling, API, data, and testing lenses, then produce prioritized findings with evidence, severity, and next actions.
Bounded Context Map
User says: "Map the auth bounded context and recommend backend docs we should add."
Action: Select templates/bounded-context-map.md, apply the domain-analysis, tactical-DDD, coupling, API, data, and project-rule lenses, then produce one context map with boundaries, relationships, model ownership, risks, unknowns, and documentation recommendations.
1---2name: backend-docs3description: Creates selected backend Markdown documentation from code evidence, including architecture/design docs, bounded context maps, developer onboarding, API contracts, and gap analysis for code smells, project-rule violations, DDD issues, coupling, and improvement opportunities. Use when the user asks to document a backend, map backend architecture or domains, onboard backend developers, audit backend documentation gaps, or produce objective backend docs. Do NOT use for frontend docs, generic README writing, or implementing backend changes.4---56# Backend Documentation78Create objective Markdown documentation for backend systems from code evidence. Generate only the document type the user selects; do not create a full documentation set unless explicitly requested.910## Document Selection1112If the user does not specify the document type, ask them to choose one or more:1314| User need | Template |15| ------------------------------------------ | ----------------------------------- |16| Architecture and backend design | `templates/architecture-design.md` |17| Developer onboarding | `templates/developer-onboarding.md` |18| Gap analysis and improvement opportunities | `templates/gap-analysis.md` |19| API contracts and endpoint behavior | `templates/api-contracts.md` |20| Bounded context map and DDD documentation | `templates/bounded-context-map.md` |2122If the user asks for "backend docs" without a target path, create the selected file under `docs/backend/` using the template name as the filename. If the repository has a stronger docs convention, follow that convention instead.2324Argument rules:2526- Treat `--mode` as the selected document type.27- Treat `--backendPath` as the backend path, module, bounded context, route group, or scope to inspect.28- Treat `--outputPath` as the requested Markdown destination.29- If `--mode` is missing, infer the document type from the user's wording or ask them to choose.3031Selection rules:3233- Choose `bounded-context-map.md` when the request mentions bounded context, domain map, subdomain, ubiquitous language, context boundary, DDD mapping, or documentation recommendations for a domain area.34- Choose `gap-analysis.md` when the main outcome is risks, smells, violations, or improvement opportunities, even if DDD is one of the lenses.35- Choose `architecture-design.md` when the main outcome is how the backend is structured or why it is designed that way.36- Ask a clarifying question only when two document types would produce materially different outputs and the prompt does not imply a stronger reader need.3738## Workflow3940### Step 1: Confirm Scope4142Identify the target backend, module, service, bounded context, or route group. If the request is broad, document only the highest-value slice first and note what remains out of scope.4344Capture:4546- Document type and target reader.47- Target path or docs convention.48- Backend stack and runtime if discoverable.49- Whether the document should describe current state, proposed design, or both.5051### Step 2: Discover Rules and Existing Docs5253Read `references/discovery-workflow.md`, then inspect project rules before reading implementation details.5455Prioritize:56571. Project instructions: `AGENTS.md`, `CLAUDE.md`, `.cursor/rules/`, `.windsurf/rules/`, `CONTRIBUTING.md`.582. Existing docs: `docs/`, ADRs, RFCs, architecture notes, onboarding docs.593. Code contracts: route definitions, schemas, generated OpenAPI setup, database schemas, migrations, jobs, queues, integrations, tests.6061If project rules conflict with this skill, project rules win.6263### Step 3: Gather Evidence From Code6465Trace the backend from entry points to behavior. Use file references rather than pasting large code blocks.6667Look for:6869- App bootstrapping, dependency injection, routing, middleware, auth, and tenancy.70- Controllers, handlers, use cases, services, domain models, repositories, data access, and external clients.71- API request and response schemas, error shapes, status codes, generated documentation, and client contracts.72- Database tables, relationships, migrations, transactions, backfills, and unsafe migration patterns.73- Background jobs, webhooks, queues, event flows, scheduled tasks, retries, idempotency, and failure handling.74- Tests, observability, runbooks, feature flags, rollback paths, and operational risks.7576Document facts as "Observed" and label conclusions as "Inference" when they are not directly stated in code or docs.7778### Step 4: Load Only Relevant References7980Use progressive disclosure:8182- For documentation structure and brevity, read `references/documentation-principles.md`.83- For backend evidence collection and source-skill routing, read `references/source-skill-map.md`.84- For architecture, API, DDD, coupling, data, and quality checks, read `references/backend-quality-lenses.md`.85- For Hono, Zod/OpenAPI, Drizzle, schema validation, generated API docs, or migration evidence, read `references/framework-contract-notes.md`.86- For the selected document shape, read only the matching template in `templates/`.8788### Step 5: Write the Markdown Document8990Use the selected template as the structure. Keep the document compact and useful to the target reader.9192Each generated document should:9394- Start with scope, audience, and last-reviewed date.95- Cite concrete code or docs evidence with file paths and line numbers when available.96- Separate current state from recommendations.97- Prefer tables for inventories, risks, APIs, gaps, and next actions.98- Include diagrams only when they clarify relationships or runtime flow.99- Mark unknowns and assumptions instead of inventing missing details.100- End with a short maintenance note explaining when the document should be updated.101102### Step 6: Validate Before Finishing103104Before final response:105106- Re-read the generated or edited document.107- Check that the selected template was followed.108- Check that every non-obvious claim has evidence or is labeled as inference.109- Check that no unrelated templates were generated.110- Check links and file paths.111- If validation commands exist for docs formatting or markdown linting, run the project-preferred command.112113## Output Rules114115- Write in the user's language unless the repository has a documented docs language.116- Use concise technical prose. Avoid promotional language and generic claims.117- Do not duplicate large source code blocks. Link to source paths instead.118- Do not silently create ADRs, RFCs, or TDDs unless the user selected that form or the repository convention requires it.119- Do not implement backend changes while documenting. If gaps are found, record them as recommendations.120121## Examples122123### Architecture and Design124125User says: "Document the backend architecture for the billing service."126127Action: Select `templates/architecture-design.md`, inspect project rules and billing code, map components and runtime flows, then write one Markdown document with current architecture, decisions, risks, and improvement opportunities.128129### Onboarding130131User says: "Create onboarding docs so a new backend dev can understand this API."132133Action: Select `templates/developer-onboarding.md`, identify setup commands and core flows from project docs and code, then write a practical guide that gets the reader from local setup to safe first contribution.134135### Gap Analysis136137User says: "Find backend documentation gaps and architecture smells in this module."138139Action: Select `templates/gap-analysis.md`, apply project rules plus DDD, coupling, API, data, and testing lenses, then produce prioritized findings with evidence, severity, and next actions.140141### Bounded Context Map142143User says: "Map the auth bounded context and recommend backend docs we should add."144145Action: Select `templates/bounded-context-map.md`, apply the domain-analysis, tactical-DDD, coupling, API, data, and project-rule lenses, then produce one context map with boundaries, relationships, model ownership, risks, unknowns, and documentation recommendations.