codex-genesis-harness 0.1.5 → 0.1.6
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/.codebase/ARCHITECTURE_REVIEW_COMPLETE.md +216 -216
- package/.codebase/CURRENT_STATE.md +7 -2
- package/.codebase/FILE_NAMING_CLARIFICATION.md +161 -161
- package/.codebase/HARNESS_COMPLETENESS_AUDIT.md +613 -613
- package/.codebase/IMPLEMENTATION_COMPLETE.md +429 -429
- package/.codebase/IMPLEMENTATION_HANDOFF.md +351 -351
- package/.codebase/IMPROVEMENTS_SUMMARY.md +419 -419
- package/.codebase/PHASE3_SKILLS_NAMING_COMPLETE.md +292 -292
- package/.codebase/PHASE_DEPENDENCY_MAP.md +486 -486
- package/.codebase/QUICK_START_SPEC_IMPACT.md +456 -456
- package/.codebase/README.md +139 -139
- package/.codebase/RECOVERY_POINTS.md +438 -438
- package/.codex/skills/genesis-api-sync/SKILL.md +354 -354
- package/.codex/skills/genesis-api-sync/checklists/api-sync-checklist.md +101 -101
- package/.codex/skills/genesis-api-sync/templates/api-change-template.md +257 -257
- package/.codex/skills/genesis-debug-guide/SKILL.md +479 -479
- package/.codex/skills/genesis-debug-guide/checklists/flaky-test-investigation.md +339 -339
- package/.codex/skills/genesis-debug-guide/checklists/production-bug-debug.md +210 -210
- package/.codex/skills/genesis-debug-guide/checklists/test-failure-debug.md +158 -158
- package/.codex/skills/genesis-debug-guide/observability/debug-commands.md +365 -365
- package/.codex/skills/genesis-debug-guide/playbooks/unit-test-failures.md +289 -289
- package/.codex/skills/genesis-debug-guide/templates/debug-investigation-log.md +288 -288
- package/.codex/skills/genesis-docs-automation/SKILL.md +1003 -1003
- package/.codex/skills/genesis-docs-automation/checklists/docs-validation.md +359 -359
- package/.codex/skills/genesis-docs-automation/checklists/spec-alignment.md +312 -312
- package/.codex/skills/genesis-docs-automation/observability/docs-tracking.md +382 -382
- package/.codex/skills/genesis-docs-automation/playbooks/auto-update-flow.md +851 -851
- package/.codex/skills/genesis-docs-automation/playbooks/changelog-generation.md +491 -491
- package/.codex/skills/genesis-docs-automation/templates/changelog-entry-template.md +187 -187
- package/.codex/skills/genesis-docs-automation/templates/handoff-template.md +297 -297
- package/.codex/skills/genesis-harness/SKILL.md +1427 -1427
- package/.codex/skills/genesis-harness/agents/openai.yaml +7 -7
- package/.codex/skills/genesis-harness/checklists/bug-fix-qa.md +169 -169
- package/.codex/skills/genesis-harness/checklists/new-feature-qa.md +157 -157
- package/.codex/skills/genesis-harness/checklists/refactor-qa.md +216 -216
- package/.codex/skills/genesis-harness/checklists/requirements-validation.md +211 -211
- package/.codex/skills/genesis-harness/references/planning-schema.md +35 -35
- package/.codex/skills/genesis-harness/references/quality-rubric.md +21 -21
- package/.codex/skills/genesis-harness/references/research-rubric.md +41 -41
- package/.codex/skills/genesis-harness/references/workflows.md +33 -33
- package/.codex/skills/genesis-harness/resources/agents-template.md +27 -27
- package/.codex/skills/genesis-harness/resources/api-docs-template.md +32 -32
- package/.codex/skills/genesis-harness/resources/architecture-template.md +30 -30
- package/.codex/skills/genesis-harness/resources/audit-template.md +26 -26
- package/.codex/skills/genesis-harness/resources/bug-template.md +34 -34
- package/.codex/skills/genesis-harness/resources/change-impact-matrix-template.md +204 -204
- package/.codex/skills/genesis-harness/resources/check-template.md +21 -21
- package/.codex/skills/genesis-harness/resources/conventions-template.md +42 -42
- package/.codex/skills/genesis-harness/resources/decision-template.md +33 -33
- package/.codex/skills/genesis-harness/resources/design-template.md +26 -26
- package/.codex/skills/genesis-harness/resources/escalation-template.md +21 -21
- package/.codex/skills/genesis-harness/resources/feature-template.md +49 -49
- package/.codex/skills/genesis-harness/resources/foundation-phase-template.md +131 -131
- package/.codex/skills/genesis-harness/resources/integrations-template.md +32 -32
- package/.codex/skills/genesis-harness/resources/journeys-template.md +13 -13
- package/.codex/skills/genesis-harness/resources/lessons-learned-template.md +12 -12
- package/.codex/skills/genesis-harness/resources/observability-template.md +34 -34
- package/.codex/skills/genesis-harness/resources/phase-00-foundation-template.md +76 -76
- package/.codex/skills/genesis-harness/resources/phase-template.md +34 -34
- package/.codex/skills/genesis-harness/resources/pitfalls-template.md +22 -22
- package/.codex/skills/genesis-harness/resources/planning-tree-template.md +39 -39
- package/.codex/skills/genesis-harness/resources/post-implementation-guide.md +347 -347
- package/.codex/skills/genesis-harness/resources/project-template.md +38 -38
- package/.codex/skills/genesis-harness/resources/quality-score-template.md +11 -11
- package/.codex/skills/genesis-harness/resources/requirements-template.md +26 -26
- package/.codex/skills/genesis-harness/resources/research-template.md +26 -26
- package/.codex/skills/genesis-harness/resources/review-template.md +22 -22
- package/.codex/skills/genesis-harness/resources/spec-changelog-template.md +6 -6
- package/.codex/skills/genesis-harness/resources/stack-template.md +33 -33
- package/.codex/skills/genesis-harness/resources/verification-template.md +26 -26
- package/.codex/skills/genesis-harness/scripts/check-architecture-boundaries.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/check-docs-sync.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/check-no-debug-logs.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/check-required-planning-files.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/check-spec-changelog.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/check-task-tracking.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/compact-context.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/create-adr.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/create-bug.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/create-feature.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/detect-stack.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/init-planning.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/list-changed-files.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/offload-log.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/run-verification.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/run-verify-loop.sh +0 -0
- package/.codex/skills/genesis-harness/scripts/update-state.sh +0 -0
- package/.codex/skills/genesis-mvp-planning/SKILL.md +114 -0
- package/.codex/skills/genesis-mvp-planning/agents/openai.yaml +6 -0
- package/.codex/skills/genesis-mvp-planning/checklists/mvp-readiness.md +18 -0
- package/.codex/skills/genesis-mvp-planning/examples/5-phase-roadmap-example.md +43 -0
- package/.codex/skills/genesis-mvp-planning/templates/phase-1-core.md +17 -0
- package/.codex/skills/genesis-mvp-planning/templates/phase-2-auth.md +17 -0
- package/.codex/skills/genesis-mvp-planning/templates/phase-3-features.md +17 -0
- package/.codex/skills/genesis-mvp-planning/templates/phase-4-integrations.md +17 -0
- package/.codex/skills/genesis-mvp-planning/templates/phase-5-readiness.md +17 -0
- package/.codex/skills/genesis-new-design/agents/openai.yaml +3 -3
- package/.codex/skills/genesis-observability-automation/checklists/.gitkeep +0 -0
- package/.codex/skills/genesis-observability-automation/observability/.gitkeep +0 -0
- package/.codex/skills/genesis-observability-automation/playbooks/.gitkeep +0 -0
- package/.codex/skills/genesis-observability-automation/templates/.gitkeep +0 -0
- package/.codex/skills/genesis-release-orchestration/SKILL.md +653 -653
- package/.codex/skills/genesis-release-orchestration/checklists/post-deployment-verification.md +274 -274
- package/.codex/skills/genesis-release-orchestration/checklists/pre-release-validation.md +220 -220
- package/.codex/skills/genesis-release-orchestration/observability/release-tracking.md +253 -253
- package/.codex/skills/genesis-release-orchestration/playbooks/canary-deployment-orchestration.md +472 -472
- package/.codex/skills/genesis-release-orchestration/playbooks/semantic-versioning-automation.md +494 -494
- package/.codex/skills/genesis-release-orchestration/templates/deployment-strategy-template.md +303 -303
- package/.codex/skills/genesis-release-orchestration/templates/release-runbook-template.md +420 -420
- package/.codex/skills/genesis-research-first/SKILL.md +237 -237
- package/.codex/skills/genesis-research-first/templates/.gitkeep +0 -0
- package/.codex/skills/genesis-spec-propagation/SKILL.md +534 -534
- package/.codex/skills/genesis-spec-propagation/checklists/phase-update-verification.md +384 -384
- package/.codex/skills/genesis-spec-propagation/checklists/spec-change-detection.md +257 -257
- package/.codex/skills/genesis-spec-propagation/observability/propagation-tracking.md +373 -373
- package/.codex/skills/genesis-spec-propagation/playbooks/breaking-change-propagation.md +692 -692
- package/.codex/skills/genesis-spec-propagation/playbooks/feature-change-propagation.md +434 -434
- package/.codex/skills/genesis-spec-propagation/templates/migration-guide-template.md +407 -407
- package/.codex/skills/genesis-upgrade-design/agents/openai.yaml +3 -3
- package/.codex/skills/spec-impact-engine/SKILL.md +504 -504
- package/.codex/skills/spec-impact-engine/detect-spec-changes.sh +0 -0
- package/.codex-plugin/plugin.json +19 -19
- package/CHANGELOG.md +42 -0
- package/LICENSE +22 -22
- package/README.EN.md +784 -730
- package/README.VI.md +776 -723
- package/README.md +102 -247
- package/VERSION +2 -2
- package/bin/genesis-harness.js +90 -87
- package/package.json +9 -3
- package/scripts/README.md +342 -342
- package/scripts/compact-context.sh +0 -0
- package/scripts/contract_integrity_gate.js +83 -0
- package/scripts/detect-changes.sh +0 -0
- package/scripts/healing_telemetry.js +118 -0
- package/scripts/install.sh +4 -1
- package/scripts/offload-log.sh +0 -0
- package/scripts/prompt_sentinel.js +84 -0
- package/scripts/run-evals.sh +1 -0
- package/scripts/run-verify-loop.sh +11 -0
- package/scripts/spec_visual_sync.js +157 -0
- package/scripts/test_generator.js +142 -0
- package/scripts/transition_state.sh +0 -0
- package/scripts/uninstall.sh +1 -0
- package/scripts/validation_gates.sh +40 -1
- package/scripts/verify.sh +5 -0
- package/tests/unit/contract_integrity_gate.test.js +74 -0
- package/tests/unit/healing_telemetry.test.js +58 -0
- package/tests/unit/prompt_sentinel.test.js +50 -0
- package/tests/unit/spec_visual_sync.test.js +77 -0
- package/tests/unit/test_generator.test.js +62 -0
|
@@ -1,354 +1,354 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: api-sync-skill
|
|
3
|
-
description: Automatic API contract synchronization. Detects API changes in implementation, updates API_CONTRACTS.md, regenerates test contracts, and maintains backward compatibility documentation. Use after API-related implementation or when contracts drift from actual code.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# API Sync Skill
|
|
7
|
-
|
|
8
|
-
## Purpose
|
|
9
|
-
|
|
10
|
-
Keep API contracts synchronized with actual implementation. Detect changes, update contracts, regenerate tests, and document breaking changes automatically.
|
|
11
|
-
|
|
12
|
-
## When to use
|
|
13
|
-
|
|
14
|
-
Use after API-related implementation when:
|
|
15
|
-
- New endpoints added
|
|
16
|
-
- Endpoint behavior changed
|
|
17
|
-
- Request/response schemas modified
|
|
18
|
-
- Error handling updated
|
|
19
|
-
- Authentication/authorization changed
|
|
20
|
-
- Deprecated endpoints need removal
|
|
21
|
-
|
|
22
|
-
## When NOT to use
|
|
23
|
-
|
|
24
|
-
Do not use for read-only API documentation or when contract-first design hasn't been completed yet.
|
|
25
|
-
|
|
26
|
-
## Inputs required
|
|
27
|
-
|
|
28
|
-
- Changed implementation files (API routes, controllers, handlers)
|
|
29
|
-
- Current API_CONTRACTS.md file
|
|
30
|
-
- Test suite location
|
|
31
|
-
- Breaking change impact assessment
|
|
32
|
-
|
|
33
|
-
## Outputs required
|
|
34
|
-
|
|
35
|
-
- Updated API_CONTRACTS.md with all changes
|
|
36
|
-
- Updated API test contracts
|
|
37
|
-
- Test code reflecting new contracts
|
|
38
|
-
- Migration guide for breaking changes (if applicable)
|
|
39
|
-
- Backward compatibility documentation
|
|
40
|
-
|
|
41
|
-
## Required tests
|
|
42
|
-
|
|
43
|
-
- Contract validation tests (request/response schemas)
|
|
44
|
-
- API integration tests updated
|
|
45
|
-
- Backward compatibility tests (if versioning)
|
|
46
|
-
- Error handling tests
|
|
47
|
-
|
|
48
|
-
## Required fixtures
|
|
49
|
-
|
|
50
|
-
- Updated endpoint fixtures
|
|
51
|
-
- Request/response examples
|
|
52
|
-
- Error scenario fixtures
|
|
53
|
-
- Edge case payloads
|
|
54
|
-
|
|
55
|
-
## Required contract updates
|
|
56
|
-
|
|
57
|
-
- API_CONTRACTS.md (primary)
|
|
58
|
-
- Versioning info (if breaking changes)
|
|
59
|
-
- Deprecation notices (if applicable)
|
|
60
|
-
- Migration guide (if breaking changes)
|
|
61
|
-
|
|
62
|
-
## Required codebase map updates
|
|
63
|
-
|
|
64
|
-
- `.codebase/API_CONTRACTS.md` - complete update
|
|
65
|
-
- `.codebase/CURRENT_STATE.md` - note API changes
|
|
66
|
-
- `.codebase/KNOWN_PROBLEMS.md` - document migration issues
|
|
67
|
-
- `.codebase/EVOLUTION_PLAN.md` - next API phases
|
|
68
|
-
|
|
69
|
-
## Token saving rules
|
|
70
|
-
|
|
71
|
-
Extract schemas programmatically; don't paste entire files. Focus on deltas from previous contracts. Link to test fixtures rather than duplicating examples.
|
|
72
|
-
|
|
73
|
-
## Acceptance criteria
|
|
74
|
-
|
|
75
|
-
- API contracts match actual implementation
|
|
76
|
-
- All endpoints documented with schemas
|
|
77
|
-
- Breaking changes clearly marked
|
|
78
|
-
- Test contracts generated and passing
|
|
79
|
-
- Migration paths documented for breaking changes
|
|
80
|
-
- No contract drift validation passing
|
|
81
|
-
|
|
82
|
-
## Common mistakes
|
|
83
|
-
|
|
84
|
-
- Skipping breaking change documentation
|
|
85
|
-
- Not updating test contracts in parallel
|
|
86
|
-
- Leaving old endpoints undocumented
|
|
87
|
-
- Forgetting error response contracts
|
|
88
|
-
- Not validating backward compatibility
|
|
89
|
-
|
|
90
|
-
## Recovery workflow
|
|
91
|
-
|
|
92
|
-
If contracts drift or sync fails:
|
|
93
|
-
1. Read current API_CONTRACTS.md
|
|
94
|
-
2. Extract actual endpoint schemas from implementation
|
|
95
|
-
3. Identify changes and breaking status
|
|
96
|
-
4. Update contracts with full changelog
|
|
97
|
-
5. Regenerate test contracts
|
|
98
|
-
6. Validate all tests pass
|
|
99
|
-
7. Document migration guide if needed
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
## Workflow: API Change Detection & Sync
|
|
104
|
-
|
|
105
|
-
### Step 1: Detect API Changes
|
|
106
|
-
|
|
107
|
-
Identify which files contain API code:
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
Scan for:
|
|
111
|
-
├─ src/api/**
|
|
112
|
-
├─ src/**/route.ts, routes.ts
|
|
113
|
-
├─ src/**/controller.ts
|
|
114
|
-
├─ src/**/endpoint.ts
|
|
115
|
-
└─ src/**/handler.ts
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
For each file, extract:
|
|
119
|
-
- HTTP method (GET, POST, PUT, DELETE, PATCH)
|
|
120
|
-
- Route/path
|
|
121
|
-
- Request schema (params, query, body)
|
|
122
|
-
- Response schema (success, error)
|
|
123
|
-
- Status codes
|
|
124
|
-
- Authentication requirements
|
|
125
|
-
- Rate limiting or other middleware
|
|
126
|
-
|
|
127
|
-
### Step 2: Compare Against Current Contract
|
|
128
|
-
|
|
129
|
-
```
|
|
130
|
-
For each endpoint:
|
|
131
|
-
New? → Add to contract
|
|
132
|
-
Modified? → Mark change and version
|
|
133
|
-
Deleted? → Mark as deprecated
|
|
134
|
-
Unchanged? → Keep as-is
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Step 3: Generate Updated Contracts
|
|
138
|
-
|
|
139
|
-
```json
|
|
140
|
-
{
|
|
141
|
-
"endpoints": [
|
|
142
|
-
{
|
|
143
|
-
"id": "endpoint-id",
|
|
144
|
-
"method": "POST",
|
|
145
|
-
"path": "/api/v1/resource",
|
|
146
|
-
"description": "Create a new resource",
|
|
147
|
-
"version": "1.0",
|
|
148
|
-
"breaking_changes_from": [],
|
|
149
|
-
"request": {
|
|
150
|
-
"body": { /* schema */ },
|
|
151
|
-
"query": { /* schema */ },
|
|
152
|
-
"headers": { /* required headers */ }
|
|
153
|
-
},
|
|
154
|
-
"responses": {
|
|
155
|
-
"200": { /* success schema */ },
|
|
156
|
-
"400": { /* error schema */ },
|
|
157
|
-
"401": { /* auth error */ }
|
|
158
|
-
},
|
|
159
|
-
"auth_required": true,
|
|
160
|
-
"rate_limit": "100/hour"
|
|
161
|
-
}
|
|
162
|
-
]
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Step 4: Mark Breaking Changes
|
|
167
|
-
|
|
168
|
-
If changes break existing clients:
|
|
169
|
-
|
|
170
|
-
```markdown
|
|
171
|
-
## Breaking Changes in v2.0
|
|
172
|
-
|
|
173
|
-
### Changed: POST /api/v1/resource
|
|
174
|
-
- Old: Returns `id`, `name`, `created_at`
|
|
175
|
-
- New: Returns `resourceId`, `title`, `timestamp`
|
|
176
|
-
- Impact: Clients expecting `id` field will break
|
|
177
|
-
- Migration: Map `resourceId` → `id` in client code
|
|
178
|
-
- Deadline: Migrate by [date], v1 endpoints removed [date]
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Step 5: Generate Test Contracts
|
|
182
|
-
|
|
183
|
-
Automatically create test schemas:
|
|
184
|
-
|
|
185
|
-
```javascript
|
|
186
|
-
// tests/contracts/api.test.ts
|
|
187
|
-
import { apiContracts } from '.codebase/API_CONTRACTS.md'
|
|
188
|
-
|
|
189
|
-
describe('API Contracts', () => {
|
|
190
|
-
apiContracts.endpoints.forEach(endpoint => {
|
|
191
|
-
it(`${endpoint.method} ${endpoint.path}`, async () => {
|
|
192
|
-
const response = await request(endpoint.method, endpoint.path)
|
|
193
|
-
validateSchema(response, endpoint.responses)
|
|
194
|
-
})
|
|
195
|
-
})
|
|
196
|
-
})
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### Step 6: Document Migration Path
|
|
200
|
-
|
|
201
|
-
If breaking changes exist:
|
|
202
|
-
|
|
203
|
-
```markdown
|
|
204
|
-
## Migration Guide
|
|
205
|
-
|
|
206
|
-
### From v1.0 → v2.0
|
|
207
|
-
|
|
208
|
-
#### Step 1: Update request payloads
|
|
209
|
-
```
|
|
210
|
-
// OLD
|
|
211
|
-
POST /api/v1/resource
|
|
212
|
-
{ "name": "Test" }
|
|
213
|
-
|
|
214
|
-
// NEW
|
|
215
|
-
POST /api/v2/resource
|
|
216
|
-
{ "title": "Test" }
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
#### Step 2: Update response parsing
|
|
220
|
-
```
|
|
221
|
-
// OLD
|
|
222
|
-
const id = data.id
|
|
223
|
-
|
|
224
|
-
// NEW
|
|
225
|
-
const id = data.resourceId
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
#### Step 3: Timeline
|
|
229
|
-
- June 1: v2 available alongside v1
|
|
230
|
-
- July 1: Clients should migrate
|
|
231
|
-
- August 1: v1 endpoints deprecated
|
|
232
|
-
- September 1: v1 endpoints removed
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
---
|
|
236
|
-
|
|
237
|
-
## Usage in Workflow
|
|
238
|
-
|
|
239
|
-
### During Feature Implementation
|
|
240
|
-
|
|
241
|
-
```bash
|
|
242
|
-
# 1. Implement API changes
|
|
243
|
-
# 2. Write tests with new contract
|
|
244
|
-
# 3. Run tests - should pass
|
|
245
|
-
|
|
246
|
-
# 4. After tests pass, sync contracts:
|
|
247
|
-
invoke api-sync-skill
|
|
248
|
-
|
|
249
|
-
# Parameters:
|
|
250
|
-
- changed_files: ["src/api/users.ts", "src/routes/auth.ts"]
|
|
251
|
-
- contract_file: ".codebase/API_CONTRACTS.md"
|
|
252
|
-
- breaking_changes: true/false
|
|
253
|
-
- version_bump: "major/minor/patch"
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
### After Sync Completed
|
|
257
|
-
|
|
258
|
-
```
|
|
259
|
-
✓ API_CONTRACTS.md updated
|
|
260
|
-
✓ Breaking changes documented
|
|
261
|
-
✓ Test contracts generated
|
|
262
|
-
✓ Migration guide created
|
|
263
|
-
✓ All tests still passing
|
|
264
|
-
|
|
265
|
-
→ Ready to merge
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
---
|
|
269
|
-
|
|
270
|
-
## Skills Integration
|
|
271
|
-
|
|
272
|
-
Works alongside:
|
|
273
|
-
- **planning-skill**: Captures API requirements in plan
|
|
274
|
-
- **api-contract-skill**: Defines contracts before implementation
|
|
275
|
-
- **design-spec-skill**: Documents API design decisions
|
|
276
|
-
- **docs-skill**: Updates README and API docs
|
|
277
|
-
|
|
278
|
-
---
|
|
279
|
-
|
|
280
|
-
## Common Patterns
|
|
281
|
-
|
|
282
|
-
### Pattern: API Versioning
|
|
283
|
-
|
|
284
|
-
```
|
|
285
|
-
OLD (v1)
|
|
286
|
-
GET /api/users
|
|
287
|
-
|
|
288
|
-
NEW (v2)
|
|
289
|
-
GET /api/v2/users
|
|
290
|
-
|
|
291
|
-
Contract update:
|
|
292
|
-
- Keep v1 endpoint
|
|
293
|
-
- Mark as deprecated
|
|
294
|
-
- Point to v2 docs
|
|
295
|
-
- Set removal date
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
### Pattern: Endpoint Evolution
|
|
299
|
-
|
|
300
|
-
```
|
|
301
|
-
Phase 1: New parameter added
|
|
302
|
-
POST /api/resource → POST /api/resource?newParam=true
|
|
303
|
-
Contract: Mark parameter as optional
|
|
304
|
-
|
|
305
|
-
Phase 2: Parameter required
|
|
306
|
-
POST /api/resource?newParam=true
|
|
307
|
-
Contract: Mark parameter as required
|
|
308
|
-
|
|
309
|
-
Phase 3: Old behavior removed
|
|
310
|
-
POST /api/resource → now requires newParam
|
|
311
|
-
Contract: Break version, update contract
|
|
312
|
-
|
|
313
|
-
Clients get: 2 quarters to migrate
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
### Pattern: Error Code Addition
|
|
317
|
-
|
|
318
|
-
```
|
|
319
|
-
OLD
|
|
320
|
-
POST /api/payment
|
|
321
|
-
Error: 400 Bad Request
|
|
322
|
-
|
|
323
|
-
NEW
|
|
324
|
-
POST /api/payment
|
|
325
|
-
Errors:
|
|
326
|
-
- 400 Bad Request
|
|
327
|
-
- 402 Payment Required (NEW)
|
|
328
|
-
- 429 Too Many Requests (NEW)
|
|
329
|
-
|
|
330
|
-
Contract: Document all codes with examples
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
---
|
|
334
|
-
|
|
335
|
-
## Acceptance Checklist
|
|
336
|
-
|
|
337
|
-
- [ ] All endpoints extracted from code
|
|
338
|
-
- [ ] Request/response schemas defined
|
|
339
|
-
- [ ] HTTP methods correct
|
|
340
|
-
- [ ] Status codes complete
|
|
341
|
-
- [ ] Auth requirements documented
|
|
342
|
-
- [ ] Breaking changes identified and marked
|
|
343
|
-
- [ ] Test contracts generated
|
|
344
|
-
- [ ] All API tests passing
|
|
345
|
-
- [ ] Migration guide created (if needed)
|
|
346
|
-
- [ ] `.codebase/API_CONTRACTS.md` updated
|
|
347
|
-
- [ ] Documentation updated
|
|
348
|
-
- [ ] Version number incremented
|
|
349
|
-
|
|
350
|
-
---
|
|
351
|
-
|
|
352
|
-
**Last Updated**: 2026-05-30
|
|
353
|
-
**Maintained By**: Genesis Harness Team
|
|
354
|
-
**Version**: 1.0
|
|
1
|
+
---
|
|
2
|
+
name: api-sync-skill
|
|
3
|
+
description: Automatic API contract synchronization. Detects API changes in implementation, updates API_CONTRACTS.md, regenerates test contracts, and maintains backward compatibility documentation. Use after API-related implementation or when contracts drift from actual code.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# API Sync Skill
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Keep API contracts synchronized with actual implementation. Detect changes, update contracts, regenerate tests, and document breaking changes automatically.
|
|
11
|
+
|
|
12
|
+
## When to use
|
|
13
|
+
|
|
14
|
+
Use after API-related implementation when:
|
|
15
|
+
- New endpoints added
|
|
16
|
+
- Endpoint behavior changed
|
|
17
|
+
- Request/response schemas modified
|
|
18
|
+
- Error handling updated
|
|
19
|
+
- Authentication/authorization changed
|
|
20
|
+
- Deprecated endpoints need removal
|
|
21
|
+
|
|
22
|
+
## When NOT to use
|
|
23
|
+
|
|
24
|
+
Do not use for read-only API documentation or when contract-first design hasn't been completed yet.
|
|
25
|
+
|
|
26
|
+
## Inputs required
|
|
27
|
+
|
|
28
|
+
- Changed implementation files (API routes, controllers, handlers)
|
|
29
|
+
- Current API_CONTRACTS.md file
|
|
30
|
+
- Test suite location
|
|
31
|
+
- Breaking change impact assessment
|
|
32
|
+
|
|
33
|
+
## Outputs required
|
|
34
|
+
|
|
35
|
+
- Updated API_CONTRACTS.md with all changes
|
|
36
|
+
- Updated API test contracts
|
|
37
|
+
- Test code reflecting new contracts
|
|
38
|
+
- Migration guide for breaking changes (if applicable)
|
|
39
|
+
- Backward compatibility documentation
|
|
40
|
+
|
|
41
|
+
## Required tests
|
|
42
|
+
|
|
43
|
+
- Contract validation tests (request/response schemas)
|
|
44
|
+
- API integration tests updated
|
|
45
|
+
- Backward compatibility tests (if versioning)
|
|
46
|
+
- Error handling tests
|
|
47
|
+
|
|
48
|
+
## Required fixtures
|
|
49
|
+
|
|
50
|
+
- Updated endpoint fixtures
|
|
51
|
+
- Request/response examples
|
|
52
|
+
- Error scenario fixtures
|
|
53
|
+
- Edge case payloads
|
|
54
|
+
|
|
55
|
+
## Required contract updates
|
|
56
|
+
|
|
57
|
+
- API_CONTRACTS.md (primary)
|
|
58
|
+
- Versioning info (if breaking changes)
|
|
59
|
+
- Deprecation notices (if applicable)
|
|
60
|
+
- Migration guide (if breaking changes)
|
|
61
|
+
|
|
62
|
+
## Required codebase map updates
|
|
63
|
+
|
|
64
|
+
- `.codebase/API_CONTRACTS.md` - complete update
|
|
65
|
+
- `.codebase/CURRENT_STATE.md` - note API changes
|
|
66
|
+
- `.codebase/KNOWN_PROBLEMS.md` - document migration issues
|
|
67
|
+
- `.codebase/EVOLUTION_PLAN.md` - next API phases
|
|
68
|
+
|
|
69
|
+
## Token saving rules
|
|
70
|
+
|
|
71
|
+
Extract schemas programmatically; don't paste entire files. Focus on deltas from previous contracts. Link to test fixtures rather than duplicating examples.
|
|
72
|
+
|
|
73
|
+
## Acceptance criteria
|
|
74
|
+
|
|
75
|
+
- API contracts match actual implementation
|
|
76
|
+
- All endpoints documented with schemas
|
|
77
|
+
- Breaking changes clearly marked
|
|
78
|
+
- Test contracts generated and passing
|
|
79
|
+
- Migration paths documented for breaking changes
|
|
80
|
+
- No contract drift validation passing
|
|
81
|
+
|
|
82
|
+
## Common mistakes
|
|
83
|
+
|
|
84
|
+
- Skipping breaking change documentation
|
|
85
|
+
- Not updating test contracts in parallel
|
|
86
|
+
- Leaving old endpoints undocumented
|
|
87
|
+
- Forgetting error response contracts
|
|
88
|
+
- Not validating backward compatibility
|
|
89
|
+
|
|
90
|
+
## Recovery workflow
|
|
91
|
+
|
|
92
|
+
If contracts drift or sync fails:
|
|
93
|
+
1. Read current API_CONTRACTS.md
|
|
94
|
+
2. Extract actual endpoint schemas from implementation
|
|
95
|
+
3. Identify changes and breaking status
|
|
96
|
+
4. Update contracts with full changelog
|
|
97
|
+
5. Regenerate test contracts
|
|
98
|
+
6. Validate all tests pass
|
|
99
|
+
7. Document migration guide if needed
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Workflow: API Change Detection & Sync
|
|
104
|
+
|
|
105
|
+
### Step 1: Detect API Changes
|
|
106
|
+
|
|
107
|
+
Identify which files contain API code:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
Scan for:
|
|
111
|
+
├─ src/api/**
|
|
112
|
+
├─ src/**/route.ts, routes.ts
|
|
113
|
+
├─ src/**/controller.ts
|
|
114
|
+
├─ src/**/endpoint.ts
|
|
115
|
+
└─ src/**/handler.ts
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For each file, extract:
|
|
119
|
+
- HTTP method (GET, POST, PUT, DELETE, PATCH)
|
|
120
|
+
- Route/path
|
|
121
|
+
- Request schema (params, query, body)
|
|
122
|
+
- Response schema (success, error)
|
|
123
|
+
- Status codes
|
|
124
|
+
- Authentication requirements
|
|
125
|
+
- Rate limiting or other middleware
|
|
126
|
+
|
|
127
|
+
### Step 2: Compare Against Current Contract
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
For each endpoint:
|
|
131
|
+
New? → Add to contract
|
|
132
|
+
Modified? → Mark change and version
|
|
133
|
+
Deleted? → Mark as deprecated
|
|
134
|
+
Unchanged? → Keep as-is
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Step 3: Generate Updated Contracts
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"endpoints": [
|
|
142
|
+
{
|
|
143
|
+
"id": "endpoint-id",
|
|
144
|
+
"method": "POST",
|
|
145
|
+
"path": "/api/v1/resource",
|
|
146
|
+
"description": "Create a new resource",
|
|
147
|
+
"version": "1.0",
|
|
148
|
+
"breaking_changes_from": [],
|
|
149
|
+
"request": {
|
|
150
|
+
"body": { /* schema */ },
|
|
151
|
+
"query": { /* schema */ },
|
|
152
|
+
"headers": { /* required headers */ }
|
|
153
|
+
},
|
|
154
|
+
"responses": {
|
|
155
|
+
"200": { /* success schema */ },
|
|
156
|
+
"400": { /* error schema */ },
|
|
157
|
+
"401": { /* auth error */ }
|
|
158
|
+
},
|
|
159
|
+
"auth_required": true,
|
|
160
|
+
"rate_limit": "100/hour"
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Step 4: Mark Breaking Changes
|
|
167
|
+
|
|
168
|
+
If changes break existing clients:
|
|
169
|
+
|
|
170
|
+
```markdown
|
|
171
|
+
## Breaking Changes in v2.0
|
|
172
|
+
|
|
173
|
+
### Changed: POST /api/v1/resource
|
|
174
|
+
- Old: Returns `id`, `name`, `created_at`
|
|
175
|
+
- New: Returns `resourceId`, `title`, `timestamp`
|
|
176
|
+
- Impact: Clients expecting `id` field will break
|
|
177
|
+
- Migration: Map `resourceId` → `id` in client code
|
|
178
|
+
- Deadline: Migrate by [date], v1 endpoints removed [date]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Step 5: Generate Test Contracts
|
|
182
|
+
|
|
183
|
+
Automatically create test schemas:
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
// tests/contracts/api.test.ts
|
|
187
|
+
import { apiContracts } from '.codebase/API_CONTRACTS.md'
|
|
188
|
+
|
|
189
|
+
describe('API Contracts', () => {
|
|
190
|
+
apiContracts.endpoints.forEach(endpoint => {
|
|
191
|
+
it(`${endpoint.method} ${endpoint.path}`, async () => {
|
|
192
|
+
const response = await request(endpoint.method, endpoint.path)
|
|
193
|
+
validateSchema(response, endpoint.responses)
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Step 6: Document Migration Path
|
|
200
|
+
|
|
201
|
+
If breaking changes exist:
|
|
202
|
+
|
|
203
|
+
```markdown
|
|
204
|
+
## Migration Guide
|
|
205
|
+
|
|
206
|
+
### From v1.0 → v2.0
|
|
207
|
+
|
|
208
|
+
#### Step 1: Update request payloads
|
|
209
|
+
```
|
|
210
|
+
// OLD
|
|
211
|
+
POST /api/v1/resource
|
|
212
|
+
{ "name": "Test" }
|
|
213
|
+
|
|
214
|
+
// NEW
|
|
215
|
+
POST /api/v2/resource
|
|
216
|
+
{ "title": "Test" }
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### Step 2: Update response parsing
|
|
220
|
+
```
|
|
221
|
+
// OLD
|
|
222
|
+
const id = data.id
|
|
223
|
+
|
|
224
|
+
// NEW
|
|
225
|
+
const id = data.resourceId
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### Step 3: Timeline
|
|
229
|
+
- June 1: v2 available alongside v1
|
|
230
|
+
- July 1: Clients should migrate
|
|
231
|
+
- August 1: v1 endpoints deprecated
|
|
232
|
+
- September 1: v1 endpoints removed
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Usage in Workflow
|
|
238
|
+
|
|
239
|
+
### During Feature Implementation
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# 1. Implement API changes
|
|
243
|
+
# 2. Write tests with new contract
|
|
244
|
+
# 3. Run tests - should pass
|
|
245
|
+
|
|
246
|
+
# 4. After tests pass, sync contracts:
|
|
247
|
+
invoke api-sync-skill
|
|
248
|
+
|
|
249
|
+
# Parameters:
|
|
250
|
+
- changed_files: ["src/api/users.ts", "src/routes/auth.ts"]
|
|
251
|
+
- contract_file: ".codebase/API_CONTRACTS.md"
|
|
252
|
+
- breaking_changes: true/false
|
|
253
|
+
- version_bump: "major/minor/patch"
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### After Sync Completed
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
✓ API_CONTRACTS.md updated
|
|
260
|
+
✓ Breaking changes documented
|
|
261
|
+
✓ Test contracts generated
|
|
262
|
+
✓ Migration guide created
|
|
263
|
+
✓ All tests still passing
|
|
264
|
+
|
|
265
|
+
→ Ready to merge
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Skills Integration
|
|
271
|
+
|
|
272
|
+
Works alongside:
|
|
273
|
+
- **planning-skill**: Captures API requirements in plan
|
|
274
|
+
- **api-contract-skill**: Defines contracts before implementation
|
|
275
|
+
- **design-spec-skill**: Documents API design decisions
|
|
276
|
+
- **docs-skill**: Updates README and API docs
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Common Patterns
|
|
281
|
+
|
|
282
|
+
### Pattern: API Versioning
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
OLD (v1)
|
|
286
|
+
GET /api/users
|
|
287
|
+
|
|
288
|
+
NEW (v2)
|
|
289
|
+
GET /api/v2/users
|
|
290
|
+
|
|
291
|
+
Contract update:
|
|
292
|
+
- Keep v1 endpoint
|
|
293
|
+
- Mark as deprecated
|
|
294
|
+
- Point to v2 docs
|
|
295
|
+
- Set removal date
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Pattern: Endpoint Evolution
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
Phase 1: New parameter added
|
|
302
|
+
POST /api/resource → POST /api/resource?newParam=true
|
|
303
|
+
Contract: Mark parameter as optional
|
|
304
|
+
|
|
305
|
+
Phase 2: Parameter required
|
|
306
|
+
POST /api/resource?newParam=true
|
|
307
|
+
Contract: Mark parameter as required
|
|
308
|
+
|
|
309
|
+
Phase 3: Old behavior removed
|
|
310
|
+
POST /api/resource → now requires newParam
|
|
311
|
+
Contract: Break version, update contract
|
|
312
|
+
|
|
313
|
+
Clients get: 2 quarters to migrate
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Pattern: Error Code Addition
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
OLD
|
|
320
|
+
POST /api/payment
|
|
321
|
+
Error: 400 Bad Request
|
|
322
|
+
|
|
323
|
+
NEW
|
|
324
|
+
POST /api/payment
|
|
325
|
+
Errors:
|
|
326
|
+
- 400 Bad Request
|
|
327
|
+
- 402 Payment Required (NEW)
|
|
328
|
+
- 429 Too Many Requests (NEW)
|
|
329
|
+
|
|
330
|
+
Contract: Document all codes with examples
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Acceptance Checklist
|
|
336
|
+
|
|
337
|
+
- [ ] All endpoints extracted from code
|
|
338
|
+
- [ ] Request/response schemas defined
|
|
339
|
+
- [ ] HTTP methods correct
|
|
340
|
+
- [ ] Status codes complete
|
|
341
|
+
- [ ] Auth requirements documented
|
|
342
|
+
- [ ] Breaking changes identified and marked
|
|
343
|
+
- [ ] Test contracts generated
|
|
344
|
+
- [ ] All API tests passing
|
|
345
|
+
- [ ] Migration guide created (if needed)
|
|
346
|
+
- [ ] `.codebase/API_CONTRACTS.md` updated
|
|
347
|
+
- [ ] Documentation updated
|
|
348
|
+
- [ ] Version number incremented
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
**Last Updated**: 2026-05-30
|
|
353
|
+
**Maintained By**: Genesis Harness Team
|
|
354
|
+
**Version**: 1.0
|