generating-documentation
This Claude Code skill generates comprehensive technical documentation across five layers: API specifications (OpenAPI/Swagger), code documentation (TypeDoc/Sphinx/godoc/rustdoc), documentation sites (Docusaurus/MkDocs), architecture decision records, and system diagrams (Mermaid/PlantUML). Use it when documenting APIs, building developer-facing documentation sites, creating code reference materials for libraries, recording architectural decisions, or visualizing system architecture.
git clone --depth 1 https://github.com/ancoleman/ai-design-components /tmp/generating-documentation && cp -r /tmp/generating-documentation/skills/generating-documentation ~/.claude/skills/generating-documentationSKILL.md
# Documentation Generation
Generate comprehensive technical documentation across multiple layers: API documentation, code documentation, documentation sites, architecture decisions, and system diagrams.
## When to Use This Skill
Use this skill when:
- Documenting REST or GraphQL APIs with OpenAPI specifications
- Creating code documentation for libraries (TypeScript, Python, Go, Rust)
- Building documentation sites for projects or products
- Recording architectural decisions (ADRs) for system design choices
- Generating diagrams to visualize system architecture or data flows
- Setting up automated documentation pipelines in CI/CD
## Documentation Layers Overview
Technical documentation operates at five distinct layers:
**Layer 1: API Documentation** - OpenAPI specs for REST/GraphQL APIs (Swagger UI, Redoc, Scalar)
**Layer 2: Code Documentation** - Generated from code comments (TypeDoc, Sphinx, godoc, rustdoc)
**Layer 3: Documentation Sites** - Comprehensive guides and tutorials (Docusaurus, MkDocs)
**Layer 4: Architecture Decisions** - ADRs using MADR template format
**Layer 5: Diagrams** - Visual architecture (Mermaid, PlantUML, D2)
See `references/api-documentation.md`, `references/code-documentation.md`, and `references/documentation-sites.md` for detailed guides.
## Quick Decision Framework
### Which Documentation Layer?
```
API for external consumers?
→ Layer 1: API Documentation (OpenAPI + Swagger UI/Redoc)
Code for maintainers?
→ Layer 2: Code Documentation (TypeDoc/Sphinx/godoc/rustdoc)
Comprehensive guides?
→ Layer 3: Documentation Site (Docusaurus/MkDocs)
Architectural decision?
→ Layer 4: ADR (MADR template)
Visual system design?
→ Layer 5: Diagrams (Mermaid/PlantUML/D2)
```
### Tool Selection Matrix
| Need | Primary Tool | Best For |
|------|-------------|----------|
| **Doc Site** | Docusaurus | Feature-rich React sites |
| **Doc Site** | MkDocs Material | Simple Python docs |
| **API Docs (Interactive)** | Swagger UI | Testing |
| **API Docs (Read-Only)** | Redoc | Professional design |
| **TypeScript** | TypeDoc | All TS projects |
| **Python** | Sphinx | All Python projects |
| **Go** | godoc | Built-in |
| **Rust** | rustdoc | Built-in |
| **Diagrams** | Mermaid | All-purpose |
## API Documentation Quick Start
Create OpenAPI specification:
```yaml
openapi: 3.1.0
info:
title: User API
version: 1.0.0
servers:
- url: https://api.example.com/v1
paths:
/users/{userId}:
get:
summary: Get a user
parameters:
- name: userId
in: path
required: true
schema:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
required: [id, email, name]
properties:
id:
type: string
email:
type: string
format: email
name:
type: string
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
security:
- bearerAuth: []
```
Render with Swagger UI, Redoc, or Scalar. See `references/api-documentation.md` for complete examples and `templates/openapi-template.yaml` for starter template.
## Code Documentation Quick Start
### TypeScript
```typescript
/**
* Calculate the sum of two numbers.
*
* @param a - The first number
* @param b - The second number
* @returns The sum of a and b
*
* @example
* ```typescript
* const result = add(2, 3);
* console.log(result); // 5
* ```
*/
export function add(a: number, b: number): number {
return a + b;
}
```
Generate docs:
```bash
npm install -D typedoc
npx typedoc --entryPoints src/index.ts --out docs
```
### Python
```python
def calculate_total(items: list[dict], tax_rate: float = 0.0) -> float:
"""Calculate the total price including tax.
Args:
items: List of items with 'price' and 'quantity' keys.
tax_rate: Tax rate as decimal (e.g., 0.1 for 10%).
Returns:
Total price including tax.
Example:
>>> items = [{'price': 10, 'quantity': 2}]
>>> calculate_total(items, tax_rate=0.1)
22.0
"""
subtotal = sum(item['price'] * item['quantity'] for item in items)
return subtotal * (1 + tax_rate)
```
Generate docs:
```bash
pip install sphinx sphinx-rtd-theme
sphinx-quickstart docs
cd docs && make html
```
See `references/code-documentation.md` for Go and Rust examples.
## Documentation Site Quick Start
### Docusaurus
```bash
npx create-docusaurus@latest my-website classic
cd my-website
npm start
```
Basic config:
```javascript
// docusaurus.config.js
module.exports = {
title: 'My Project',
url: 'https://docs.example.com',
themeConfig: {
navbar: {
items: [
{type: 'doc', docId: 'intro', label: 'Docs'},
],
},
},
presets: [
['@docusaurus/preset-classic', {
docs: {
sidebarPath: require.resolve('./sidebars.js'),
},
}],
],
};
```
### MkDocs
```bash
pip install mkdocs mkdocs-material
mkdocs new my-project
mkdocs serve
```
Basic config:
```yaml
# mkdocs.yml
site_name: My Project
theme:
name: material
features:
- navigation.tabs
- search.suggest
plugins:
- search
nav:
- Home: index.md
- Getting Started: getting-started.md
```
See `references/documentation-sites.md` for versioning and deployment.
## Architecture Decision Records
Use MADR template for recording decisions:
```markdown
# Use PostgreSQL for Primary Database
* Status: accepted
* Deciders: Engineering Team, CTO
* Date: 2025-01-15
## Context and Problem Statement
Application requires relational database with complex queries,
ACID transactions, JSON support, and full-text search.
## Decision Drivers
* Data integrity (ACID compliance)
* Performance (10K+ queries/second)
* Cost (open-source preferred)
* Features (JSONManage Linux systems covering systemd services, process management, filesystems, networking, performance tuning, and troubleshooting. Use when deploying applications, optimizing server performance, diagnosing production issues, or managing users and security on Linux servers.
Data pipelines, feature stores, and embedding generation for AI/ML systems. Use when building RAG pipelines, ML feature serving, or data transformations. Covers feature stores (Feast, Tecton), embedding pipelines, chunking strategies, orchestration (Dagster, Prefect, Airflow), dbt transformations, data versioning (LakeFS), and experiment tracking (MLflow, W&B).
Strategic guidance for designing modern data platforms, covering storage paradigms (data lake, warehouse, lakehouse), modeling approaches (dimensional, normalized, data vault, wide tables), data mesh principles, and medallion architecture patterns. Use when architecting data platforms, choosing between centralized vs decentralized patterns, selecting table formats (Iceberg, Delta Lake), or designing data governance frameworks.
Design cloud network architectures with VPC patterns, subnet strategies, zero trust principles, and hybrid connectivity. Use when planning VPC topology, implementing multi-cloud networking, or establishing secure network segmentation for cloud workloads.
Design comprehensive security architectures using defense-in-depth, zero trust principles, threat modeling (STRIDE, PASTA), and control frameworks (NIST CSF, CIS Controls, ISO 27001). Use when designing security for new systems, auditing existing architectures, or establishing security governance programs.
Assembles component outputs from AI Design Components skills into unified, production-ready component systems with validated token integration, proper import chains, and framework-specific scaffolding. Use as the capstone skill after running theming, layout, dashboard, data-viz, or feedback skills to wire components into working React/Next.js, Python, or Rust projects.
Builds AI chat interfaces and conversational UI with streaming responses, context management, and multi-modal support. Use when creating ChatGPT-style interfaces, AI assistants, code copilots, or conversational agents. Handles streaming text, token limits, regeneration, feedback loops, tool usage visualization, and AI-specific error patterns. Provides battle-tested components from leading AI products with accessibility and performance built in.
Constructs secure, efficient CI/CD pipelines with supply chain security (SLSA), monorepo optimization, caching strategies, and parallelization patterns for GitHub Actions, GitLab CI, and Argo Workflows. Use when setting up automated testing, building, or deployment workflows.