api-documenter — Claude Code skill: OpenAPI docs that hold up
A skill for writing REST and GraphQL API documentation as OpenAPI/Swagger specs. Useful when scattered endpoints need to become one readable file.
npx skills add zhaono1/agent-playbook --skill api-documenter -a claude-codeWhat api-documenter does
The skill activates when you ask to document an API, create an OpenAPI/Swagger spec, or mention API docs. It gets Read, Write, Edit, Bash, Grep and Glob, so it can read your code, find handlers and write the spec file.
Inside you get the OpenAPI 3.0.3 layout, the fields each endpoint needs (summary, operationId, tags, responses), rules for shared schemas with $ref, string formats like uuid and date-time, security and securitySchemes blocks for bearer auth, plus a standard error schema and the common HTTP status codes. Two scripts ship with it: python3 scripts/generate_openapi.py --name <resource-name> --output openapi.yaml builds a spec from code, and python3 scripts/validate_openapi.py --input openapi.yaml checks one. Running them needs Python 3.
When the work finishes, the skill fires a session-logger hook in auto mode to record documentation activity. A starter spec sits in references/openapi-template.yaml, examples in references/examples/. If your project already generates specs some other way, both tools will write files — decide which one owns openapi.yaml before you run this.
What it helps with
- build an OpenAPI spec from existing route handlers
- document parameters and responses for every endpoint
- move shared schemas into
componentsand link them with$ref - describe bearer auth and error codes in the spec
- validate an
openapi.yamlbefore publishing it
Example prompts for the agent
- document the REST API in this project and produce an OpenAPI spec
- generate
openapi.yamlfor the users resource - validate
openapi.yamland list the missing descriptions
How to install api-documenter
1Skills CLI (Vercel)
npx skills add zhaono1/agent-playbook --skill api-documenter -a claude-code2Manually: put the files in place
~/.claude/skills/api-documenter/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/api-documenter/
1Skills CLI (Vercel)
npx skills add zhaono1/agent-playbook --skill api-documenter -a codex2Manually: put the files in place
.agents/skills/api-documenter/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add zhaono1/agent-playbook --skill api-documenter -a cursor2Manually: put the files in place
.cursor/skills/api-documenter/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install zhaono1/agent-playbook api-documenter2Manually: put the files in place
.github/skills/api-documenter/SKILL.md1Skills CLI (Vercel)
npx skills add zhaono1/agent-playbook --skill api-documenter -a gemini-cli2Platform CLI
gemini skills install https://github.com/zhaono1/agent-playbook --path skills/api-documenterManually: put the files in place
.devin/skills/api-documenter/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add zhaono1/agent-playbook --skill api-documenter -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about api-documenter
How do I install api-documenter in Claude?
Run npx skills add zhaono1/agent-playbook --skill api-documenter -a claude-code. The skill lands at ~/.claude/skills/api-documenter/SKILL.md.
What does api-documenter do?
It helps write REST and GraphQL API docs as OpenAPI/Swagger specs: spec structure, schemas, auth, errors. It also ships two scripts for generating and validating openapi.yaml.
Which tools can the skill use?
Read, Write, Edit, Bash, Grep and Glob. That is enough to read project code, locate endpoints and write the spec.
Source text
SKILL.md · MIT
---
name: api-documenter
description: API documentation specialist for OpenAPI/Swagger specifications. Use when documenting REST or GraphQL APIs.
allowed-tools: Read, Write, Edit, Bash, Grep, Glob
metadata:
hooks:
after_complete:
- trigger: session-logger
mode: auto
reason: "Log documentation activity"
---
# API Documenter
Specialist in creating comprehensive API documentation using OpenAPI/Swagger specifications.
## When This Skill Activates
Activates when you:
- Ask to document an API
- Create OpenAPI/Swagger specs
- Need API reference documentation
- Mention "API docs"
## OpenAPI Specification Structure
```yaml
openapi: 3.0.3
info:
title: API Title
version: 1.0.0
description: API description
servers:
- url: https://example.com/api/v1
paths:
/users:
get:
summary: List users
operationId: listUsers
tags:
- users
parameters: []
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
properties:
id:
type: string
name:
type: string
```
## Endpoint Documentation
For each endpoint, document:
### Required Fields
- **summary**: Brief description
- **operationId**: Unique identifier
- **description**: Detailed explanation
- **tags**: For grouping
- **responses**: All possible responses
### Recommended Fields
- **parameters**: All parameters with details
- **requestBody**: For POST/PUT/PATCH
- **security**: Authentication requirements
- **deprecated**: If applicable
### Example
```yaml
/users/{id}:
get:
summary: Get a user by ID
operationId: getUserById
description: Retrieves a single user by their unique identifier
tags:
- users
parameters:
- name: id
in: path
required: true
schema:
type: string
description: The user ID
responses:
'200':
description: User found
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'404':
description: User not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
```
## Schema Documentation
### Best Practices
1. **Use references** for shared schemas
2. **Add descriptions** to all properties
3. **Specify format** for strings (email, uuid, date-time)
4. **Add examples** for complex schemas
5. **Mark required fields**
### Example
```yaml
components:
schemas:
User:
type: object
required:
- id
- email
properties:
id:
type: string
format: uuid
description: Unique user identifier
example: "550e8400-e29b-41d4-a716-446655440000"
email:
type: string
format: email
description: User's email address
example: "[email protected]"
createdAt:
type: string
format: date-time
description: Account creation timestamp
```
## Authentication Documentation
Document auth requirements:
```yaml
security:
- bearerAuth: []
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: Use your JWT token from /auth/login
```
## Error Responses
Standard error format:
```yaml
components:
schemas:
Error:
type: object
properties:
error:
type: string
description: Error message
code:
type: string
description: Application-specific error code
details:
type: object
description: Additional error details
```
Common HTTP status codes:
- **200**: Success
- **201**: Created
- **204**: No Content
- **400**: Bad Request
- **401**: Unauthorized
- **403**: Forbidden
- **404**: Not Found
- **409**: Conflict
- **422**: Unprocessable Entity
- **500**: Internal Server Error
## Scripts
Generate OpenAPI spec from code:
```bash
python3 scripts/generate_openapi.py --name <resource-name> --output openapi.yaml
```
Validate OpenAPI spec:
```bash
python3 scripts/validate_openapi.py --input openapi.yaml
```
## References
- `references/openapi-template.yaml` - OpenAPI template
- `references/examples/` - API documentation examples
- [OpenAPI Specification](https://swagger.io/specification/)
© zhaono1 · MIT · zhaono1/agent-playbook