Purpose & When-To-Use
Trigger conditions:
- New feature requires documentation
- API endpoint needs OpenAPI-driven documentation
- User guide or tutorial creation needed
- Documentation refresh for clarity and accessibility
- Knowledge base article generation
- Migration from wiki/docs to structured documentation site
Not for:
- Marketing copy or sales materials
- Legal documents or contracts
- Research papers or academic writing
- Long-form narrative content
Pre-Checks
Time normalization:
- Compute
NOW_ET using NIST/time.gov semantics (America/New_York, ISO-8601)
- Use
NOW_ET for all citation access dates
Input validation:
content_type must be one of: technical-doc, api-doc, user-guide, tutorial
source must be valid (file exists, spec parseable, or non-empty string)
output_format must be: markdown, mdx, or html
style_guide must be: microsoft, google, or write-the-docs
Source freshness:
- For API docs: verify OpenAPI spec version (3.0.x or 3.1.x supported)
- Style guide references accessible and current
Procedure
T1: Standard Documentation Generation (≤2k tokens)
Fast path for 80% of documentation needs:
Content Analysis
- Detect content type from source or use provided
content_type
- Identify key sections needed (overview, quickstart, reference, examples)
Template Selection (Write the Docs Structure Guide, accessed 2025-10-25T21:30:36-04:00)
- Technical Doc: Title, Purpose, Prerequisites, Steps, Troubleshooting, Next Steps
- API Doc: Endpoint description, Request/Response schemas, Examples, Error codes
- User Guide: Introduction, Task-based sections, Screenshots/diagrams, FAQs
- Tutorial: Learning objectives, Step-by-step instructions, Code samples, Validation
Content Generation Principles (Google Technical Writing Guide, accessed 2025-10-25T21:30:36-04:00)
- Use active voice and present tense
- Keep sentences ≤25 words
- Use concrete examples over abstract concepts
- Front-load important information
- Use bulleted lists for 3+ items
- Add code blocks with language identifiers
Accessibility Checks (WCAG 2.2 Level AA, accessed 2025-10-25T21:30:36-04:00)
- Headings in logical hierarchy (H1 → H2 → H3)
- Descriptive link text (no "click here")
- Alt text for images
- Color contrast sufficient (4.5:1 for text)
- No flashing content
Metadata Generation
- Generate frontmatter: title, description (≤160 chars), keywords, date
- Create navigation breadcrumbs if part of doc site
Output: Markdown/MDX document with frontmatter and accessibility-compliant structure.
Decision: If content_type == "api-doc" and OpenAPI spec provided → proceed to T2 for enhanced API documentation. Otherwise STOP at T1.
T2: API Documentation Enhancement (≤6k tokens)
Extended API documentation from OpenAPI specifications:
OpenAPI Parsing
- Parse OpenAPI 3.0.x or 3.1.x specification
- Extract endpoints, schemas, security schemes
- Validate spec completeness (descriptions, examples present)
Enhanced Documentation Sections (Docusaurus OpenAPI Docs, accessed 2025-10-25T21:30:36-04:00)
- Overview: API purpose, base URL, authentication methods
- Authentication: Security scheme details with examples
- Endpoints by Resource: Group by tags, show HTTP methods
- Request Details: Parameters (path/query/header/body), schemas, constraints
- Response Details: Status codes, response schemas, examples
- Error Handling: Common error codes and resolution steps
- Rate Limiting: If defined in spec
Code Sample Generation
- Generate request examples in 2-3 languages (curl, JavaScript, Python)
- Include authentication headers
- Use realistic sample data from OpenAPI examples
Interactive Features (for MDX output)
- Try-it-out component metadata
- Collapsible schema sections
- Tabbed code examples
Output: Comprehensive API documentation with code samples and interactive elements.
T3: Documentation Site Generation (not implemented in v1.0.0)
Reserved for:
- Full documentation site scaffolding (Docusaurus/MkDocs)
- Multi-version documentation management
- Search indexing and algolia integration
- Documentation analytics and feedback collection
Decision Rules
Content Type Detection:
- If source contains
openapi or swagger key → api-doc
- If source is directory with code files → technical-doc
- If source is plain text brief → user-guide or tutorial (ask user if ambiguous)
Abort Conditions:
- OpenAPI spec invalid or unparseable → error "Invalid OpenAPI specification"
- Source file not found → error "Source file not accessible"
- Unsupported OpenAPI version → error "Only OpenAPI 3.0.x and 3.1.x supported"
Accessibility Threshold:
- Score ≥90 → "Excellent accessibility"
- Score 70-89 → "Good accessibility, minor improvements suggested"
- Score <70 → Include remediation recommendations in output
Style Guide Conflicts:
- When style guides conflict, prefer: write-the-docs > google > microsoft
- Document style guide choice in frontmatter
Output Contract
Required fields:
documentation:
type: string
description: "Generated documentation content in requested format"
format: "markdown | mdx | html"
metadata:
type: object
required: [title, description, keywords, generated_at]
properties:
title:
type: string
maxLength: 60
description:
type: string
maxLength: 160
keywords:
type: array
items: {type: string}
maxItems: 10
generated_at:
type: string
format: date-time
style_guide:
type: string
enum: [microsoft, google, write-the-docs]
accessibility_score:
type: integer
minimum: 0
maximum: 100
description: "WCAG 2.2 Level AA compliance rating"
issues:
type: array
description: "Accessibility or style issues found (optional)"
items:
type: object
properties:
severity: {type: string, enum: [error, warning, info]}
message: {type: string}
line: {type: integer}
Examples
Input:
content_type: "api-doc"
source: "openapi-spec.yaml"
output_format: "markdown"
style_guide: "write-the-docs"
Output (abbreviated):
---
title: "User Management API"
description: "REST API for user authentication and profile management"
keywords: [api, users, authentication, rest]
generated_at: "2025-10-25T21:30:36-04:00"
style_guide: "write-the-docs"
---
# User Management API
Manage user accounts and authentication.
## Authentication
Bearer token required. Include in `Authorization` header.
## Endpoints
### POST /users/register
Create new user account.
**Request:**
```json
{"email": "user@example.com", "password": "***"}
Response (201):
{"id": "usr_123", "email": "user@example.com"}
---
## Quality Gates
**Token budgets (mandatory):**
- **T1 ≤ 2k tokens** — Standard doc generation (technical-doc, user-guide, tutorial)
- **T2 ≤ 6k tokens** — API documentation with OpenAPI parsing and code samples
- **T3 ≤ 12k tokens** — (Not implemented) Full site generation
**Safety:**
- No secrets in documentation examples
- Sanitize user-provided content
- No executable code in examples (documentation only)
**Auditability:**
- All style guide references cite specific sections with access dates
- Template choices logged in metadata
- Accessibility issues enumerated with severity
**Determinism:**
- Same input + style guide → same output structure
- Variation acceptable in generated examples (realistic data)
---
## Resources
**Style Guides:**
- [Write the Docs Guide](https://www.writethedocs.org/guide/) — Community best practices
- [Google Technical Writing Courses](https://developers.google.com/tech-writing) — Free courses on clarity
- [Microsoft Writing Style Guide](https://learn.microsoft.com/en-us/style-guide/welcome/) — Enterprise style guide
**Documentation Tools:**
- [Docusaurus](https://docusaurus.io/docs) — React-based doc site generator
- [MkDocs](https://www.mkdocs.org/) — Python-based static site generator
- [MkDocs Material](https://squidfunk.github.io/mkdocs-material/) — Material Design theme for MkDocs
**Accessibility:**
- [WCAG 2.2 Quick Reference](https://www.w3.org/WAI/WCAG22/quickref/) — Official guidelines
- [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/) — Color contrast validation
**OpenAPI:**
- [OpenAPI Specification](https://spec.openapis.org/oas/latest.html) — Official spec
- [Swagger Editor](https://editor.swagger.io/) — Online OpenAPI editor
**Templates:**
- See `resources/templates/` for reusable Markdown templates
- See `resources/schemas/` for JSON schemas
1---2name: content-documentation-generator3description: Generate technical documentation, API docs, and content with accessibility and SEO optimization.4license: MIT5---67## Purpose & When-To-Use89**Trigger conditions:**10- New feature requires documentation11- API endpoint needs OpenAPI-driven documentation12- User guide or tutorial creation needed13- Documentation refresh for clarity and accessibility14- Knowledge base article generation15- Migration from wiki/docs to structured documentation site1617**Not for:**18- Marketing copy or sales materials19- Legal documents or contracts20- Research papers or academic writing21- Long-form narrative content2223---2425## Pre-Checks2627**Time normalization:**28- Compute `NOW_ET` using NIST/time.gov semantics (America/New_York, ISO-8601)29- Use `NOW_ET` for all citation access dates3031**Input validation:**32- `content_type` must be one of: technical-doc, api-doc, user-guide, tutorial33- `source` must be valid (file exists, spec parseable, or non-empty string)34- `output_format` must be: markdown, mdx, or html35- `style_guide` must be: microsoft, google, or write-the-docs3637**Source freshness:**38- For API docs: verify OpenAPI spec version (3.0.x or 3.1.x supported)39- Style guide references accessible and current4041---4243## Procedure4445### T1: Standard Documentation Generation (≤2k tokens)4647**Fast path for 80% of documentation needs:**48491. **Content Analysis**50 - Detect content type from source or use provided `content_type`51 - Identify key sections needed (overview, quickstart, reference, examples)52532. **Template Selection** ([Write the Docs Structure Guide](https://www.writethedocs.org/guide/writing/beginners-guide-to-docs/), accessed 2025-10-25T21:30:36-04:00)54 - **Technical Doc:** Title, Purpose, Prerequisites, Steps, Troubleshooting, Next Steps55 - **API Doc:** Endpoint description, Request/Response schemas, Examples, Error codes56 - **User Guide:** Introduction, Task-based sections, Screenshots/diagrams, FAQs57 - **Tutorial:** Learning objectives, Step-by-step instructions, Code samples, Validation58593. **Content Generation Principles** ([Google Technical Writing Guide](https://developers.google.com/tech-writing/overview), accessed 2025-10-25T21:30:36-04:00)60 - Use active voice and present tense61 - Keep sentences ≤25 words62 - Use concrete examples over abstract concepts63 - Front-load important information64 - Use bulleted lists for 3+ items65 - Add code blocks with language identifiers66674. **Accessibility Checks** ([WCAG 2.2 Level AA](https://www.w3.org/WAI/WCAG22/quickref/), accessed 2025-10-25T21:30:36-04:00)68 - Headings in logical hierarchy (H1 → H2 → H3)69 - Descriptive link text (no "click here")70 - Alt text for images71 - Color contrast sufficient (4.5:1 for text)72 - No flashing content73745. **Metadata Generation**75 - Generate frontmatter: title, description (≤160 chars), keywords, date76 - Create navigation breadcrumbs if part of doc site7778**Output:** Markdown/MDX document with frontmatter and accessibility-compliant structure.7980**Decision:** If `content_type == "api-doc"` and OpenAPI spec provided → proceed to T2 for enhanced API documentation. Otherwise STOP at T1.8182---8384### T2: API Documentation Enhancement (≤6k tokens)8586**Extended API documentation from OpenAPI specifications:**87881. **OpenAPI Parsing**89 - Parse OpenAPI 3.0.x or 3.1.x specification90 - Extract endpoints, schemas, security schemes91 - Validate spec completeness (descriptions, examples present)92932. **Enhanced Documentation Sections** ([Docusaurus OpenAPI Docs](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs), accessed 2025-10-25T21:30:36-04:00)94 - **Overview:** API purpose, base URL, authentication methods95 - **Authentication:** Security scheme details with examples96 - **Endpoints by Resource:** Group by tags, show HTTP methods97 - **Request Details:** Parameters (path/query/header/body), schemas, constraints98 - **Response Details:** Status codes, response schemas, examples99 - **Error Handling:** Common error codes and resolution steps100 - **Rate Limiting:** If defined in spec1011023. **Code Sample Generation**103 - Generate request examples in 2-3 languages (curl, JavaScript, Python)104 - Include authentication headers105 - Use realistic sample data from OpenAPI examples1061074. **Interactive Features** (for MDX output)108 - Try-it-out component metadata109 - Collapsible schema sections110 - Tabbed code examples111112**Output:** Comprehensive API documentation with code samples and interactive elements.113114---115116### T3: Documentation Site Generation (not implemented in v1.0.0)117118Reserved for:119- Full documentation site scaffolding (Docusaurus/MkDocs)120- Multi-version documentation management121- Search indexing and algolia integration122- Documentation analytics and feedback collection123124---125126## Decision Rules127128**Content Type Detection:**129- If source contains `openapi` or `swagger` key → api-doc130- If source is directory with code files → technical-doc131- If source is plain text brief → user-guide or tutorial (ask user if ambiguous)132133**Abort Conditions:**134- OpenAPI spec invalid or unparseable → error "Invalid OpenAPI specification"135- Source file not found → error "Source file not accessible"136- Unsupported OpenAPI version → error "Only OpenAPI 3.0.x and 3.1.x supported"137138**Accessibility Threshold:**139- Score ≥90 → "Excellent accessibility"140- Score 70-89 → "Good accessibility, minor improvements suggested"141- Score <70 → Include remediation recommendations in output142143**Style Guide Conflicts:**144- When style guides conflict, prefer: write-the-docs > google > microsoft145- Document style guide choice in frontmatter146147---148149## Output Contract150151**Required fields:**152153```yaml154documentation:155 type: string156 description: "Generated documentation content in requested format"157 format: "markdown | mdx | html"158159metadata:160 type: object161 required: [title, description, keywords, generated_at]162 properties:163 title:164 type: string165 maxLength: 60166 description:167 type: string168 maxLength: 160169 keywords:170 type: array171 items: {type: string}172 maxItems: 10173 generated_at:174 type: string175 format: date-time176 style_guide:177 type: string178 enum: [microsoft, google, write-the-docs]179180accessibility_score:181 type: integer182 minimum: 0183 maximum: 100184 description: "WCAG 2.2 Level AA compliance rating"185186issues:187 type: array188 description: "Accessibility or style issues found (optional)"189 items:190 type: object191 properties:192 severity: {type: string, enum: [error, warning, info]}193 message: {type: string}194 line: {type: integer}195```196197---198199## Examples200201**Input:**202```yaml203content_type: "api-doc"204source: "openapi-spec.yaml"205output_format: "markdown"206style_guide: "write-the-docs"207```208209**Output (abbreviated):**210```markdown211---212title: "User Management API"213description: "REST API for user authentication and profile management"214keywords: [api, users, authentication, rest]215generated_at: "2025-10-25T21:30:36-04:00"216style_guide: "write-the-docs"217---218219# User Management API220221Manage user accounts and authentication.222223## Authentication224Bearer token required. Include in `Authorization` header.225226## Endpoints227228### POST /users/register229Create new user account.230231**Request:**232```json233{"email": "user@example.com", "password": "***"}234```235236**Response (201):**237```json238{"id": "usr_123", "email": "user@example.com"}239```240```241242---243244## Quality Gates245246**Token budgets (mandatory):**247- **T1 ≤ 2k tokens** — Standard doc generation (technical-doc, user-guide, tutorial)248- **T2 ≤ 6k tokens** — API documentation with OpenAPI parsing and code samples249- **T3 ≤ 12k tokens** — (Not implemented) Full site generation250251**Safety:**252- No secrets in documentation examples253- Sanitize user-provided content254- No executable code in examples (documentation only)255256**Auditability:**257- All style guide references cite specific sections with access dates258- Template choices logged in metadata259- Accessibility issues enumerated with severity260261**Determinism:**262- Same input + style guide → same output structure263- Variation acceptable in generated examples (realistic data)264265---266267## Resources268269**Style Guides:**270- [Write the Docs Guide](https://www.writethedocs.org/guide/) — Community best practices271- [Google Technical Writing Courses](https://developers.google.com/tech-writing) — Free courses on clarity272- [Microsoft Writing Style Guide](https://learn.microsoft.com/en-us/style-guide/welcome/) — Enterprise style guide273274**Documentation Tools:**275- [Docusaurus](https://docusaurus.io/docs) — React-based doc site generator276- [MkDocs](https://www.mkdocs.org/) — Python-based static site generator277- [MkDocs Material](https://squidfunk.github.io/mkdocs-material/) — Material Design theme for MkDocs278279**Accessibility:**280- [WCAG 2.2 Quick Reference](https://www.w3.org/WAI/WCAG22/quickref/) — Official guidelines281- [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/) — Color contrast validation282283**OpenAPI:**284- [OpenAPI Specification](https://spec.openapis.org/oas/latest.html) — Official spec285- [Swagger Editor](https://editor.swagger.io/) — Online OpenAPI editor286287**Templates:**288- See `resources/templates/` for reusable Markdown templates289- See `resources/schemas/` for JSON schemas