contract-driven-delivery 1.10.0 → 1.12.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +532 -135
  3. package/assets/CLAUDE.template.md +34 -0
  4. package/assets/CODEX.template.md +39 -0
  5. package/assets/agents/backend-engineer.md +15 -0
  6. package/assets/agents/change-classifier.md +57 -1
  7. package/assets/agents/ci-cd-gatekeeper.md +15 -0
  8. package/assets/agents/contract-reviewer.md +15 -0
  9. package/assets/agents/dependency-security-reviewer.md +2 -0
  10. package/assets/agents/e2e-resilience-engineer.md +15 -0
  11. package/assets/agents/frontend-engineer.md +15 -0
  12. package/assets/agents/monkey-test-engineer.md +15 -0
  13. package/assets/agents/qa-reviewer.md +15 -0
  14. package/assets/agents/repo-context-scanner.md +2 -0
  15. package/assets/agents/spec-architect.md +15 -0
  16. package/assets/agents/spec-drift-auditor.md +2 -0
  17. package/assets/agents/stress-soak-engineer.md +15 -0
  18. package/assets/agents/test-strategist.md +15 -0
  19. package/assets/agents/ui-ux-reviewer.md +2 -0
  20. package/assets/agents/visual-reviewer.md +2 -0
  21. package/assets/cdd/context-policy.json +25 -0
  22. package/assets/cdd/model-policy.json +5 -0
  23. package/assets/contracts/api/api-contract.md +3 -0
  24. package/assets/contracts/api/api-inventory.md +7 -0
  25. package/assets/contracts/api/error-format.md +7 -0
  26. package/assets/contracts/business/business-rules.md +3 -0
  27. package/assets/contracts/ci/ci-gate-contract.md +3 -0
  28. package/assets/contracts/css/css-contract.md +3 -0
  29. package/assets/contracts/css/design-tokens.md +7 -0
  30. package/assets/contracts/data/data-shape-contract.md +3 -0
  31. package/assets/contracts/env/env-contract.md +3 -0
  32. package/assets/hooks/pre-commit +1 -1
  33. package/assets/skills/cdd-close/SKILL.md +150 -0
  34. package/assets/skills/cdd-new/SKILL.md +94 -35
  35. package/assets/skills/cdd-resume/SKILL.md +114 -0
  36. package/assets/skills/contract-driven-delivery/templates/change-classification.md +9 -8
  37. package/assets/skills/contract-driven-delivery/templates/tasks.md +7 -0
  38. package/assets/specs-templates/change-classification.md +9 -8
  39. package/assets/specs-templates/context-manifest.md +49 -0
  40. package/assets/specs-templates/tasks.md +9 -0
  41. package/dist/cli/index.js +1846 -152
  42. package/docs/release-checklist.md +39 -0
  43. package/package.json +12 -6
package/README.md CHANGED
@@ -1,96 +1,479 @@
1
1
  # Contract-Driven Delivery Kit
2
2
 
3
- A reusable Claude Code development kit for brownfield full-stack systems that need specification-driven development, test-driven development, strict contracts, CI/CD gates, visual review, E2E, resilience, fuzz/monkey, stress, and soak testing.
3
+ **cdd-kit** is a contract-driven delivery kit for AI coding agents. It started with Claude Code skills and now keeps the core workflow provider-neutral: contracts-first, test-first, spec-first. Every change goes through classification, contract review, TDD, implementation, and gate verification.
4
4
 
5
- This kit is designed for internal production systems such as dashboards, reporting systems, workflow tools, and data-heavy web apps. It is repo-informed but repo-agnostic: install it once, deploy it into any repository, and apply the same delivery discipline without repeating instructions every time.
5
+ Designed for solo developers and small teams building brownfield production systems (dashboards, APIs, workflow tools, data apps) who want AI to do all the implementation while they stay in the spec-author and reviewer seat.
6
6
 
7
- ## Install via npm
7
+ **Context Governance v1** adds a manifest-driven audit layer for AI agents. New changes include `context-manifest.md`, `agent-log` entries are expected to report `files-read`, and `cdd-kit gate` audits those reads against allowed and forbidden paths. This is governance and review support, not a sandbox.
8
+
9
+ ---
10
+
11
+ ## Install
8
12
 
9
13
  ```bash
10
14
  npm install -g contract-driven-delivery
11
15
  ```
12
16
 
13
- Requires Node.js 18+ and Python 3.8+.
17
+ Requires **Node.js 18+** and **Python 3.8+** (for contract validators).
18
+
19
+ ---
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ # 1. Install globally
25
+ npm install -g contract-driven-delivery
26
+
27
+ # 2. Go to your repo
28
+ cd your-repo
29
+
30
+ # 3. Deploy the kit
31
+ cdd-kit init
32
+
33
+ # 4. Open Claude Code in your repo and tell Claude:
34
+ # "Use /cdd-new to set up the project. My system is a <brief description>."
35
+ ```
36
+
37
+ ---
38
+
39
+ ## How to Direct Claude Code
40
+
41
+ > All workflows are started by typing a **natural language instruction** to Claude Code in your IDE or terminal. The `/cdd-*` prefixed commands are Claude Code skills — not shell commands.
42
+
43
+ ### Starting a new project (first time)
44
+
45
+ After `cdd-kit init`, open Claude Code and say:
46
+
47
+ ```
48
+ Scan this repo and create a project profile. Tell me what contracts are
49
+ missing and what the minimum setup should be before we start any feature work.
50
+ ```
51
+
52
+ Claude will:
53
+ 1. Run `cdd-kit detect-stack` to detect the tech stack
54
+ 2. Read your existing code structure
55
+ 3. Create `specs/project-profile.md`
56
+ 4. Identify gaps in `contracts/` and recommend filling order
57
+
58
+ Then fill your contracts in this order (Claude can help draft them):
59
+
60
+ | Contract | File | What it captures |
61
+ |---|---|---|
62
+ | Env | `contracts/env/env-contract.md` | Every env var, secret flag, default, validation |
63
+ | API | `contracts/api/api-contract.md` | Every endpoint: method, path, auth, schemas, errors |
64
+ | Data | `contracts/data/data-shape-contract.md` | Schemas, types, nullability, bad-data behavior |
65
+ | CSS/UI | `contracts/css/css-contract.md` | Design tokens, component states, forbidden raw values |
66
+ | Business | `contracts/business/business-rules.md` | Rules, edge cases, decision tables |
67
+ | CI/CD | `contracts/ci/ci-gate-contract.md` | Gate tiers, promotion policy, rollback policy |
68
+
69
+ ---
70
+
71
+ ### Starting a new task / feature / bug fix
72
+
73
+ Type this in Claude Code:
74
+
75
+ ```
76
+ /cdd-new add JWT authentication to the API
77
+ ```
78
+
79
+ or
80
+
81
+ ```
82
+ /cdd-new redesign the user dashboard to show real-time metrics
83
+ ```
84
+
85
+ or
86
+
87
+ ```
88
+ /cdd-new fix the order export timeout when result set exceeds 10 000 rows
89
+ ```
90
+
91
+ **What happens:**
92
+ 1. Claude generates a `change-id` (e.g. `add-jwt-auth`) and scaffolds `specs/changes/add-jwt-auth/`
93
+ 2. The `change-classifier` agent (Opus) reads the request, classifies risk and tier, decides which agents are needed
94
+ 3. Agents run in order: contracts → test plan → spec/architecture review (if needed) → backend engineer → frontend engineer → CI/CD gates → QA
95
+ 4. Each agent produces machine-verifiable evidence (agent-log files)
96
+ 5. `cdd-kit gate <change-id>` runs automatically to confirm all artifacts are complete
97
+ 6. Claude reports a summary and the suggested git commit
98
+
99
+ **You stay in control by:**
100
+ - Reviewing the `change-classification.md` before implementation starts
101
+ - Checking the `test-plan.md` to confirm the right test families are planned
102
+ - Reading the final `agent-log/qa-reviewer.md` for the release-readiness verdict
103
+
104
+ ---
105
+
106
+ ### Updating architecture or contracts
107
+
108
+ ```
109
+ /cdd-new update the API contract to add pagination to all list endpoints
110
+ ```
111
+
112
+ ```
113
+ /cdd-new migrate the database from MySQL to PostgreSQL
114
+ ```
115
+
116
+ ```
117
+ /cdd-new add Redis caching layer to the reporting queries
118
+ ```
119
+
120
+ The change-classifier will detect that these are architectural or contract-level changes, assign a higher risk tier (0–2), and automatically require:
121
+ - Architecture review (`spec-architect` agent)
122
+ - E2E, resilience, stress, and monkey tests
123
+ - Updated contracts before any implementation begins
124
+
125
+ ---
126
+
127
+ ### Resuming an interrupted task
128
+
129
+ If a session was cut off or you need to return to an in-progress change:
130
+
131
+ ```
132
+ /cdd-resume add-jwt-auth
133
+ ```
134
+
135
+ or, if you're unsure of the change-id:
136
+
137
+ ```
138
+ What changes are currently in progress? (cdd-kit list)
139
+ ```
140
+
141
+ **What happens:**
142
+ 1. Claude reads `tasks.md` and `agent-log/` to determine what was completed
143
+ 2. Reports the current state (which agents ran, which tasks are pending)
144
+ 3. Asks if you want to continue from the next pending agent
145
+ 4. Resumes the full agent flow from where it stopped, with no duplication
146
+
147
+ > If you're upgrading from an older version and your change was created before v1.11.0, Claude will automatically run `cdd-kit migrate <change-id>` to upgrade the format before resuming.
148
+
149
+ ---
150
+
151
+ ### Closing a completed change
152
+
153
+ After the PR is merged:
154
+
155
+ ```
156
+ /cdd-close add-jwt-auth
157
+ ```
158
+
159
+ **What happens:**
160
+ 1. Runs `cdd-kit gate` to confirm the change still passes
161
+ 2. Synthesizes `archive.md` — a permanent record of what changed, what tests were added, and what lessons were found
162
+ 3. Invokes `contract-reviewer` to propose any durable learnings back into `contracts/`
163
+ 4. Runs `cdd-kit archive add-jwt-auth` — moves the change from `specs/changes/` to `specs/archive/2026/`
164
+ 5. Reduces the active context that future Claude sessions need to load
165
+
166
+ ---
167
+
168
+ ### Abandoning a change
169
+
170
+ If you decide not to proceed with a change:
171
+
172
+ ```
173
+ /cdd-close add-jwt-auth
174
+ ```
175
+
176
+ Then when Claude asks for confirmation, say "abandon it." Claude will run:
177
+
178
+ ```bash
179
+ cdd-kit abandon add-jwt-auth --reason "decided to use a third-party auth service instead"
180
+ ```
181
+
182
+ The directory stays on disk for git history, but `cdd-kit list` will show it as `abandoned`.
183
+
184
+ ---
185
+
186
+ ### Checking the status of all active changes
187
+
188
+ Type to Claude:
189
+
190
+ ```
191
+ What changes are currently in progress?
192
+ ```
193
+
194
+ Claude will run `cdd-kit list`, which shows:
195
+
196
+ ```
197
+ Active changes:
198
+ add-jwt-auth [in-progress] (3 pending)
199
+ fix-export-timeout [gate-blocked]
200
+ redesign-dashboard [in-progress] (12 pending)
201
+ ```
202
+
203
+ ---
204
+
205
+ ## CLI Reference
14
206
 
15
- ## CLI Usage
207
+ These are shell commands — not Claude Code skills. Run them directly in the terminal, or Claude Code will run them on your behalf.
16
208
 
17
209
  ### `cdd-kit init`
18
210
 
19
- Installs Claude Code agents and the `contract-driven-delivery` skill into `~/.claude`, and scaffolds project files (`contracts/`, `specs/templates/`, `tests/templates/`, `ci/`, `CLAUDE.md`, `AGENTS.md`) into the current repository.
211
+ Installs agents and skill into `~/.claude` and scaffolds project files.
20
212
 
21
213
  ```bash
22
- cdd-kit init # global + local (recommended for first-time setup)
23
- cdd-kit init --global-only # only install agents/skill into ~/.claude
24
- cdd-kit init --local-only # only scaffold project files in current repo
25
- cdd-kit init --force # overwrite existing project files (CLAUDE.md is never overwritten)
214
+ cdd-kit init # global + local (recommended)
215
+ cdd-kit init --global-only # only install into ~/.claude
216
+ cdd-kit init --local-only # only scaffold project files
217
+ cdd-kit init --provider codex # scaffold Codex-oriented project guidance
218
+ cdd-kit init --provider both # scaffold Claude Code + Codex guidance
219
+ cdd-kit init --force # overwrite existing project files
26
220
  ```
27
221
 
222
+ Creates: `contracts/`, `specs/templates/`, provider guidance files (`CLAUDE.md`, `AGENTS.md`, and/or `CODEX.md`), `hooks/`
223
+
224
+ ---
225
+
28
226
  ### `cdd-kit update`
29
227
 
30
- Updates the agents and skill in `~/.claude` to the latest installed version. Does not touch project-level files like `contracts/` or `CLAUDE.md`.
228
+ Updates provider assets to the latest installed version. By default, `update` reads `.cdd/model-policy.json` and updates only the matching provider adapter. It does not overwrite project guidance files such as `CLAUDE.md`, `AGENTS.md`, or `CODEX.md`.
31
229
 
32
230
  ```bash
33
231
  cdd-kit update
232
+ cdd-kit update --yes # apply without confirmation
233
+ cdd-kit update --provider codex
234
+ cdd-kit update --provider both
34
235
  ```
35
236
 
36
- ### `cdd-kit new <name>`
237
+ Codex currently has no global assets to update, so Codex-only projects report that they are already up to date. Run `cdd-kit init --local-only --provider codex` if a project is missing `CODEX.md`.
37
238
 
38
- Creates a new change scaffold under `specs/changes/<name>/` with the required template files.
239
+ ---
240
+
241
+ ### `cdd-kit doctor`
242
+
243
+ Inspects repo-level cdd-kit health without writing files.
39
244
 
40
245
  ```bash
41
- cdd-kit new add-user-auth # required templates only
42
- cdd-kit new add-user-auth --all # include all optional templates
43
- cdd-kit new add-user-auth --force # re-scaffold even if directory already exists
246
+ cdd-kit doctor
247
+ cdd-kit doctor --strict
248
+ cdd-kit doctor --json
249
+ cdd-kit doctor --provider codex
44
250
  ```
45
251
 
46
- Required templates: `change-request.md`, `change-classification.md`, `test-plan.md`, `ci-gates.md`, `tasks.md`
252
+ Checks for missing `.cdd/` policy files, provider guidance (`CLAUDE.md`, `AGENTS.md`, `CODEX.md`), context indexes, stale `specs/context/*` outputs, and contract summary metadata gaps. `--strict` treats warnings as errors. `--json` emits a machine-readable report for CI or wrapper scripts.
47
253
 
48
- Optional templates (with `--all`): `current-behavior.md`, `proposal.md`, `spec.md`, `design.md`, `contracts.md`, `qa-report.md`, `regression-report.md`, `archive.md`
254
+ ---
49
255
 
50
- ### `cdd-kit validate`
256
+ ### `cdd-kit upgrade`
51
257
 
52
- Runs contract validation scripts against the current repository.
258
+ Adds missing repo-level cdd-kit files after upgrading the npm package. It preserves existing contracts and guidance files; default mode is a dry run.
53
259
 
54
260
  ```bash
55
- cdd-kit validate # run all validators
56
- cdd-kit validate --contracts # validate API/data/CSS contracts + semantic validators
57
- cdd-kit validate --env # validate env contract
58
- cdd-kit validate --ci # validate CI gate policy
59
- cdd-kit validate --spec # validate spec traceability
261
+ cdd-kit upgrade
262
+ cdd-kit upgrade --yes
263
+ cdd-kit upgrade --yes --migrate-changes
264
+ cdd-kit upgrade --yes --migrate-changes --enable-context-governance
265
+ cdd-kit upgrade --provider codex --yes
266
+ cdd-kit upgrade --provider both --yes
60
267
  ```
61
268
 
62
- `--contracts` also chains two semantic validators:
63
- - **API semantic**: checks endpoint table for valid HTTP methods, paths starting with `/`, and valid auth values.
64
- - **Env semantic**: checks variable table for secrets with default values (forbidden), and warns on required non-secret vars with no default.
269
+ Use this for old repos that already have `contracts/` or `specs/` but are missing new assets such as `.cdd/context-policy.json`, `.cdd/model-policy.json`, `CODEX.md`, or newer templates. Add `--migrate-changes` if you also want to upgrade existing `specs/changes/<change-id>/` directories in the same run.
270
+
271
+ ---
65
272
 
66
273
  ### `cdd-kit gate <change-id>`
67
274
 
68
- Validates that a change has completed the full orchestration workflow before it can be committed or shipped. Checks: directory exists, all 5 required artifacts are present, each has > 100 meaningful characters (not a stub), `change-classification.md` contains a tier or risk marker, and all contract validators pass.
275
+ The single quality gate for a change. Blocks merge if anything is missing or incomplete.
69
276
 
70
277
  ```bash
71
- cdd-kit gate add-user-auth
72
- # gate passed for change: add-user-auth
278
+ cdd-kit gate add-jwt-auth
279
+ cdd-kit gate add-jwt-auth --strict
73
280
  ```
74
281
 
75
- Failure examples:
282
+ Checks:
283
+ - All required artifacts exist (`change-request.md`, `change-classification.md`, `test-plan.md`, `ci-gates.md`, `tasks.md`; new context-governed changes also require `context-manifest.md`)
284
+ - Each artifact has sufficient content (not a stub): change-classification ≥ 200 chars, test-plan ≥ 200, ci-gates ≥ 150, others ≥ 100
285
+ - `change-classification.md` contains a tier or risk marker
286
+ - `agent-log/*.md` files all have `status: complete` (not blocked)
287
+ - For context-governed changes, `agent-log/*.md` files include a structured `- files-read:` list and those repo-relative paths are audited against `context-manifest.md` and `.cdd/context-policy.json`
288
+ - Atomic `depends-on` upstream changes are completed or archived before dependent work gates
289
+ - Tier 0–1 changes have `e2e-resilience-engineer`, `monkey-test-engineer`, and `stress-soak-engineer` logs
290
+ - Tier 0–3 changes have `contract-reviewer` and `qa-reviewer` logs
291
+ - All contract validators pass
292
+
293
+ `--strict` additionally:
294
+ - Treats any pending `[ ]` tasks (except section 7 archive items) as errors
295
+ - Validates that every file path listed in `agent-log` artifact pointers actually exists on disk
296
+ - Treats legacy changes missing `context-manifest.md` or `files-read` audit data as errors
297
+
298
+ Pre-commit hook uses `--strict` by default (installed via `cdd-kit install-hooks`).
299
+
76
300
  ```
301
+ ✓ gate passed for change: add-jwt-auth
302
+
77
303
  ✗ gate failed for change: feat-001
78
- missing required artifact: tasks.md
79
- change-classification.md: missing tier/risk marker (Tier 0-5 or low/medium/high/critical)
304
+ change-classification.md: appears to be a stub (< 200 meaningful chars)
305
+ Tier 1 change requires agent-log/e2e-resilience-engineer.md
306
+ ✗ 1 task(s) still pending (use [-] for N/A items, [x] for done)
307
+ ```
308
+
309
+ ---
310
+
311
+ ### `cdd-kit list`
312
+
313
+ Lists all active changes in `specs/changes/` with status and pending task count.
314
+
315
+ ```bash
316
+ cdd-kit list
317
+ ```
318
+
319
+ ```
320
+ Active changes:
321
+ add-jwt-auth [in-progress] (3 pending)
322
+ fix-export-timeout [gate-blocked]
323
+ old-experiment [abandoned]
324
+ ```
325
+
326
+ ---
327
+
328
+ ### `cdd-kit archive <change-id>`
329
+
330
+ Physically moves a completed change from `specs/changes/` to `specs/archive/<year>/`.
331
+
332
+ ```bash
333
+ cdd-kit archive add-jwt-auth
334
+ # ✓ Archived: specs/changes/add-jwt-auth → specs/archive/2026/add-jwt-auth
335
+ # ✓ Index updated: specs/archive/INDEX.md
336
+ ```
337
+
338
+ Warns (but does not block) if `tasks.md` has pending items or `status: gate-blocked`. Use after `/cdd-close` — the skill runs this automatically at the end.
339
+
340
+ ---
341
+
342
+ ### `cdd-kit abandon <change-id>`
343
+
344
+ Marks a change as abandoned. Updates `tasks.md` status to `abandoned`, records the reason in `specs/archive/INDEX.md`. The directory stays on disk for git history.
345
+
346
+ ```bash
347
+ cdd-kit abandon add-jwt-auth --reason "using Auth0 instead"
348
+ # ✓ Change add-jwt-auth marked as abandoned.
349
+ ```
350
+
351
+ ---
352
+
353
+ ### `cdd-kit migrate <change-id> | --all`
354
+
355
+ Upgrades pre-v1.11.0 change directories to the current format.
356
+
357
+ ```bash
358
+ cdd-kit migrate add-jwt-auth # migrate one change
359
+ cdd-kit migrate --all # migrate all changes in specs/changes/
360
+ cdd-kit migrate --all --dry-run # preview without writing
361
+ cdd-kit migrate --all --enable-context-governance
362
+ ```
363
+
364
+ What it upgrades:
365
+ - `tasks.md`: adds YAML frontmatter (`change-id`, `status: in-progress`) and `[x]/[-]/[ ]` legend if missing
366
+ - `change-classification.md`: detects old `**Tier:** Tier N` format and appends the new `## Tier\n- N` section so tier-based gate checks activate
367
+ - `context-manifest.md`: adds a legacy manifest scaffold by default so old changes can continue with warning-only context audit behavior
368
+ - `--enable-context-governance`: explicitly adds `context-governance: v1` and a context-governed manifest scaffold, making missing manifest or malformed `files-read` data hard gate failures
369
+
370
+ `agent-log/*.md` must use this `files-read` format for context-governed changes:
371
+
372
+ ```md
373
+ - files-read:
374
+ - contracts/api/api-contract.md
375
+ - src/server/routes/users.ts
376
+ ```
377
+
378
+ Paths must be repo-relative. Absolute paths and `..` parent traversal are rejected.
379
+
380
+ Run this after upgrading from v1.10 or earlier if you have mid-flight changes.
381
+
382
+ ```bash
383
+ cdd-kit migrate --all
384
+ git add specs/changes/
385
+ git commit -m "chore: migrate changes to current cdd-kit format"
386
+ ```
387
+
388
+ ---
389
+
390
+ ### `cdd-kit context request <change-id> <request-id>`
391
+
392
+ Records a pending Context Expansion Request in `context-manifest.md`.
393
+
394
+ ```bash
395
+ cdd-kit context request add-jwt-auth CER-001 --path src/server/users.ts tests/users.test.ts --reason "paired implementation and regression coverage"
396
+ ```
397
+
398
+ Use this when an agent needs more context than its current work packet allows.
399
+
400
+ ---
401
+
402
+ ### `cdd-kit context approve <change-id> <request-id>`
403
+
404
+ Approves a pending Context Expansion Request in `context-manifest.md` and adds its `requested_paths` to `## Approved Expansions`.
405
+
406
+ ```bash
407
+ cdd-kit context approve add-jwt-auth CER-001
80
408
  ```
81
409
 
410
+ This keeps expansion history explicit while avoiding manual manifest editing. Agents still have to report `files-read` in `agent-log/*.md`; `cdd-kit gate` audits those paths against the manifest.
411
+
412
+ ---
413
+
414
+ ### `cdd-kit context reject <change-id> <request-id>`
415
+
416
+ Rejects a pending Context Expansion Request and records `status: rejected` in the manifest.
417
+
418
+ ```bash
419
+ cdd-kit context reject add-jwt-auth CER-001
420
+ ```
421
+
422
+ ---
423
+
424
+ ### `cdd-kit context list <change-id>`
425
+
426
+ Lists all Context Expansion Requests for a change.
427
+
428
+ ```bash
429
+ cdd-kit context list add-jwt-auth
430
+ cdd-kit context list add-jwt-auth --json
431
+ ```
432
+
433
+ ---
434
+
435
+ ### `cdd-kit validate`
436
+
437
+ Runs contract validation scripts.
438
+
439
+ ```bash
440
+ cdd-kit validate # all validators
441
+ cdd-kit validate --contracts # API, CSS, data-shape (+ semantic checks)
442
+ cdd-kit validate --env # env contract
443
+ cdd-kit validate --ci # CI gate policy
444
+ cdd-kit validate --spec # spec traceability
445
+ cdd-kit validate --versions # contract frontmatter schema versions
446
+ ```
447
+
448
+ ---
449
+
450
+ ### `cdd-kit new <name>`
451
+
452
+ Scaffolds an empty change directory. Normally you use `/cdd-new` (the Claude Code skill) instead, which runs this and then orchestrates all agents. Use `cdd-kit new` only if you want an empty scaffold without agent orchestration.
453
+
454
+ ```bash
455
+ cdd-kit new add-user-auth
456
+ cdd-kit new add-user-auth --all # include optional templates too
457
+ cdd-kit new add-user-auth --force # overwrite existing directory
458
+ cdd-kit new add-user-api --depends-on add-user-db
459
+ ```
460
+
461
+ For larger requests, split the work into atomic changes on the same feature branch and use `--depends-on` to record upstream order. `cdd-kit gate` blocks a dependent change until each upstream change is either archived or has `status: completed` in its `tasks.md` frontmatter.
462
+
463
+ ---
464
+
82
465
  ### `cdd-kit install-hooks`
83
466
 
84
- Installs a pre-commit Git hook that automatically runs `cdd-kit gate` for any change folder touched in the staged commit. Prevents skipping the orchestration workflow.
467
+ Installs a pre-commit Git hook that auto-runs `cdd-kit gate --strict` on any staged change directory.
85
468
 
86
469
  ```bash
87
470
  cdd-kit install-hooks
88
471
  # ✓ pre-commit hook installed at .git/hooks/pre-commit
89
472
  ```
90
473
 
91
- - Idempotent: re-running updates the cdd-kit block in place without duplicating it.
92
- - Preserves existing hook content: if a pre-commit hook already exists, the cdd-kit block is prepended after the shebang line.
93
- - Bypass with `--no-verify` (not recommended; defeats AI process enforcement).
474
+ Idempotent. Preserves existing hook content. Bypass with `--no-verify` is possible but defeats enforcement.
475
+
476
+ ---
94
477
 
95
478
  ### `cdd-kit detect-stack`
96
479
 
@@ -99,139 +482,153 @@ Detects the project tech stack from lockfiles and config files.
99
482
  ```bash
100
483
  cdd-kit detect-stack
101
484
  # Detected stack: conda
102
- # Candidates (in order): conda, pnpm
103
485
  # Polyglot: yes (config will be generated for conda)
104
486
  ```
105
487
 
106
- ## Supported stacks (stack detection)
488
+ | Language | Tool | Detection signal |
489
+ |---|---|---|
490
+ | Python | conda | `environment.yml`, `conda-lock.yml` |
491
+ | Python | poetry | `pyproject.toml` with `[tool.poetry]` |
492
+ | Python | uv | `pyproject.toml` (no poetry section) |
493
+ | Python | pip | `requirements.txt` |
494
+ | JS/TS | pnpm | `pnpm-lock.yaml` |
495
+ | JS/TS | bun | `bun.lockb` |
496
+ | JS/TS | yarn | `yarn.lock` |
497
+ | JS/TS | npm | `package.json` (fallback) |
498
+ | Go | go | `go.mod` |
499
+ | Rust | rust | `Cargo.toml` |
107
500
 
108
- | Language | Tool | Detection signal |
109
- |------------|---------|----------------------------------------------|
110
- | Python | conda | `environment.yml`, `conda-lock.yml`, `meta.yaml` |
111
- | Python | poetry | `pyproject.toml` with `[tool.poetry]` |
112
- | Python | uv | `pyproject.toml` (no poetry section) |
113
- | Python | pip | `requirements.txt` |
114
- | JavaScript | pnpm | `package.json` + `pnpm-lock.yaml` |
115
- | JavaScript | bun | `package.json` + `bun.lockb` |
116
- | JavaScript | yarn | `package.json` + `yarn.lock` |
117
- | JavaScript | npm | `package.json` (no lockfile match) |
118
- | Go | go | `go.mod` |
119
- | Rust | rust | `Cargo.toml` |
501
+ ---
120
502
 
121
- When multiple language families are detected (polyglot project), `cdd-kit init` generates CI config for the first detected stack and prints a warning.
503
+ ### `cdd-kit context-scan`
122
504
 
123
- ## First-time setup in a repository
505
+ Builds deterministic, low-token context indexes for classifiers and orchestrators.
124
506
 
125
507
  ```bash
126
- # 1. Install the CLI globally
127
- npm install -g contract-driven-delivery
508
+ cdd-kit context-scan
509
+ ```
128
510
 
129
- # 2. Navigate to your repository
130
- cd your-repo
511
+ Outputs:
512
+ - `specs/context/project-map.md`: ASCII directory tree with schema metadata, visible file/dir counts, and excluded paths from `.cdd/context-policy.json`
513
+ - `specs/context/contracts-index.md`: contract inventory table plus deterministic details from YAML frontmatter or `<!-- cdd: ... -->` metadata
131
514
 
132
- # 3. Deploy the kit
133
- cdd-kit init
515
+ Recommended contract metadata:
134
516
 
135
- # 4. Open Claude Code and run the workflow
136
- # Ask Claude Code: "Use the contract-driven-delivery workflow.
137
- # Scan this repo, create a project profile, identify missing contracts,
138
- # and recommend the minimum standardization changes before feature work."
517
+ ```yaml
518
+ ---
519
+ contract: api
520
+ summary: User API endpoint rules and compatibility policy.
521
+ owner: backend-team
522
+ surface: user-management
523
+ ---
139
524
  ```
140
525
 
141
- ## What to expect after `cdd-kit init`
526
+ The classifier should read these two files before proposing `context-manifest.md` allowed paths.
527
+
528
+ ---
142
529
 
143
- The first `cdd-kit validate` after `init` is expected to print contract placeholder warnings — six contract files are scaffolded but empty. Validation still exits 0; warnings are advisory.
530
+ ## Migrating an Older Production Repo
144
531
 
145
- ```text
146
- Warning: contracts present but appear empty: contracts/api/api-contract.md, ...
147
- Fill them in before relying on the gate.
532
+ ```bash
533
+ npm update -g contract-driven-delivery
534
+ cdd-kit upgrade --yes
535
+ cdd-kit context-scan
536
+ cdd-kit doctor --strict
148
537
  ```
149
538
 
150
- To turn warnings off, fill each contract with real content (typical user-filled contracts run 500+ characters of meaningful text, well above the placeholder threshold). Recommended filling order:
539
+ ### Old completed specs
540
+
541
+ If a change is already finished, merged, or only kept for audit/history:
151
542
 
152
- 1. `contracts/env/env-contract.md` — list every env var your app reads, with `secret`, `default`, `validation` columns.
153
- 2. `contracts/api/api-contract.md` inventory every endpoint with method, path, request/response shape, and error format.
154
- 3. `contracts/data/data-shape-contract.md` — required columns, types, nullability, and malformed-data behavior for each data surface.
155
- 4. `contracts/css/css-contract.md` design tokens, component states, and forbidden raw values.
156
- 5. `contracts/business/business-rules.md` — current rules, decision tables, edge cases.
157
- 6. `contracts/ci/ci-gate-contract.md` — gate tiers, promotion policy, rollback policy.
543
+ ```bash
544
+ cdd-kit migrate --all
545
+ git add specs/changes/
546
+ git commit -m "chore: migrate changes to current cdd-kit format"
547
+ ```
158
548
 
159
- `cdd-kit validate --contracts` re-runs only the contract check; use it incrementally as you fill each file.
549
+ This gives those legacy specs the new `tasks.md` frontmatter, tier markers, and a warning-mode `context-manifest.md` without forcing strict context governance on closed work.
160
550
 
161
- ## What this kit standardizes
551
+ ### Old in-progress specs
162
552
 
163
- - Change classification before implementation
164
- - SDD artifacts for every meaningful change
165
- - TDD and test-first handoff rules
166
- - API, CSS/UI, environment, data-shape, business-rule, and CI/CD contracts
167
- - Required CI/CD gate planning for every change
168
- - E2E, resilience, data-boundary, monkey-operation, stress, and soak testing
169
- - Visual and UI/UX review for frontend changes
170
- - Spec drift audits across multiple iterations
171
- - Archiving completed changes back into durable standards
553
+ If a change is still being actively developed:
172
554
 
173
- ## Core workflow
555
+ ```bash
556
+ cdd-kit upgrade --yes --migrate-changes
557
+ cdd-kit context-scan
558
+ cdd-kit doctor --strict
559
+ ```
174
560
 
175
- 1. Classify the change.
176
- 2. Scan the repository context.
177
- 3. Decide the required artifact path.
178
- 4. Write or update specs, contracts, tests, and CI gate plan before implementation.
179
- 5. Implement through the right engineer agents.
180
- 6. Run local and CI gates.
181
- 7. Run visual, E2E, resilience, stress, soak, or monkey testing as required.
182
- 8. Archive stable learnings back into contracts and standards.
561
+ Then choose one path per active change:
183
562
 
184
- ## Change folder structure
563
+ - Conservative path: keep the migrated legacy manifest, resume work, and let `gate` warn on missing `files-read` data while the team transitions.
564
+ - Strict path: run `cdd-kit migrate <change-id> --enable-context-governance`, review `context-manifest.md`, narrow `Allowed Paths`, and require agents to report `- files-read:` before continuing implementation.
185
565
 
186
- ```text
187
- specs/changes/<change-id>/
188
- ├── change-request.md (required)
189
- ├── change-classification.md (required)
190
- ├── test-plan.md (required)
191
- ├── ci-gates.md (required)
192
- ├── tasks.md (required)
193
- ├── current-behavior.md
194
- ├── proposal.md
195
- ├── spec.md
196
- ├── design.md
197
- ├── contracts.md
198
- ├── qa-report.md
199
- ├── regression-report.md
200
- └── archive.md
201
- ```
566
+ ### Recommended rollout for production repos already burned by token overuse
202
567
 
203
- ## Definition of done
568
+ 1. Run `cdd-kit upgrade --yes` once per repo after updating the npm package.
569
+ 2. Run `cdd-kit context-scan` so classifiers can read `specs/context/project-map.md` and `specs/context/contracts-index.md` instead of broad repo searches.
570
+ 3. Run `cdd-kit doctor --strict` in CI.
571
+ 4. Migrate old completed specs with plain `cdd-kit migrate`.
572
+ 5. Migrate active specs with `cdd-kit migrate --enable-context-governance` only after reviewing the generated manifest.
573
+ 6. Teach agents to use `cdd-kit context request/approve/reject/list` instead of silently widening context.
204
574
 
205
- A change is not done until:
575
+ ---
206
576
 
207
- - Required specs and contracts are updated.
208
- - Required tests exist and are mapped to acceptance criteria.
209
- - Required CI/CD gates are present and green or explicitly marked as informational with promotion policy.
210
- - UI changes have visual evidence.
211
- - Data/reporting changes have data-boundary and bad-shape coverage.
212
- - High-load or long-running features have stress or soak evidence.
213
- - The archive captures what should become durable project knowledge.
577
+ ## Directory structure after `cdd-kit init`
214
578
 
215
- ## Stress / Soak runner support
579
+ ```
580
+ your-repo/
581
+ ├── contracts/
582
+ │ ├── api/api-contract.md ← what endpoints exist and how they behave
583
+ │ ├── css/css-contract.md ← design tokens, component states
584
+ │ ├── data/data-shape-contract.md ← schemas, types, nullability
585
+ │ ├── env/env-contract.md ← every env var, secret flags, defaults
586
+ │ ├── business/business-rules.md ← rules, edge cases, decision tables
587
+ │ └── ci/ci-gate-contract.md ← gate tiers, promotion, rollback
588
+ ├── specs/
589
+ │ ├── project-profile.md ← overall system description
590
+ │ ├── changes/ ← active in-progress changes
591
+ │ │ └── <change-id>/
592
+ │ │ ├── change-request.md (required)
593
+ │ │ ├── change-classification.md (required)
594
+ │ │ ├── test-plan.md (required)
595
+ │ │ ├── ci-gates.md (required)
596
+ │ │ ├── tasks.md (required)
597
+ │ │ └── agent-log/ ← machine-verifiable evidence per agent
598
+ │ ├── archive/ ← completed and abandoned changes
599
+ │ │ ├── INDEX.md
600
+ │ │ └── 2026/<change-id>/
601
+ │ └── templates/
602
+ ├── tests/
603
+ ├── CLAUDE.md ← Claude's project guide (edit this)
604
+ ├── AGENTS.md ← agent roster (auto-managed)
605
+ └── CODEX.md ← Codex project guide when initialized for Codex
606
+ ```
216
607
 
217
- cdd-kit ships starter configs for three load runners. Pick one
218
- when filling out `tests/<change-id>/stress-test-plan.md`:
608
+ ---
219
609
 
220
- | runner | best for | example |
221
- |--------|----------|---------|
222
- | k6 | JS-friendly, scriptable scenarios, native thresholds | tests/templates/stress/k6-example.js |
223
- | locust | Python teams, complex stateful scenarios | tests/templates/stress/locust-example.py |
224
- | artillery | declarative YAML, quick http flows | tests/templates/stress/artillery-example.yml |
610
+ ## Risk tiers and what each triggers
225
611
 
226
- Soak templates live under `tests/templates/soak/`.
612
+ | Tier | Risk level | Example changes | Extra agents |
613
+ |---|---|---|---|
614
+ | 0–1 | High / critical | Auth, payments, migrations, concurrency | E2E + monkey + stress/soak |
615
+ | 2–3 | Medium | Feature with API change, bug fix with behavior change | Contract review + QA |
616
+ | 4–5 | Low | Docs, prompts, config only, no behavior change | Contract review + QA |
227
617
 
228
- ## Updating the kit
618
+ ---
229
619
 
230
- ```bash
231
- npm update -g contract-driven-delivery
232
- cdd-kit update
620
+ ## Task notation in `tasks.md`
621
+
622
+ ```markdown
623
+ - [x] 1.1 Confirm classification ← done
624
+ - [-] 2.2 CSS/UI contract ← N/A (not applicable to this change)
625
+ - [ ] 4.1 Backend implementation ← pending
233
626
  ```
234
627
 
628
+ `cdd-kit gate --strict` treats any `[ ]` (except section 7 archive tasks) as an error. Use `[-]` for items that are genuinely not applicable to a given change.
629
+
630
+ ---
631
+
235
632
  ## License
236
633
 
237
634
  MIT