No. 086 Write it down
API Documenter
Use when someone who was not in the session has to understand the result
- Claude Code
- Codex
- Cursor
- Write it down
# API Documenter
Please help me document all APIs in this codebase systematically:
## 1. API Discovery
Find all API endpoints using these search patterns:
### Express/Node.js
```bash
chs find-code "app\.(get\|post\|put\|delete\|patch)\|router\.(get\|post\|put\|delete\|patch)"
chs find-file "*route*\|*api*\|*controller*"
```
### Decorators (NestJS, TypeScript)
```bash
chs find-code "@(Get\|Post\|Put\|Delete\|Patch)\|@Controller\|@Route"
```
### Other Frameworks
```bash
# Python (FastAPI, Flask, Django)
chs find-code "@app\.(get\|post\|put\|delete)\|@router\|@route"
chs find-code "path\(\|urlpatterns\s*=\|views\."
# Rails/Ruby
chs find-code "resources\s\|get\s['\"]\/\|post\s['\"]\/\|match\s['\"]\/"
# Java/Spring
chs find-code "@(Get\|Post\|Put\|Delete\|Request)Mapping\|@RestController"
# Go
chs find-code "HandleFunc\|Handle\(.*\"\/"
```
## 2. Document Each Endpoint
For every endpoint found, document:
### Endpoint Details
- **Method**: GET, POST, PUT, DELETE, PATCH
- **Path**: Full URL path with parameters
- **Description**: What this endpoint does
- **Authentication**: Required? Type?
### Request
- **Parameters**: Query params, URL params
- **Body**: Expected JSON/form data structure
- **Headers**: Required headers
### Response
- **Success Response**: Status code and body structure
- **Error Responses**: Common error codes and meanings
- **Response Headers**: Any special headers
### Example
```bash
# Generate curl example
curl -X METHOD 'http://localhost:3000/path' \
-H 'Content-Type: application/json' \
-d '{"example": "data"}'
```
## 3. Generate Documentation Formats
### README.md Format
Create organized sections by resource:
- User endpoints
- Authentication endpoints
- Product endpoints
- etc.
### OpenAPI/Swagger Format
If applicable, generate OpenAPI spec:
```yaml
paths:
/users:
get:
summary: List users
responses:
200:
description: Success
```
### Postman Collection
Create importable collection with all endpoints
## 4. Validation Checklist
- [ ] All endpoints discovered are documented
- [ ] Authentication requirements clear
- [ ] Request/response examples provided
- [ ] Error cases documented
- [ ] Rate limiting noted
- [ ] CORS settings documented
## 5. Auto-generate Examples
Use actual code to create realistic examples:
- Find test files: `chs find-file "*.test.*" | xargs grep -l "request\|fetch"`
- Extract real API calls from tests
- Use as documentation examples
Create a comprehensive API reference that developers can immediately use!
When to use
“API Documenter” fits when someone who was not in the session has to understand the result, because it says “API Documenter”, and that published sentence is the whole assignment.
Send “API Documenter” as the turn itself: API Documenter
When not to use
Leave “API Documenter” unused when the file's behavior is wrong and a paragraph would hide that, because “API Documenter” points the other way
How to run it
Claude Code
Claude Code stores “API Documenter” as a Claude command and runs it with that command, putting the requirement in the argument, and CLAUDE.md should not also carry “API Documenter”.
Codex
Codex takes “API Documenter” as a paste above the task. Leave AGENTS.md unchanged so the next thread does not inherit “API Documenter”.
Cursor
Cursor should see “API Documenter” only as a chat paste of “API Documenter” for this turn. A file at .cursor/rules would keep applying after the turn ends.
Comparison
对比待补
This before-and-after was not run on this machine.
Related
- Stage: Write it down
- Same stage: Developer Diary Entry
来源:Darin Cassler · https://github.com/cassler/awesome-claude-code-setup/blob/main/commands/api-documenter.md · MIT · Copyright (c) 2025 Darin Cassler · 2026-12-01