moicle 1.7.0 → 2.0.0
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 +72 -29
- package/assets/skills/docs/content/SKILL.md +269 -0
- package/assets/skills/{logo-design → docs/logo}/SKILL.md +31 -16
- package/assets/skills/{sync-docs → docs/sync}/SKILL.md +31 -1
- package/assets/skills/{video-content → docs/video}/SKILL.md +32 -17
- package/assets/skills/docs/write/SKILL.md +371 -0
- package/assets/skills/feature/api/SKILL.md +277 -0
- package/assets/skills/feature/deprecate/SKILL.md +276 -0
- package/assets/skills/{new-feature → feature/new}/SKILL.md +28 -12
- package/assets/skills/{refactor → feature/refactor}/SKILL.md +24 -12
- package/assets/skills/{hotfix → fix/hotfix}/SKILL.md +32 -30
- package/assets/skills/fix/incident/SKILL.md +272 -0
- package/assets/skills/{fix-pr-comment → fix/pr-comment}/SKILL.md +30 -1
- package/assets/skills/fix/root-cause/SKILL.md +219 -0
- package/assets/skills/{onboarding → research/onboarding}/SKILL.md +32 -31
- package/assets/skills/{spike → research/spike}/SKILL.md +33 -32
- package/assets/skills/research/web/SKILL.md +163 -0
- package/assets/skills/{architect-review → review/architect}/SKILL.md +37 -7
- package/assets/skills/{review-changes → review/branch}/SKILL.md +27 -7
- package/assets/skills/{pr-review → review/pr}/SKILL.md +31 -30
- package/assets/skills/review/tdd/SKILL.md +206 -0
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +2 -2
- package/dist/commands/list.js.map +1 -1
- package/dist/utils/symlink.d.ts +7 -0
- package/dist/utils/symlink.d.ts.map +1 -1
- package/dist/utils/symlink.js +82 -0
- package/dist/utils/symlink.js.map +1 -1
- package/package.json +1 -1
- package/assets/skills/api-integration/SKILL.md +0 -883
- package/assets/skills/content-writer/SKILL.md +0 -721
- package/assets/skills/deep-debug/SKILL.md +0 -114
- package/assets/skills/deprecation/SKILL.md +0 -923
- package/assets/skills/documentation/SKILL.md +0 -1333
- package/assets/skills/incident-response/SKILL.md +0 -946
- package/assets/skills/research/SKILL.md +0 -124
- package/assets/skills/tdd/SKILL.md +0 -828
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docs-write
|
|
3
|
+
description: Documentation workflow for authoring project documentation manually. Use when documenting, writing docs, generating documentation, or when user says "document", "generate docs", "write docs", "create documentation", "update docs".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Documentation Workflow
|
|
7
|
+
|
|
8
|
+
Author project documentation manually following stack conventions. **Use this when you want full control** over the output (README, API.md, ARCHITECTURE.md, CONTRIBUTING.md). For automated batch generation with review loop, use `/docs:sync` instead.
|
|
9
|
+
|
|
10
|
+
## When to use this skill
|
|
11
|
+
|
|
12
|
+
- ✅ Authoring or updating a specific document (README, API, ARCHITECTURE, CONTRIBUTING)
|
|
13
|
+
- ✅ Need to write opinionated prose, not just structure
|
|
14
|
+
- ✅ Doc is small / scoped — a single file or section
|
|
15
|
+
- ❌ Want fully automated multi-doc generation → use `/docs:sync`
|
|
16
|
+
- ❌ Just need API reference from OpenAPI spec → use `/feature:api` Phase 4
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Workflow
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
SCAN → ANALYZE → GENERATE → REVIEW (loop)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Read Architecture First
|
|
27
|
+
|
|
28
|
+
Before writing, read:
|
|
29
|
+
1. `~/.claude/architecture/ddd-architecture.md` (core)
|
|
30
|
+
2. Stack-specific doc (see Stack Detection below)
|
|
31
|
+
3. `.claude/architecture/` for project overrides (if any)
|
|
32
|
+
|
|
33
|
+
**Documentation must accurately reflect the architecture and patterns used in the codebase.**
|
|
34
|
+
|
|
35
|
+
### Stack Detection
|
|
36
|
+
| File | Doc |
|
|
37
|
+
|------|-----|
|
|
38
|
+
| `go.mod` | `go-backend.md` |
|
|
39
|
+
| `package.json` + NestJS dep | `nodejs-nestjs.md` |
|
|
40
|
+
| `package.json` + Vite config | `react-frontend.md` |
|
|
41
|
+
| `remix.config.*` | `remix-fullstack.md` |
|
|
42
|
+
| `composer.json` | `laravel-backend.md` |
|
|
43
|
+
| `pubspec.yaml` | `flutter-mobile.md` |
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Phase 1: SCAN
|
|
48
|
+
|
|
49
|
+
**Goal:** identify what needs documentation.
|
|
50
|
+
|
|
51
|
+
### Actions
|
|
52
|
+
1. Read architecture doc for the stack
|
|
53
|
+
2. Scan codebase:
|
|
54
|
+
```bash
|
|
55
|
+
tree -L 3 -I 'node_modules|vendor|dist|build'
|
|
56
|
+
find . -maxdepth 3 -name "*.md" -o -name "README*"
|
|
57
|
+
```
|
|
58
|
+
3. Identify documentable items:
|
|
59
|
+
- README (project overview)
|
|
60
|
+
- API documentation (endpoints, schemas)
|
|
61
|
+
- ARCHITECTURE (system design, layer rules)
|
|
62
|
+
- CONTRIBUTING (dev setup, PR flow, conventions)
|
|
63
|
+
- Setup / deployment guides
|
|
64
|
+
- Database schema
|
|
65
|
+
- Configuration reference
|
|
66
|
+
|
|
67
|
+
### Gate
|
|
68
|
+
- [ ] Architecture doc read
|
|
69
|
+
- [ ] Existing docs inventoried
|
|
70
|
+
- [ ] Gaps identified
|
|
71
|
+
- [ ] Priorities set (high → low)
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Phase 2: ANALYZE
|
|
76
|
+
|
|
77
|
+
**Goal:** define what each document MUST contain.
|
|
78
|
+
|
|
79
|
+
For each doc:
|
|
80
|
+
- **Purpose** — what problem does this doc solve?
|
|
81
|
+
- **Audience** — new contributor / API consumer / ops team?
|
|
82
|
+
- **Source** — which files / sections of the codebase feed this doc?
|
|
83
|
+
|
|
84
|
+
### Required sections per doc type
|
|
85
|
+
|
|
86
|
+
**README.md** must have:
|
|
87
|
+
- One-line description + badges
|
|
88
|
+
- Quick start (install → run in ≤5 commands)
|
|
89
|
+
- Tech stack (link to architecture)
|
|
90
|
+
- Common commands (build / test / lint / dev)
|
|
91
|
+
- Project structure (top 2 levels only)
|
|
92
|
+
- Link to ARCHITECTURE.md, CONTRIBUTING.md, API.md
|
|
93
|
+
|
|
94
|
+
**API.md** must have:
|
|
95
|
+
- Auth method (Bearer / OAuth / API key) + how to obtain
|
|
96
|
+
- Base URL per environment
|
|
97
|
+
- For each endpoint: method, path, request schema, response schema, error codes, example
|
|
98
|
+
- Pagination convention (one block, not per endpoint)
|
|
99
|
+
- Error response format (one block, not per endpoint)
|
|
100
|
+
- Rate limits, versioning policy
|
|
101
|
+
|
|
102
|
+
**ARCHITECTURE.md** must have:
|
|
103
|
+
- 1 mermaid diagram of the layer structure (link to `ddd-architecture.md` for rules)
|
|
104
|
+
- Domain list with 1-line responsibility each
|
|
105
|
+
- Cross-domain communication pattern (events)
|
|
106
|
+
- Key tech decisions (why this DB, why this queue, why this auth)
|
|
107
|
+
- Link to stack-specific architecture doc
|
|
108
|
+
|
|
109
|
+
**CONTRIBUTING.md** must have:
|
|
110
|
+
- Local dev setup (prerequisites + ≤5 steps)
|
|
111
|
+
- Branch / commit conventions
|
|
112
|
+
- PR flow + review expectations
|
|
113
|
+
- Test commands + coverage expectations
|
|
114
|
+
- Where to ask for help
|
|
115
|
+
|
|
116
|
+
### Gate
|
|
117
|
+
- [ ] Each doc has clear purpose, audience, source
|
|
118
|
+
- [ ] Required sections listed
|
|
119
|
+
- [ ] Aligned with architecture doc
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Phase 3: GENERATE
|
|
124
|
+
|
|
125
|
+
**Goal:** write each doc using actual code examples from the codebase.
|
|
126
|
+
|
|
127
|
+
### Rules
|
|
128
|
+
- **Use real code from the repo** — never invent examples
|
|
129
|
+
- **Link to architecture docs**, don't duplicate them
|
|
130
|
+
- **Code blocks must be runnable** — copy verbatim from working files
|
|
131
|
+
- **Diagrams** — use mermaid; one per major concept
|
|
132
|
+
- **Tables** for any list with >3 items and parallel structure (endpoints, env vars, commands)
|
|
133
|
+
|
|
134
|
+
### Skeleton — README.md
|
|
135
|
+
|
|
136
|
+
```markdown
|
|
137
|
+
# {Project Name}
|
|
138
|
+
|
|
139
|
+
> One-line value proposition.
|
|
140
|
+
|
|
141
|
+
[](link) [](link)
|
|
142
|
+
|
|
143
|
+
## Quick Start
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
{install}
|
|
147
|
+
{run}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Tech Stack
|
|
151
|
+
|
|
152
|
+
- {language + version}
|
|
153
|
+
- {framework}
|
|
154
|
+
- {DB / queue / cache}
|
|
155
|
+
|
|
156
|
+
See [ARCHITECTURE.md](./ARCHITECTURE.md) for layer structure.
|
|
157
|
+
|
|
158
|
+
## Common Commands
|
|
159
|
+
|
|
160
|
+
| Command | Purpose |
|
|
161
|
+
|---------|---------|
|
|
162
|
+
| `{cmd}` | {what it does} |
|
|
163
|
+
|
|
164
|
+
## Project Structure
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
{top 2 levels only}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Documentation
|
|
171
|
+
|
|
172
|
+
- [API.md](./API.md) — endpoint reference
|
|
173
|
+
- [ARCHITECTURE.md](./ARCHITECTURE.md) — system design
|
|
174
|
+
- [CONTRIBUTING.md](./CONTRIBUTING.md) — dev guide
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Skeleton — API.md
|
|
178
|
+
|
|
179
|
+
```markdown
|
|
180
|
+
# API Reference
|
|
181
|
+
|
|
182
|
+
**Base URL:** `https://api.example.com/v1`
|
|
183
|
+
**Auth:** Bearer token in `Authorization` header
|
|
184
|
+
|
|
185
|
+
## Errors
|
|
186
|
+
|
|
187
|
+
All errors return JSON:
|
|
188
|
+
```json
|
|
189
|
+
{ "error": { "code": "STRING", "message": "STRING", "details": {} } }
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Pagination
|
|
193
|
+
|
|
194
|
+
Cursor-based: `?cursor=<opaque>&limit=<int, default 20, max 100>`.
|
|
195
|
+
Response includes `pagination.next_cursor` (null if last page).
|
|
196
|
+
|
|
197
|
+
## Endpoints
|
|
198
|
+
|
|
199
|
+
### POST /resource
|
|
200
|
+
|
|
201
|
+
Create a resource.
|
|
202
|
+
|
|
203
|
+
**Request**
|
|
204
|
+
```json
|
|
205
|
+
{ "field": "value" }
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Response 201**
|
|
209
|
+
```json
|
|
210
|
+
{ "id": "...", "field": "value" }
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Errors:** 400 invalid_field, 401 unauthorized, 409 already_exists
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Skeleton — ARCHITECTURE.md
|
|
217
|
+
|
|
218
|
+
```markdown
|
|
219
|
+
# Architecture
|
|
220
|
+
|
|
221
|
+
## Overview
|
|
222
|
+
|
|
223
|
+
{1-2 paragraphs: what this system does, key constraints}
|
|
224
|
+
|
|
225
|
+
## Layer Structure
|
|
226
|
+
|
|
227
|
+
```mermaid
|
|
228
|
+
graph TD
|
|
229
|
+
App[Application] --> Domain
|
|
230
|
+
Domain --> Infra[Infrastructure]
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
See [DDD architecture reference](~/.claude/architecture/ddd-architecture.md) for layer rules.
|
|
234
|
+
|
|
235
|
+
## Domains
|
|
236
|
+
|
|
237
|
+
| Domain | Responsibility |
|
|
238
|
+
|--------|----------------|
|
|
239
|
+
| {name} | {one line} |
|
|
240
|
+
|
|
241
|
+
## Cross-Domain Communication
|
|
242
|
+
|
|
243
|
+
Domains communicate via **domain events** (no direct imports).
|
|
244
|
+
|
|
245
|
+
```mermaid
|
|
246
|
+
sequenceDiagram
|
|
247
|
+
DomainA->>EventBus: raises Event
|
|
248
|
+
EventBus->>DomainB: Listener consumes
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Key Decisions
|
|
252
|
+
|
|
253
|
+
| Decision | Rationale |
|
|
254
|
+
|----------|-----------|
|
|
255
|
+
| {tech / pattern} | {why} |
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Skeleton — CONTRIBUTING.md
|
|
259
|
+
|
|
260
|
+
```markdown
|
|
261
|
+
# Contributing
|
|
262
|
+
|
|
263
|
+
## Prerequisites
|
|
264
|
+
- {runtime + version}
|
|
265
|
+
- {DB / service}
|
|
266
|
+
|
|
267
|
+
## Setup
|
|
268
|
+
```bash
|
|
269
|
+
{1-5 commands}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Branch & Commits
|
|
273
|
+
- Branch: `{prefix}/{ticket}-{slug}`
|
|
274
|
+
- Commit: Conventional Commits (`feat:`, `fix:`, `chore:`)
|
|
275
|
+
|
|
276
|
+
## PR Flow
|
|
277
|
+
1. Open PR against `{base branch}`
|
|
278
|
+
2. CI must pass
|
|
279
|
+
3. At least 1 review approval
|
|
280
|
+
4. Squash merge
|
|
281
|
+
|
|
282
|
+
## Tests
|
|
283
|
+
```bash
|
|
284
|
+
{test command}
|
|
285
|
+
```
|
|
286
|
+
Coverage target: {N}%
|
|
287
|
+
|
|
288
|
+
## Help
|
|
289
|
+
- {Slack / issue / discussion link}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Gate
|
|
293
|
+
- [ ] All planned docs drafted
|
|
294
|
+
- [ ] Code examples taken from real files (no invention)
|
|
295
|
+
- [ ] Diagrams render (mermaid syntax valid)
|
|
296
|
+
- [ ] Cross-links between docs work
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Phase 4: REVIEW
|
|
301
|
+
|
|
302
|
+
**Goal:** verify accuracy, consistency, and clarity.
|
|
303
|
+
|
|
304
|
+
### Review checklist per doc
|
|
305
|
+
|
|
306
|
+
- [ ] Reflects current architecture (not outdated)
|
|
307
|
+
- [ ] All commands run as written (try them)
|
|
308
|
+
- [ ] All file paths exist
|
|
309
|
+
- [ ] All endpoints / functions referenced still exist
|
|
310
|
+
- [ ] Links resolve (internal + external)
|
|
311
|
+
- [ ] Code blocks compile / are valid syntax
|
|
312
|
+
- [ ] Diagrams match actual code structure
|
|
313
|
+
|
|
314
|
+
### Cross-doc consistency
|
|
315
|
+
|
|
316
|
+
- [ ] README references match other docs' content
|
|
317
|
+
- [ ] Same terminology used everywhere (e.g., "domain" vs "module")
|
|
318
|
+
- [ ] No duplicated info — link instead
|
|
319
|
+
|
|
320
|
+
### Loop
|
|
321
|
+
If any issue found → go back to **Phase 3** for that doc, fix, re-review.
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Final Report
|
|
326
|
+
|
|
327
|
+
```markdown
|
|
328
|
+
## Documentation Update
|
|
329
|
+
|
|
330
|
+
### Files Created / Modified
|
|
331
|
+
- `README.md` — {changes}
|
|
332
|
+
- `API.md` — {changes}
|
|
333
|
+
- `ARCHITECTURE.md` — {changes}
|
|
334
|
+
- `CONTRIBUTING.md` — {changes}
|
|
335
|
+
|
|
336
|
+
### Coverage
|
|
337
|
+
- [x] Project overview
|
|
338
|
+
- [x] API reference
|
|
339
|
+
- [x] Architecture
|
|
340
|
+
- [x] Contributing guide
|
|
341
|
+
- [ ] Deployment (out of scope)
|
|
342
|
+
|
|
343
|
+
### Verification
|
|
344
|
+
- [x] All commands tested
|
|
345
|
+
- [x] All links resolve
|
|
346
|
+
- [x] All examples compile
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## Related Skills
|
|
352
|
+
|
|
353
|
+
| When | Use |
|
|
354
|
+
|------|-----|
|
|
355
|
+
| Generate full doc site from codebase automatically | `/docs:sync` |
|
|
356
|
+
| Document a newly added API endpoint | `/feature:api` (Phase 4) |
|
|
357
|
+
| Onboard yourself / new dev to the codebase | `/research:onboarding` |
|
|
358
|
+
| Write release notes / changelog | `release` (manually for now) |
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## Recommended Agents
|
|
363
|
+
|
|
364
|
+
| Phase | Agent | Purpose |
|
|
365
|
+
|-------|-------|---------|
|
|
366
|
+
| SCAN | `@clean-architect` | Identify doc needs from architecture |
|
|
367
|
+
| ANALYZE (API) | `@api-designer` | API doc structure |
|
|
368
|
+
| ANALYZE (DB) | `@db-designer` | Database doc structure |
|
|
369
|
+
| GENERATE | `@docs-writer` | Write all docs |
|
|
370
|
+
| REVIEW | `@code-reviewer` | Verify accuracy against code |
|
|
371
|
+
| REVIEW | Stack-specific dev agent | Stack-specific review |
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: feature-api
|
|
3
|
+
description: API integration workflow for adding new endpoints or integrating external APIs. Use when adding API endpoints, integrating third-party APIs, or when user says "integrate api", "add endpoint", "new api", "connect api", "api integration".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# API Integration Workflow
|
|
7
|
+
|
|
8
|
+
End-to-end workflow for designing, implementing, testing, and documenting APIs — both internal endpoints and third-party integrations.
|
|
9
|
+
|
|
10
|
+
## When to use this skill
|
|
11
|
+
|
|
12
|
+
- ✅ Adding a new REST / GraphQL endpoint to your service
|
|
13
|
+
- ✅ Integrating a third-party API (Stripe, OpenAI, etc.) into the system
|
|
14
|
+
- ✅ Replacing or upgrading an existing API integration
|
|
15
|
+
- ❌ Just need a one-off HTTP call in a script → use Bash directly
|
|
16
|
+
- ❌ Need to research which API to use → use `/research:web` first
|
|
17
|
+
- ❌ Building a whole new domain → use `/feature:new` (which calls this skill internally for the API surface)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Workflow
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
DESIGN → IMPLEMENT → TEST → DOCUMENT → REVIEW LOOP
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Read Architecture First
|
|
28
|
+
|
|
29
|
+
Before any phase, read:
|
|
30
|
+
1. `~/.claude/architecture/ddd-architecture.md` (core DDD)
|
|
31
|
+
2. Stack-specific doc (`go-backend.md`, `nodejs-nestjs.md`, etc.)
|
|
32
|
+
3. Existing API conventions in the project (look at 1–2 existing endpoints as reference)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Phase 1: DESIGN
|
|
37
|
+
|
|
38
|
+
**Goal:** lock the API contract before writing any code.
|
|
39
|
+
|
|
40
|
+
### Actions
|
|
41
|
+
1. Identify API type: REST / GraphQL / gRPC / third-party client
|
|
42
|
+
2. Define contract:
|
|
43
|
+
- Endpoints / operations (method + path)
|
|
44
|
+
- Request / response schema (use real types from domain entities)
|
|
45
|
+
- Auth method
|
|
46
|
+
- Error codes per endpoint
|
|
47
|
+
- Pagination (cursor or offset) — pick ONE, apply to all list endpoints
|
|
48
|
+
- Idempotency keys for POST/PUT (if applicable)
|
|
49
|
+
3. Write the contract as **OpenAPI 3.0** (REST) or **GraphQL SDL**
|
|
50
|
+
|
|
51
|
+
### Minimal OpenAPI skeleton
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
openapi: 3.0.0
|
|
55
|
+
info: { title: <name>, version: 1.0.0 }
|
|
56
|
+
servers: [{ url: https://api.example.com/v1 }]
|
|
57
|
+
components:
|
|
58
|
+
securitySchemes:
|
|
59
|
+
BearerAuth: { type: http, scheme: bearer }
|
|
60
|
+
schemas:
|
|
61
|
+
Error: { type: object, properties: { code: { type: string }, message: { type: string } } }
|
|
62
|
+
paths:
|
|
63
|
+
/resource:
|
|
64
|
+
post:
|
|
65
|
+
summary: Create resource
|
|
66
|
+
security: [{ BearerAuth: [] }]
|
|
67
|
+
requestBody: { content: { application/json: { schema: { $ref: '#/components/schemas/CreateInput' } } } }
|
|
68
|
+
responses:
|
|
69
|
+
'201': { description: Created, content: { application/json: { schema: { $ref: '#/components/schemas/Resource' } } } }
|
|
70
|
+
'400': { description: Validation error, content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Gate
|
|
74
|
+
- [ ] Endpoints listed in a table (method, path, auth, purpose)
|
|
75
|
+
- [ ] Request / response schemas defined
|
|
76
|
+
- [ ] Error codes listed (with stable string codes, not just HTTP status)
|
|
77
|
+
- [ ] Pagination strategy chosen (cursor preferred)
|
|
78
|
+
- [ ] **User CONFIRMED contract** before continuing
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Phase 2: IMPLEMENT
|
|
83
|
+
|
|
84
|
+
**Goal:** implement the contract per stack conventions, respecting DDD layers.
|
|
85
|
+
|
|
86
|
+
### Layered placement (DDD)
|
|
87
|
+
|
|
88
|
+
| Concern | Layer | Notes |
|
|
89
|
+
|---------|-------|-------|
|
|
90
|
+
| Route definition | `application/ports/http/` | Thin handler: parse → service → respond |
|
|
91
|
+
| Request / Response DTOs | `application/ports/http/dto/` | NOT domain types |
|
|
92
|
+
| Validation | Handler or domain (depending on stack) | Reject bad input before reaching usecase |
|
|
93
|
+
| Business logic | `domain/{domain}/usecases/` | NEVER in the handler |
|
|
94
|
+
| External API client | `infrastructure/adapters/` | Implements a port in `domain/{domain}/ports/` |
|
|
95
|
+
| Auth check | Middleware / decorator | NOT inline in handler |
|
|
96
|
+
|
|
97
|
+
### Standard error response
|
|
98
|
+
|
|
99
|
+
All endpoints return errors in the same shape:
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{ "error": { "code": "STRING", "message": "human-readable", "details": {} } }
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`code` is stable across versions; `message` may change. Map domain errors → HTTP codes in ONE place (middleware / interceptor).
|
|
106
|
+
|
|
107
|
+
### Standard pagination (cursor)
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
GET /resource?cursor=<opaque>&limit=<int 1..100, default 20>
|
|
111
|
+
→
|
|
112
|
+
{
|
|
113
|
+
"data": [...],
|
|
114
|
+
"pagination": { "next_cursor": "..." | null }
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Gate
|
|
119
|
+
- [ ] Routes registered in router / app module
|
|
120
|
+
- [ ] Handler is thin (parse → service → respond)
|
|
121
|
+
- [ ] Business logic in usecase, not handler
|
|
122
|
+
- [ ] External calls go through infrastructure adapter
|
|
123
|
+
- [ ] Auth + validation in middleware, not handler
|
|
124
|
+
- [ ] Build passes: `{stack_build_command}`
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Phase 3: TEST
|
|
129
|
+
|
|
130
|
+
**Goal:** verify the contract holds and breaks safely.
|
|
131
|
+
|
|
132
|
+
### Test layers
|
|
133
|
+
|
|
134
|
+
| Layer | Type | What |
|
|
135
|
+
|-------|------|------|
|
|
136
|
+
| Handler | Unit | Validation, error mapping (mock service) |
|
|
137
|
+
| UseCase | Unit | Business logic (mock port) |
|
|
138
|
+
| Adapter (external API) | Integration | Real HTTP call to sandbox OR contract test with `nock` / `WireMock` |
|
|
139
|
+
| End-to-end | Integration | Full request → response, real DB |
|
|
140
|
+
|
|
141
|
+
### Mandatory test cases per endpoint
|
|
142
|
+
- [ ] Happy path
|
|
143
|
+
- [ ] Auth failure (missing / invalid token)
|
|
144
|
+
- [ ] Validation failure (each required field missing)
|
|
145
|
+
- [ ] Permission failure (valid token, wrong scope)
|
|
146
|
+
- [ ] Not found (where applicable)
|
|
147
|
+
- [ ] Rate limit / quota (where applicable)
|
|
148
|
+
- [ ] Idempotency (POST with same key returns same response)
|
|
149
|
+
|
|
150
|
+
### Gate
|
|
151
|
+
- [ ] All mandatory cases covered
|
|
152
|
+
- [ ] Tests pass: `{stack_test_command}`
|
|
153
|
+
- [ ] Error response shape verified in tests
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Phase 4: DOCUMENT
|
|
158
|
+
|
|
159
|
+
**Goal:** update API docs so consumers can use it without reading code.
|
|
160
|
+
|
|
161
|
+
### What to update
|
|
162
|
+
1. **OpenAPI spec** committed to repo (`openapi.yaml` or per-resource files)
|
|
163
|
+
2. **API.md** — append the new endpoint(s) (or refer to `/docs:write` skill for full re-author)
|
|
164
|
+
3. **CHANGELOG.md** — note breaking / additive changes
|
|
165
|
+
4. **README.md** — if this changes quick-start
|
|
166
|
+
|
|
167
|
+
### Endpoint doc entry (minimal)
|
|
168
|
+
|
|
169
|
+
```markdown
|
|
170
|
+
### POST /resource
|
|
171
|
+
|
|
172
|
+
Create a resource. Idempotent via `Idempotency-Key` header.
|
|
173
|
+
|
|
174
|
+
**Auth:** Bearer
|
|
175
|
+
|
|
176
|
+
**Request**
|
|
177
|
+
```json
|
|
178
|
+
{ "field": "value" }
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Response 201**
|
|
182
|
+
```json
|
|
183
|
+
{ "id": "...", "field": "value" }
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Errors**
|
|
187
|
+
| Code | HTTP | Meaning |
|
|
188
|
+
|------|------|---------|
|
|
189
|
+
| `invalid_field` | 400 | `field` failed validation |
|
|
190
|
+
| `unauthorized` | 401 | Token missing or invalid |
|
|
191
|
+
| `already_exists` | 409 | Same idempotency key with different body |
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Gate
|
|
195
|
+
- [ ] OpenAPI spec updated and lints
|
|
196
|
+
- [ ] API.md entry added
|
|
197
|
+
- [ ] CHANGELOG entry
|
|
198
|
+
- [ ] At least 1 example request runs successfully (curl / Postman)
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Phase 5: REVIEW LOOP
|
|
203
|
+
|
|
204
|
+
Run `/review:architect` for the touched domain. Loop until score ≥ B.
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
LOOP:
|
|
208
|
+
1. Run /review:architect {stack} {domain}
|
|
209
|
+
2. Fix violations
|
|
210
|
+
3. Re-run tests + build
|
|
211
|
+
4. GOTO 1 (until score ≥ B)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Final Report
|
|
217
|
+
|
|
218
|
+
```markdown
|
|
219
|
+
## API Integration Complete
|
|
220
|
+
|
|
221
|
+
### Endpoints Added / Changed
|
|
222
|
+
| Method | Path | Purpose |
|
|
223
|
+
|--------|------|---------|
|
|
224
|
+
| POST | /v1/resource | Create resource |
|
|
225
|
+
|
|
226
|
+
### Files Created
|
|
227
|
+
- `application/ports/http/resource_handler.{ext}`
|
|
228
|
+
- `domain/{domain}/usecases/create_resource.{ext}`
|
|
229
|
+
- `infrastructure/adapters/{external_service}.{ext}` (if applicable)
|
|
230
|
+
|
|
231
|
+
### Tests
|
|
232
|
+
- {N} test files, {M} test cases
|
|
233
|
+
- Coverage: handler, usecase, adapter, e2e
|
|
234
|
+
|
|
235
|
+
### Documentation
|
|
236
|
+
- [x] OpenAPI spec updated
|
|
237
|
+
- [x] API.md entry added
|
|
238
|
+
- [x] CHANGELOG entry
|
|
239
|
+
|
|
240
|
+
### Review Score: {A/B}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Hard Rules
|
|
246
|
+
|
|
247
|
+
- **NEVER put business logic in the handler** — handler is thin parse-call-respond
|
|
248
|
+
- **NEVER call an external API directly from a usecase** — go through an infrastructure adapter that implements a domain port
|
|
249
|
+
- **Error codes are stable strings**, not just HTTP status — frontend/SDK depend on them
|
|
250
|
+
- **Pick one pagination style** for the whole API (cursor preferred), don't mix
|
|
251
|
+
- **Idempotency key required** for any POST that creates state
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Related Skills
|
|
256
|
+
|
|
257
|
+
| When | Use |
|
|
258
|
+
|------|-----|
|
|
259
|
+
| Designing the API contract from scratch | `@api-designer` agent |
|
|
260
|
+
| Adding the endpoint as part of a larger feature | `/feature:new` (calls this internally) |
|
|
261
|
+
| Writing tests for the endpoint | `/review:tdd` |
|
|
262
|
+
| Documenting the full API surface | `/docs:write` |
|
|
263
|
+
| Reviewing architecture compliance | `/review:architect` |
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Recommended Agents
|
|
268
|
+
|
|
269
|
+
| Phase | Agent | Purpose |
|
|
270
|
+
|-------|-------|---------|
|
|
271
|
+
| DESIGN | `@api-designer` | API contract design (OpenAPI / GraphQL) |
|
|
272
|
+
| DESIGN | `@clean-architect` | Ensure DDD compliance |
|
|
273
|
+
| IMPLEMENT | Stack-specific dev agent | Implementation |
|
|
274
|
+
| IMPLEMENT | `@db-designer` | DB schema if new tables needed |
|
|
275
|
+
| TEST | `@test-writer` | Unit + integration tests |
|
|
276
|
+
| TEST | `@security-audit` | Auth / injection / rate-limit checks |
|
|
277
|
+
| DOCUMENT | `@docs-writer` | OpenAPI + API.md |
|