@codeharbor/agent-playbook 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/package.json +5 -2
- package/skills/api-designer/README.md +36 -0
- package/skills/api-designer/SKILL.md +232 -0
- package/skills/api-designer/references/graphql-patterns.md +12 -0
- package/skills/api-designer/references/rest-patterns.md +17 -0
- package/skills/api-designer/scripts/generate_api.py +87 -0
- package/skills/api-designer/scripts/validate_api.py +48 -0
- package/skills/api-documenter/README.md +41 -0
- package/skills/api-documenter/SKILL.md +209 -0
- package/skills/api-documenter/references/examples/README.md +3 -0
- package/skills/api-documenter/references/examples/openapi-example.yaml +10 -0
- package/skills/api-documenter/references/openapi-template.yaml +5 -0
- package/skills/api-documenter/scripts/generate_openapi.py +84 -0
- package/skills/api-documenter/scripts/validate_openapi.py +45 -0
- package/skills/architecting-solutions/README.md +22 -0
- package/skills/architecting-solutions/SKILL.md +459 -0
- package/skills/auto-trigger/README.md +23 -0
- package/skills/auto-trigger/SKILL.md +183 -0
- package/skills/code-reviewer/README.md +59 -0
- package/skills/code-reviewer/SKILL.md +220 -0
- package/skills/code-reviewer/references/checklist.md +80 -0
- package/skills/code-reviewer/references/patterns.md +226 -0
- package/skills/code-reviewer/references/security.md +88 -0
- package/skills/code-reviewer/scripts/review_checklist.py +191 -0
- package/skills/commit-helper/README.md +58 -0
- package/skills/commit-helper/SKILL.md +159 -0
- package/skills/commit-helper/references/conventional-commits.md +68 -0
- package/skills/commit-helper/references/examples.md +125 -0
- package/skills/commit-helper/references/scopes.md +49 -0
- package/skills/commit-helper/scripts/validate_commit.py +70 -0
- package/skills/create-pr/README.md +182 -0
- package/skills/create-pr/SKILL.md +340 -0
- package/skills/debugger/README.md +53 -0
- package/skills/debugger/SKILL.md +239 -0
- package/skills/debugger/references/checklist.md +7 -0
- package/skills/debugger/references/errors.md +6 -0
- package/skills/debugger/references/patterns.md +5 -0
- package/skills/debugger/scripts/debug_report.py +77 -0
- package/skills/deployment-engineer/README.md +40 -0
- package/skills/deployment-engineer/SKILL.md +242 -0
- package/skills/deployment-engineer/references/kubernetes.md +23 -0
- package/skills/deployment-engineer/references/monitoring.md +14 -0
- package/skills/deployment-engineer/references/pipelines.md +12 -0
- package/skills/deployment-engineer/scripts/generate_deploy.py +72 -0
- package/skills/deployment-engineer/scripts/validate_deploy.py +46 -0
- package/skills/documentation-engineer/README.md +41 -0
- package/skills/documentation-engineer/SKILL.md +164 -0
- package/skills/documentation-engineer/references/api-template.md +22 -0
- package/skills/documentation-engineer/references/readme-template.md +25 -0
- package/skills/documentation-engineer/references/style-guide.md +13 -0
- package/skills/documentation-engineer/scripts/generate_docs.py +68 -0
- package/skills/documentation-engineer/scripts/validate_docs.py +46 -0
- package/skills/figma-designer/README.md +222 -0
- package/skills/figma-designer/SKILL.md +407 -0
- package/skills/figma-designer/references/example-output.md +86 -0
- package/skills/performance-engineer/README.md +42 -0
- package/skills/performance-engineer/SKILL.md +236 -0
- package/skills/performance-engineer/references/checklist.md +6 -0
- package/skills/performance-engineer/references/monitoring.md +5 -0
- package/skills/performance-engineer/references/optimization.md +7 -0
- package/skills/performance-engineer/scripts/perf_report.py +64 -0
- package/skills/performance-engineer/scripts/profile.py +63 -0
- package/skills/planning-with-files/README.md +27 -0
- package/skills/planning-with-files/SKILL.md +103 -0
- package/skills/prd-implementation-precheck/README.md +97 -0
- package/skills/prd-implementation-precheck/SKILL.md +112 -0
- package/skills/prd-planner/README.md +102 -0
- package/skills/prd-planner/SKILL.md +449 -0
- package/skills/prd-planner/references/edge-case-analysis.md +111 -0
- package/skills/qa-expert/README.md +37 -0
- package/skills/qa-expert/SKILL.md +225 -0
- package/skills/qa-expert/references/gates.md +11 -0
- package/skills/qa-expert/references/metrics.md +6 -0
- package/skills/qa-expert/references/strategy.md +11 -0
- package/skills/qa-expert/scripts/coverage_analysis.py +61 -0
- package/skills/qa-expert/scripts/generate_test_plan.py +68 -0
- package/skills/refactoring-specialist/README.md +37 -0
- package/skills/refactoring-specialist/SKILL.md +283 -0
- package/skills/refactoring-specialist/references/checklist.md +6 -0
- package/skills/refactoring-specialist/references/smells.md +6 -0
- package/skills/refactoring-specialist/references/techniques.md +6 -0
- package/skills/security-auditor/README.md +48 -0
- package/skills/security-auditor/SKILL.md +256 -0
- package/skills/security-auditor/references/checklist.md +7 -0
- package/skills/security-auditor/references/owasp.md +12 -0
- package/skills/security-auditor/references/remediation.md +7 -0
- package/skills/security-auditor/scripts/find_secrets.py +58 -0
- package/skills/security-auditor/scripts/security_audit.py +64 -0
- package/skills/self-improving-agent/README.md +136 -0
- package/skills/self-improving-agent/SKILL.md +407 -0
- package/skills/self-improving-agent/hooks/post-bash.sh +10 -0
- package/skills/self-improving-agent/hooks/pre-tool.sh +10 -0
- package/skills/self-improving-agent/hooks/session-end.sh +4 -0
- package/skills/self-improving-agent/memory/semantic-patterns.json +288 -0
- package/skills/self-improving-agent/references/appendix.md +131 -0
- package/skills/self-improving-agent/templates/correction-template.md +11 -0
- package/skills/self-improving-agent/templates/pattern-template.md +15 -0
- package/skills/self-improving-agent/templates/validation-template.md +14 -0
- package/skills/session-logger/README.md +50 -0
- package/skills/session-logger/SKILL.md +156 -0
- package/skills/skill-router/README.md +155 -0
- package/skills/skill-router/SKILL.md +215 -0
- package/skills/test-automator/README.md +41 -0
- package/skills/test-automator/SKILL.md +202 -0
- package/skills/test-automator/references/best-practices.md +6 -0
- package/skills/test-automator/references/examples/README.md +3 -0
- package/skills/test-automator/references/examples/unit-test-example.md +8 -0
- package/skills/test-automator/references/mocking.md +5 -0
- package/skills/test-automator/scripts/coverage_report.py +59 -0
- package/skills/test-automator/scripts/generate_test.py +66 -0
- package/skills/workflow-orchestrator/README.md +20 -0
- package/skills/workflow-orchestrator/SKILL.md +342 -0
- package/src/cli.js +107 -20
package/README.md
CHANGED
|
@@ -23,16 +23,18 @@ pnpm dlx @codeharbor/agent-playbook init --project
|
|
|
23
23
|
- Records a metadata block in `~/.codex/config.toml`.
|
|
24
24
|
|
|
25
25
|
## Commands
|
|
26
|
-
- `agent-playbook init [--project] [--copy] [--hooks] [--no-hooks] [--session-dir <path>] [--dry-run] [--repo <path>]`
|
|
26
|
+
- `agent-playbook init [--project] [--copy] [--overwrite] [--hooks] [--no-hooks] [--session-dir <path>] [--dry-run] [--repo <path>]`
|
|
27
27
|
- `agent-playbook status`
|
|
28
28
|
- `agent-playbook doctor`
|
|
29
|
-
- `agent-playbook repair`
|
|
29
|
+
- `agent-playbook repair [--overwrite]`
|
|
30
30
|
- `agent-playbook uninstall`
|
|
31
31
|
- `agent-playbook session-log [--session-dir <path>]`
|
|
32
32
|
- `agent-playbook self-improve`
|
|
33
33
|
|
|
34
34
|
## Notes
|
|
35
35
|
- Default session logs go to repo `sessions/` if a Git root is found; otherwise `~/.claude/sessions/`.
|
|
36
|
+
- If skill folders already exist, you will be prompted before overwriting. Use `--overwrite` to skip the prompt.
|
|
37
|
+
- Session logs and self-improve entries record the agent-playbook version.
|
|
36
38
|
- Hooks are merged without overwriting existing user hooks.
|
|
37
39
|
- Requires Node.js 18+.
|
|
38
40
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeharbor/agent-playbook",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "One-click installer and workflow fixer for agent-playbook across Claude Code and Codex.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "node --test test/*.test.js",
|
|
12
|
-
"lint": "node -c src/cli.js"
|
|
12
|
+
"lint": "node -c src/cli.js",
|
|
13
|
+
"prepack": "node scripts/sync-skills.js copy",
|
|
14
|
+
"postpack": "node scripts/sync-skills.js clean"
|
|
13
15
|
},
|
|
14
16
|
"files": [
|
|
15
17
|
"bin",
|
|
16
18
|
"src",
|
|
19
|
+
"skills",
|
|
17
20
|
"templates",
|
|
18
21
|
"README.md",
|
|
19
22
|
"LICENSE"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# API Designer
|
|
2
|
+
|
|
3
|
+
> A Claude Code skill for REST and GraphQL API design.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This skill is part of the [agent-playbook](https://github.com/Charon-Fan/agent-playbook) collection.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
You: Design an API for user management
|
|
13
|
+
You: Create API specification
|
|
14
|
+
You: Review this API design
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## API Design Principles
|
|
18
|
+
|
|
19
|
+
1. **Resource-Oriented**: Nouns, not verbs
|
|
20
|
+
2. **Consistent Naming**: kebab-case for URLs
|
|
21
|
+
3. **Proper HTTP Methods**: GET, POST, PUT, DELETE
|
|
22
|
+
4. **Status Codes**: Correct HTTP status codes
|
|
23
|
+
5. **Versioning**: Plan for API evolution
|
|
24
|
+
|
|
25
|
+
## Scripts
|
|
26
|
+
|
|
27
|
+
Generate API scaffold:
|
|
28
|
+
```bash
|
|
29
|
+
python scripts/generate_api.py <resource-name>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Resources
|
|
33
|
+
|
|
34
|
+
- [REST API Tutorial](https://restfulapi.net/)
|
|
35
|
+
- [GraphQL Best Practices](https://graphql.org/learn/best-practices/)
|
|
36
|
+
- [API Design Guidelines](https://github.com/microsoft/api-guidelines)
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-designer
|
|
3
|
+
description: REST and GraphQL API architect for designing robust, scalable APIs. Use when designing new APIs or improving existing ones.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Bash, Grep, Glob, WebFetch, WebSearch
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# API Designer
|
|
8
|
+
|
|
9
|
+
Expert in designing REST and GraphQL APIs that are robust, scalable, and maintainable.
|
|
10
|
+
|
|
11
|
+
## When This Skill Activates
|
|
12
|
+
|
|
13
|
+
Activates when you:
|
|
14
|
+
- Design a new API
|
|
15
|
+
- Review API design
|
|
16
|
+
- Improve existing API
|
|
17
|
+
- Create API specifications
|
|
18
|
+
|
|
19
|
+
## REST API Design Principles
|
|
20
|
+
|
|
21
|
+
### 1. Resource-Oriented Design
|
|
22
|
+
|
|
23
|
+
**Good:**
|
|
24
|
+
```
|
|
25
|
+
GET /users # List users
|
|
26
|
+
POST /users # Create user
|
|
27
|
+
GET /users/{id} # Get specific user
|
|
28
|
+
PATCH /users/{id} # Update user
|
|
29
|
+
DELETE /users/{id} # Delete user
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Avoid:**
|
|
33
|
+
```
|
|
34
|
+
POST /getUsers # Should be GET
|
|
35
|
+
POST /users/create # Redundant
|
|
36
|
+
GET /users/get/{id} # Redundant
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. HTTP Methods
|
|
40
|
+
|
|
41
|
+
| Method | Safe | Idempotent | Purpose |
|
|
42
|
+
|--------|------|------------|---------|
|
|
43
|
+
| GET | ✓ | ✓ | Read resource |
|
|
44
|
+
| POST | ✗ | ✗ | Create resource |
|
|
45
|
+
| PUT | ✗ | ✓ | Replace resource |
|
|
46
|
+
| PATCH | ✗ | ✗ | Update resource |
|
|
47
|
+
| DELETE | ✗ | ✓ | Delete resource |
|
|
48
|
+
|
|
49
|
+
### 3. Status Codes
|
|
50
|
+
|
|
51
|
+
| Code | Meaning | Usage |
|
|
52
|
+
|------|---------|-------|
|
|
53
|
+
| 200 | OK | Successful GET, PATCH, DELETE |
|
|
54
|
+
| 201 | Created | Successful POST |
|
|
55
|
+
| 204 | No Content | Successful DELETE with no body |
|
|
56
|
+
| 400 | Bad Request | Invalid input |
|
|
57
|
+
| 401 | Unauthorized | Missing or invalid auth |
|
|
58
|
+
| 403 | Forbidden | Authenticated but not authorized |
|
|
59
|
+
| 404 | Not Found | Resource doesn't exist |
|
|
60
|
+
| 409 | Conflict | Resource already exists |
|
|
61
|
+
| 422 | Unprocessable | Valid syntax but semantic errors |
|
|
62
|
+
| 429 | Too Many Requests | Rate limit exceeded |
|
|
63
|
+
| 500 | Internal Server Error | Server error |
|
|
64
|
+
|
|
65
|
+
### 4. Naming Conventions
|
|
66
|
+
|
|
67
|
+
- **URLs**: kebab-case (`/user-preferences`)
|
|
68
|
+
- **JSON**: camelCase (`{"userId": "123"}`)
|
|
69
|
+
- **Query params**: snake_case or camelCase (`?page_size=10`)
|
|
70
|
+
|
|
71
|
+
### 5. Pagination
|
|
72
|
+
|
|
73
|
+
```http
|
|
74
|
+
GET /users?page=1&page_size=20
|
|
75
|
+
|
|
76
|
+
Response:
|
|
77
|
+
{
|
|
78
|
+
"data": [...],
|
|
79
|
+
"pagination": {
|
|
80
|
+
"page": 1,
|
|
81
|
+
"page_size": 20,
|
|
82
|
+
"total": 100,
|
|
83
|
+
"total_pages": 5
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 6. Filtering and Sorting
|
|
89
|
+
|
|
90
|
+
```http
|
|
91
|
+
GET /users?status=active&sort=-created_at,name
|
|
92
|
+
|
|
93
|
+
# -created_at = descending
|
|
94
|
+
# name = ascending
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## GraphQL API Design
|
|
98
|
+
|
|
99
|
+
### Schema Design
|
|
100
|
+
|
|
101
|
+
```graphql
|
|
102
|
+
type Query {
|
|
103
|
+
user(id: ID!): User
|
|
104
|
+
users(limit: Int, offset: Int): UserConnection!
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type Mutation {
|
|
108
|
+
createUser(input: CreateUserInput!): CreateUserPayload!
|
|
109
|
+
updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
type User {
|
|
113
|
+
id: ID!
|
|
114
|
+
email: String!
|
|
115
|
+
profile: Profile
|
|
116
|
+
posts(first: Int, after: String): PostConnection!
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
type UserConnection {
|
|
120
|
+
edges: [UserEdge!]!
|
|
121
|
+
pageInfo: PageInfo!
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type UserEdge {
|
|
125
|
+
node: User!
|
|
126
|
+
cursor: String!
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
type PageInfo {
|
|
130
|
+
hasNextPage: Boolean!
|
|
131
|
+
hasPreviousPage: Boolean!
|
|
132
|
+
startCursor: String
|
|
133
|
+
endCursor: String
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Best Practices
|
|
138
|
+
|
|
139
|
+
- **Nullability**: Default to non-null, nullable only when appropriate
|
|
140
|
+
- **Connections**: Use cursor-based pagination for lists
|
|
141
|
+
- **Payloads**: Use mutation payloads for consistent error handling
|
|
142
|
+
- **Descriptions**: Document all types and fields
|
|
143
|
+
|
|
144
|
+
## API Versioning
|
|
145
|
+
|
|
146
|
+
### Approaches
|
|
147
|
+
|
|
148
|
+
**URL Versioning** (Recommended):
|
|
149
|
+
```
|
|
150
|
+
/api/v1/users
|
|
151
|
+
/api/v2/users
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Header Versioning**:
|
|
155
|
+
```
|
|
156
|
+
GET /users
|
|
157
|
+
Accept: application/vnd.myapi.v2+json
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Versioning Guidelines
|
|
161
|
+
|
|
162
|
+
- Start with v1
|
|
163
|
+
- Maintain backwards compatibility when possible
|
|
164
|
+
- Deprecate old versions with notice
|
|
165
|
+
- Document breaking changes
|
|
166
|
+
|
|
167
|
+
## Authentication & Authorization
|
|
168
|
+
|
|
169
|
+
### Authentication Methods
|
|
170
|
+
|
|
171
|
+
1. **JWT Bearer Token**
|
|
172
|
+
```http
|
|
173
|
+
Authorization: Bearer <token>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
2. **API Key**
|
|
177
|
+
```http
|
|
178
|
+
X-API-Key: <key>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
3. **OAuth 2.0**
|
|
182
|
+
```http
|
|
183
|
+
Authorization: Bearer <access_token>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Authorization
|
|
187
|
+
|
|
188
|
+
- Use roles/permissions
|
|
189
|
+
- Document required permissions per endpoint
|
|
190
|
+
- Return 403 for authorization failures
|
|
191
|
+
|
|
192
|
+
## Rate Limiting
|
|
193
|
+
|
|
194
|
+
```http
|
|
195
|
+
HTTP/1.1 200 OK
|
|
196
|
+
X-RateLimit-Limit: 1000
|
|
197
|
+
X-RateLimit-Remaining: 999
|
|
198
|
+
X-RateLimit-Reset: 1631234567
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Recommended limits:**
|
|
202
|
+
- Public APIs: 100-1000 requests/hour
|
|
203
|
+
- Authenticated APIs: 1000-10000 requests/hour
|
|
204
|
+
- Webhooks: 10-100 requests/minute
|
|
205
|
+
|
|
206
|
+
## Documentation Requirements
|
|
207
|
+
|
|
208
|
+
- All endpoints documented
|
|
209
|
+
- Request/response examples
|
|
210
|
+
- Authentication requirements
|
|
211
|
+
- Error response formats
|
|
212
|
+
- Rate limits
|
|
213
|
+
- SDK examples (if available)
|
|
214
|
+
|
|
215
|
+
## Scripts
|
|
216
|
+
|
|
217
|
+
Generate API scaffold:
|
|
218
|
+
```bash
|
|
219
|
+
python scripts/generate_api.py <resource-name>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Validate API design:
|
|
223
|
+
```bash
|
|
224
|
+
python scripts/validate_api.py openapi.yaml
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## References
|
|
228
|
+
|
|
229
|
+
- `references/rest-patterns.md` - REST design patterns
|
|
230
|
+
- `references/graphql-patterns.md` - GraphQL design patterns
|
|
231
|
+
- [REST API Tutorial](https://restfulapi.net/)
|
|
232
|
+
- [GraphQL Best Practices](https://graphql.org/learn/best-practices/)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# REST Patterns
|
|
2
|
+
|
|
3
|
+
## Resource Naming
|
|
4
|
+
- Use nouns (e.g., /users)
|
|
5
|
+
- Use plural for collections
|
|
6
|
+
|
|
7
|
+
## Methods
|
|
8
|
+
- GET for retrieval
|
|
9
|
+
- POST for creation
|
|
10
|
+
- PUT/PATCH for updates
|
|
11
|
+
- DELETE for removal
|
|
12
|
+
|
|
13
|
+
## Status Codes
|
|
14
|
+
- 200 OK
|
|
15
|
+
- 201 Created
|
|
16
|
+
- 204 No Content
|
|
17
|
+
- 400/401/403/404 for errors
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Template generator for API design.
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import argparse
|
|
6
|
+
import textwrap
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def write_output(path: Path, content: str, force: bool) -> bool:
|
|
10
|
+
if path.exists() and not force:
|
|
11
|
+
print(f"{path} already exists (use --force to overwrite)")
|
|
12
|
+
return False
|
|
13
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
14
|
+
path.write_text(content, encoding="utf-8")
|
|
15
|
+
return True
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def main() -> int:
|
|
19
|
+
parser = argparse.ArgumentParser(description="Generate a starter API design.")
|
|
20
|
+
parser.add_argument("--output", default="api-design.md", help="Output file path")
|
|
21
|
+
parser.add_argument("--name", default="example", help="Primary resource name")
|
|
22
|
+
parser.add_argument("--owner", default="team", help="Owning team or service")
|
|
23
|
+
parser.add_argument("--force", action="store_true", help="Overwrite existing file")
|
|
24
|
+
args = parser.parse_args()
|
|
25
|
+
|
|
26
|
+
content = textwrap.dedent(
|
|
27
|
+
f"""\
|
|
28
|
+
# API Design
|
|
29
|
+
|
|
30
|
+
## Overview
|
|
31
|
+
Describe the API for {args.name}.
|
|
32
|
+
|
|
33
|
+
## Ownership
|
|
34
|
+
- Owner: {args.owner}
|
|
35
|
+
- Stakeholders: TBD
|
|
36
|
+
|
|
37
|
+
## Goals
|
|
38
|
+
- Provide CRUD for {args.name}
|
|
39
|
+
- Maintain backward compatibility
|
|
40
|
+
|
|
41
|
+
## Non-Goals
|
|
42
|
+
- Bulk export
|
|
43
|
+
- Cross-service transactions
|
|
44
|
+
|
|
45
|
+
## Resources
|
|
46
|
+
- {args.name}
|
|
47
|
+
- {args.name}-metadata
|
|
48
|
+
|
|
49
|
+
## Endpoints
|
|
50
|
+
| Method | Path | Description | Auth |
|
|
51
|
+
| --- | --- | --- | --- |
|
|
52
|
+
| GET | /{args.name} | List {args.name} | Required |
|
|
53
|
+
| POST | /{args.name} | Create {args.name} | Required |
|
|
54
|
+
|
|
55
|
+
## Authentication
|
|
56
|
+
- OAuth2 bearer tokens
|
|
57
|
+
- Service-to-service mTLS
|
|
58
|
+
|
|
59
|
+
## Error Model
|
|
60
|
+
- Use RFC7807 problem details
|
|
61
|
+
- Standard error codes and retry hints
|
|
62
|
+
|
|
63
|
+
## Pagination and Filtering
|
|
64
|
+
- Cursor-based pagination
|
|
65
|
+
- Filter by status, owner, and created_at
|
|
66
|
+
|
|
67
|
+
## Rate Limits
|
|
68
|
+
- 100 rps per token, burst 200
|
|
69
|
+
|
|
70
|
+
## Observability
|
|
71
|
+
- Structured logs with request_id
|
|
72
|
+
- Metrics: latency, error rate, saturation
|
|
73
|
+
|
|
74
|
+
## Open Questions
|
|
75
|
+
- Define data retention policy
|
|
76
|
+
"""
|
|
77
|
+
).strip() + "\n"
|
|
78
|
+
|
|
79
|
+
output = Path(args.output)
|
|
80
|
+
if not write_output(output, content, args.force):
|
|
81
|
+
return 1
|
|
82
|
+
print(f"Wrote {output}")
|
|
83
|
+
return 0
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if __name__ == "__main__":
|
|
87
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Template validator for API design.
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import argparse
|
|
6
|
+
|
|
7
|
+
DEFAULT_REQUIRED = [
|
|
8
|
+
"## Overview",
|
|
9
|
+
"## Ownership",
|
|
10
|
+
"## Resources",
|
|
11
|
+
"## Endpoints",
|
|
12
|
+
"## Authentication",
|
|
13
|
+
"## Error Model",
|
|
14
|
+
"## Pagination",
|
|
15
|
+
"## Rate Limits",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main() -> int:
|
|
20
|
+
parser = argparse.ArgumentParser(description="Validate a generated artifact.")
|
|
21
|
+
parser.add_argument("--input", default="api-design.md", help="Input file path")
|
|
22
|
+
parser.add_argument(
|
|
23
|
+
"--require",
|
|
24
|
+
action="append",
|
|
25
|
+
default=[],
|
|
26
|
+
help="Additional required section heading",
|
|
27
|
+
)
|
|
28
|
+
args = parser.parse_args()
|
|
29
|
+
|
|
30
|
+
path = Path(args.input)
|
|
31
|
+
if not path.exists():
|
|
32
|
+
print(f"Missing file: {path}")
|
|
33
|
+
return 1
|
|
34
|
+
|
|
35
|
+
text = path.read_text(encoding="utf-8", errors="ignore")
|
|
36
|
+
text_lower = text.lower()
|
|
37
|
+
required = DEFAULT_REQUIRED + args.require
|
|
38
|
+
missing = [section for section in required if section.lower() not in text_lower]
|
|
39
|
+
if missing:
|
|
40
|
+
print("Missing required sections: " + ", ".join(missing))
|
|
41
|
+
return 1
|
|
42
|
+
|
|
43
|
+
print(f"Validated {path}")
|
|
44
|
+
return 0
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# API Documenter
|
|
2
|
+
|
|
3
|
+
> A Claude Code skill for OpenAPI/Swagger API documentation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This skill is part of the [agent-playbook](https://github.com/Charon-Fan/agent-playbook) collection.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
You: Document this API
|
|
13
|
+
You: Create OpenAPI spec
|
|
14
|
+
You: Generate API documentation
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## OpenAPI Specification
|
|
18
|
+
|
|
19
|
+
The skill generates OpenAPI 3.0 specifications following:
|
|
20
|
+
- RESTful conventions
|
|
21
|
+
- Clear resource naming
|
|
22
|
+
- Complete request/response documentation
|
|
23
|
+
- Authentication requirements
|
|
24
|
+
- Error response formats
|
|
25
|
+
|
|
26
|
+
## Scripts
|
|
27
|
+
|
|
28
|
+
Generate OpenAPI spec:
|
|
29
|
+
```bash
|
|
30
|
+
python scripts/generate_openapi.py
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Validate OpenAPI spec:
|
|
34
|
+
```bash
|
|
35
|
+
python scripts/validate_openapi.py openapi.yaml
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Resources
|
|
39
|
+
|
|
40
|
+
- [OpenAPI Specification](https://swagger.io/specification/)
|
|
41
|
+
- [Swagger Tools](https://swagger.io/tools/)
|