generate-api-documentation — команда для Claude Code: обзор
Анализирует код эндпоинтов, находит аннотации и генерирует спецификации OpenAPI, Swagger UI или Redoc. Помогает настроить сборку документации API и шаги в CI/CD.
npx claude-code-templates@latest --command documentation/generate-api-documentationЧто делает generate-api-documentation
Команда проверяет кодовую базу на наличие аннотаций вроде @api, @swagger или @doc, а также ищет существующие файлы спецификаций YAML и JSON. Затем Claude Code определяет фреймворк через package.json и предлагает подходящий инструмент: Swagger UI, Redoc, Postman или Insomnia.
Процесс разбит на десять этапов. Агент размечает схемы запросов и ответов, добавляет примеры вызовов и настраивает шаги генерации в .github/workflows/. Документацию можно собрать сразу в нескольких форматах, например в HTML или Markdown.
Команде обязательно нужны разрешения Bash, Read, Write и Edit. Без доступа к терминалу агент не сможет запустить поиск файлов через grep и find.
Какие задачи решает
- найти эндпоинты и служебные аннотации в коде проекта
- сгенерировать спецификации OpenAPI и Swagger из исходников
- развернуть интерактивную документацию на Redoc или Swagger UI
- подготовить коллекции запросов для Postman и Insomnia
- встроить автоматическую сборку документации в CI/CD
Примеры запросов агенту
- Сгенерируй интерактивную документацию Swagger UI для REST API:
/generate-api-documentation --swagger-ui - Собери документацию для эндпоинтов в формате Redoc:
/generate-api-documentation --redoc - Экспортируй спецификации API сразу в нескольких форматах:
/generate-api-documentation --multi-format
Как установить generate-api-documentation
1Через claude-code-templates
npx claude-code-templates@latest --command documentation/generate-api-documentation2Вручную: положить файлы
.claude/commands/generate-api-documentation.mdВызов — /generate-api-documentation. Для всех проектов — ~/.claude/commands/
Вручную: положить файлы
~/.codex/prompts/generate-api-documentation.mdВызов — /prompts:generate-api-documentation. В Codex этот формат помечен устаревшим, замена — скиллы
Вручную: положить файлы
.github/prompts/generate-api-documentation.prompt.mdВручную: положить файлы
.gemini/commands/generate-api-documentation.tomlGemini хранит команды в TOML: текст запроса — в поле prompt
Вопросы о generate-api-documentation
Как установить generate-api-documentation в Claude Code?
Выполните команду npx claude-code-templates@latest --command documentation/generate-api-documentation. Шаблон запишется в файл .claude/commands/generate-api-documentation.md.
Какие форматы документации поддерживает команда?
Команда настраивает спецификации OpenAPI, интерфейсы Swagger UI и Redoc, коллекции Postman и Insomnia, а также схемы для GraphQL.
Какие инструменты нужны Claude Code для запуска команды?
В конфигурации команды указаны инструменты Read, Write, Edit и Bash. Терминал необходим для сканирования аннотаций утилитами grep и find.
Исходный текст
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