backend-api-documenter
4
总安装量
4
周安装量
#49183
全站排名
安装命令
npx skills add https://github.com/realroc/skills --skill backend-api-documenter
Agent 安装分布
opencode
4
gemini-cli
4
github-copilot
4
codex
4
amp
4
kimi-cli
4
Skill 文档
Backend API Documenter
Generate comprehensive backend API documentation by reading FastAPI route files and schema definitions, then creating detailed specifications in backend/AGENTS.md.
Core Workflow
1. Scan API Structure
Read all backend API route files to identify:
- API modules and their base paths
- All endpoints (GET, POST, PUT, PATCH, DELETE)
- Route decorators and parameters
- Summary and description annotations
Key files to read:
backend/app/api/v1/*.py– All API route filesbackend/app/schemas/*.py– Request/response schema definitionsbackend/CLAUDE.md– Backend-specific specifications (if exists)
Optional helper script:
python3 scripts/scan_api_routes.py ./backend
2. Extract Endpoint Details
For each endpoint, extract:
- HTTP method and path
- Request headers (Authorization, X-API-Key, etc.)
- Request body schema (from Pydantic models)
- Response body schema
- Query parameters
- Path parameters
- Error responses and status codes
- Business rules from docstrings and code logic
3. Organize Documentation
Structure documentation following this hierarchy:
1. Module Overview
Baseè·¯å¾: /api/v1/module
1.1 Endpoint Name
- æ¥å£ (Interface)
- æè¿° (Description)
- 请æ±å¤´ (Request Headers)
- 请æ±ä½ (Request Body) with field descriptions
- ååºä½ (Response Body) with field descriptions
- é误ååº (Error Responses)
- æéè¦æ± (Authorization)
- ä¸å¡è§å (Business Rules)
4. Include Standard Appendices
Always include these appendices at the end:
- éå½A: ç»ä¸ååºæ ¼å¼ – Standard response format and business codes
- éå½B: å½é åæ¯æ – i18n headers and locale handling
- éå½C: è®¤è¯æ¹å¼ – JWT Token and API Key authentication
- éå½D: é误å¤çæä½³å®è·µ – Client-side error handling patterns
See doc_template.md for complete template structure.
5. Write Documentation
Write the complete documentation to backend/AGENTS.md:
- Start with project context inheritance:
> **Inherits from**: [Root AGENTS.md](../AGENTS.md) - Include table of contents with anchor links
- Use consistent formatting (Chinese labels, English technical terms)
- Provide concrete JSON examples for all requests/responses
- Document all field types, constraints, and validation rules
- Include business logic and special cases
Field Description Best Practices
For every field in request/response schemas, document:
- Name and type:
field_name(string, int, float, bool, array, object) - Required/Optional: Always specify
- Constraints: Length limits, value ranges, formats, enums
- Description: What it represents and how it’s used
- Examples: Concrete values when helpful
Example:
- `email` (string, optional): User email address, must be valid email format, max 255 characters
- `reward_amount` (float, required): Task reward amount, must be > 0, max 100000
- `status` (string, required): Task status, possible values: published/in_progress/completed/expired
- `location` (object, optional): GeoJSON Point format with coordinates [longitude, latitude]
Common Patterns
Authentication Documentation
**请æ±å¤´**:
Authorization: Bearer {access_token}
æ
X-API-Key: {api_key}
**æéè¦æ±**: éè¦äººç±»ç¨æ·è®¤è¯(JWT Token) æ éè¦ä»£ç认è¯(API Key)
Error Response Documentation
**é误ååº**:
éªè¯å¤±è´¥(400):
```json
{
"success": false,
"code": "INVALID_INPUT",
"message": "è¾å
¥åæ°æ æ",
"data": null
}
æªææ(401):
{
"success": false,
"code": "UNAUTHORIZED",
"message": "æªææ",
"data": null
}
### Business Rules Documentation
```markdown
**ä¸å¡è§å**:
- åªæä»»å¡ææè
å¯ä»¥æ´æ°
- åå»ºä»»å¡æ¶ä¼éå®ç¸åºéé¢
- ä»»å¡åå¸åç«å³å¯è§
- è¯åèå´: 1.0-5.0
Documentation Quality Standards
- Completeness: Document every field in every request/response
- Accuracy: Match actual code behavior, not ideal behavior
- Clarity: Use clear, concise language with concrete examples
- Consistency: Follow same format for all endpoints
- Bilingual: Chinese labels with English technical terms
- Currency: Keep documentation in sync with code changes
Notes
- This skill generates documentation for FastAPI-based backends
- Assumes Pydantic models for request/response schemas
- Follows unified response format with success/code/message/data structure
- Supports both JWT Token (human users) and API Key (agents) authentication
- Documentation should be comprehensive but concise – include all necessary details without redundancy