Skip to main content
command

generate-api-documentation — Claude Code command: how to install

Scans source code for endpoint annotations and builds API documentation. Supports Swagger UI, Redoc, Postman collections, and automated CI/CD steps.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --command documentation/generate-api-documentation
Open on GitHub

What generate-api-documentation does

The command inspects your codebase for docstrings like @api, @swagger, or @doc. It reads package.json to detect the underlying framework, then locates existing YAML or JSON specification files. After that, Claude Code sets up documentation renderers such as Swagger UI, Redoc, or Postman.

The workflow proceeds through ten structured milestones. The agent drafts request and response schemas, writes endpoint examples, and prepares .github/workflows/ automation. It can export references into HTML, Markdown, or PDF.

Bash execution permissions are mandatory. Without shell access for grep and find, Claude Code cannot inspect existing code annotations automatically.

What it helps with

  • scan codebases for API annotations and endpoints
  • build OpenAPI and Swagger specifications from source code
  • render interactive docs using Redoc or Swagger UI
  • export request collections for Postman and Insomnia
  • integrate documentation builds into CI/CD workflows

Example prompts for the agent

  • Generate Swagger UI docs for our endpoints: /generate-api-documentation --swagger-ui
  • Set up a Redoc documentation site: /generate-api-documentation --redoc
  • Export API references in multiple formats: /generate-api-documentation --multi-format

How to install generate-api-documentation

1claude-code-templates

npx claude-code-templates@latest --command documentation/generate-api-documentation

2Manually: put the files in place

.claude/commands/generate-api-documentation.md

Call it with /generate-api-documentation. For all projects use ~/.claude/commands/

Questions about generate-api-documentation

How to install generate-api-documentation in Claude Code?

Run npx claude-code-templates@latest --command documentation/generate-api-documentation. The command file will be saved to .claude/commands/generate-api-documentation.md.

What documentation formats does the command support?

It supports Swagger UI, Redoc, Postman collections, Insomnia workspaces, API Blueprint, and GraphQL documentation tools.

Which tools must Claude Code be granted to run this command?

The command requires Read, Write, Edit, and Bash. Terminal access is needed to find existing specs and annotations with grep and find.

Source text

generate-api-documentation.md · MIT
---
allowed-tools: Read, Write, Edit, Bash
argument-hint: "[output-format] | --swagger-ui | --redoc | --postman | --insomnia | --multi-format"
description: Auto-generate API reference documentation with multiple output formats and automated deployment
---

# Automated API Documentation Generator

Auto-generate API reference documentation: $ARGUMENTS

## Current API Infrastructure

- Code annotations: !`grep -r "@api\|@swagger\|@doc" src/ 2>/dev/null | wc -l` annotations found
- API framework: @package.json or detect from imports
- Existing specs: !`find . -name "*spec*.yaml" -o -name "*spec*.json" | head -3`
- Documentation tools: !`grep -E "swagger|redoc|postman" package.json 2>/dev/null || echo "None detected"`
- CI/CD pipeline: @.github/workflows/ (if exists)

## Task

Setup automated API documentation generation with modern tooling:

1. **API Documentation Strategy Analysis**
   - Analyze current API structure and endpoints
   - Identify documentation requirements (REST, GraphQL, gRPC, etc.)
   - Assess existing code annotations and documentation
   - Determine documentation output formats and hosting requirements
   - Plan documentation automation and maintenance strategy

2. **Documentation Tool Selection**
   - Choose appropriate API documentation tools:
     - **OpenAPI/Swagger**: REST API documentation with Swagger UI
     - **Redoc**: Modern OpenAPI documentation renderer
     - **GraphQL**: GraphiQL, Apollo Studio, GraphQL Playground
     - **Postman**: API documentation with collections
     - **Insomnia**: API documentation and testing
     - **API Blueprint**: Markdown-based API documentation
     - **JSDoc/TSDoc**: Code-first documentation generation
   - Consider factors: API type, team workflow, hosting, interactivity

3. **Code Annotation and Schema Definition**
   - Add comprehensive code annotations for API endpoints
   - Define request/response schemas and data models
   - Add parameter descriptions and validation rules
   - Document authentication and authorization requirements
   - Add example requests and responses

4. **API Specification Generation**
   - Set up automated API specification generation from code
   - Configure OpenAPI/Swagger specification generation
   - Set up schema validation and consistency checking
   - Configure API versioning and changelog generation
   - Set up specification file management and version control

5. **Interactive Documentation Setup**
   - Configure interactive API documentation with try-it-out functionality
   - Set up API testing and example execution
   - Configure authentication handling in documentation
   - Set up request/response validation and examples
   - Configure API endpoint categorization and organization

6. **Documentation Content Enhancement**
   - Add comprehensive API guides and tutorials
   - Create authentication and authorization documentation
   - Add error handling and status code documentation
   - Create SDK and client library documentation
   - Add rate limiting and usage guidelines

7. **Documentation Hosting and Deployment**
   - Set up documentation hosting and deployment
   - Configure documentation website generation and styling
   - Set up custom domain and SSL configuration
   - Configure documentation search and navigation
   - Set up documentation analytics and usage tracking

8. **Automation and CI/CD Integration**
   - Configure automated documentation generation in CI/CD pipeline
   - Set up documentation deployment automation
   - Configure documentation validation and quality checks
   - Set up documentation change detection and notifications
   - Configure documentation testing and link validation

9. **Multi-format Documentation Generation**
   - Generate documentation in multiple formats (HTML, PDF, Markdown)
   - Set up downloadable documentation packages
   - Configure offline documentation access
   - Set up documentation API for programmatic access
   - Configure documentation syndication and distribution

10. **Maintenance and Quality Assurance**
    - Set up documentation quality monitoring and validation
    - Configure documentation feedback and improvement workflows
    - Set up documentation analytics and usage metrics
    - Create documentation maintenance procedures and guidelines
    - Train team on documentation best practices and tools
    - Set up documentation review and approval processes

© davila7 · MIT · davila7/claude-code-templates

Similar slash commands

All slash commands for Writing and docs →

From the same set238

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor