contract-driven-delivery 1.11.0 → 1.16.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 (41) hide show
  1. package/CHANGELOG.md +205 -0
  2. package/README.md +194 -24
  3. package/assets/CLAUDE.template.md +10 -0
  4. package/assets/CODEX.template.md +39 -0
  5. package/assets/agents/backend-engineer.md +4 -23
  6. package/assets/agents/change-classifier.md +130 -24
  7. package/assets/agents/ci-cd-gatekeeper.md +4 -23
  8. package/assets/agents/contract-reviewer.md +4 -23
  9. package/assets/agents/dependency-security-reviewer.md +4 -22
  10. package/assets/agents/e2e-resilience-engineer.md +4 -23
  11. package/assets/agents/frontend-engineer.md +4 -23
  12. package/assets/agents/monkey-test-engineer.md +4 -23
  13. package/assets/agents/qa-reviewer.md +4 -23
  14. package/assets/agents/repo-context-scanner.md +4 -22
  15. package/assets/agents/spec-architect.md +4 -23
  16. package/assets/agents/spec-drift-auditor.md +4 -22
  17. package/assets/agents/stress-soak-engineer.md +4 -23
  18. package/assets/agents/test-strategist.md +4 -23
  19. package/assets/agents/ui-ux-reviewer.md +4 -22
  20. package/assets/agents/visual-reviewer.md +4 -22
  21. package/assets/cdd/context-policy.json +25 -0
  22. package/assets/cdd/model-policy.json +24 -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/post-tool-use-files-read.sh +55 -0
  33. package/assets/skills/cdd-close/SKILL.md +37 -10
  34. package/assets/skills/cdd-new/SKILL.md +200 -164
  35. package/assets/skills/cdd-resume/SKILL.md +31 -3
  36. package/assets/skills/contract-driven-delivery/references/agent-log-protocol.md +117 -0
  37. package/assets/specs-templates/context-manifest.md +44 -0
  38. package/assets/specs-templates/tasks.md +4 -0
  39. package/dist/cli/index.js +2149 -342
  40. package/docs/release-checklist.md +39 -0
  41. package/package.json +6 -3
@@ -72,19 +72,10 @@ Target: `test-plan.md` ≤ 100 lines.
72
72
 
73
73
  ## Machine-Verifiable Evidence
74
74
 
75
- After completing your task, write or append to `specs/changes/<change-id>/agent-log/<your-agent-name>.md`
76
- with this exact structure (lines starting with `- ` are required):
77
-
78
- ```
79
- # Test Strategist Log
80
- - change-id: <id>
81
- - timestamp: <ISO 8601, e.g. 2026-04-27T14:30:00Z>
82
- - status: complete | needs-review | blocked
83
- - artifacts:
84
- - <evidence-type>: <concrete pointer>
85
- - <evidence-type>: <concrete pointer>
86
- - next-action: <one line, or "none">
87
- ```
75
+ After completing your task, write or append to
76
+ `specs/changes/<change-id>/agent-log/<your-agent-name>.md`. Required fields,
77
+ field rules, and gate-enforcement behavior are defined once in
78
+ `references/agent-log-protocol.md` — do not duplicate them in this prompt.
88
79
 
89
80
  ### Required artifacts for this agent
90
81
  - `test-plan-path`: `specs/changes/<id>/test-plan.md`
@@ -92,16 +83,6 @@ with this exact structure (lines starting with `- ` are required):
92
83
  - `coverage-tiers`: list of tiers covered (unit/contract/integration/E2E/resilience/monkey/stress/soak)
93
84
  - `mapping-completeness`: percentage or "all requirements covered"
94
85
 
95
- ### Rules
96
- - NEVER omit this log file. `cdd-kit gate` rejects changes whose agent-log
97
- is missing the `status:` line or has an invalid status.
98
- - If you cannot complete the task, set `status: blocked` and write a
99
- concrete `next-action` (NOT "investigate further" — write the actual
100
- next step a human can act on).
101
- - Evidence must be concrete: file:line, command name + last-10-line stdout,
102
- contract path + section, test name, etc. NEVER write "verified" or "OK"
103
- without a pointer.
104
-
105
86
  ## Read scope
106
87
 
107
88
  - Allowed: `contracts/`, `tests/`, `src/`, `specs/changes/<current-change-id>/`
@@ -51,19 +51,10 @@ approved / changes-required
51
51
 
52
52
  ## Machine-Verifiable Evidence
53
53
 
54
- After completing your task, include an **## Agent Log** section at the end of your response with this exact structure (lines starting with `- ` are required). The calling skill will write this block to `specs/changes/<change-id>/agent-log/ui-ux-reviewer.md`.
55
-
56
- ```
57
- ## Agent Log
58
- # UI/UX Reviewer Log
59
- - change-id: <id>
60
- - timestamp: <ISO 8601, e.g. 2026-04-27T14:30:00Z>
61
- - status: complete | needs-review | blocked
62
- - artifacts:
63
- - <evidence-type>: <concrete pointer>
64
- - <evidence-type>: <concrete pointer>
65
- - next-action: <one line, or "none">
66
- ```
54
+ After completing your task, write or append to
55
+ `specs/changes/<change-id>/agent-log/<your-agent-name>.md`. Required fields,
56
+ field rules, and gate-enforcement behavior are defined once in
57
+ `references/agent-log-protocol.md` do not duplicate them in this prompt.
67
58
 
68
59
  ### Required artifacts for this agent
69
60
  - `journeys-reviewed`: list of journey names
@@ -71,12 +62,3 @@ After completing your task, include an **## Agent Log** section at the end of yo
71
62
  - `copy-issues`: count + severity
72
63
  - `accessibility-findings`: count + severity
73
64
 
74
- ### Rules
75
- - NEVER omit this log file. `cdd-kit gate` rejects changes whose agent-log
76
- is missing the `status:` line or has an invalid status.
77
- - If you cannot complete the task, set `status: blocked` and write a
78
- concrete `next-action` (NOT "investigate further" — write the actual
79
- next step a human can act on).
80
- - Evidence must be concrete: file:line, command name + last-10-line stdout,
81
- contract path + section, test name, etc. NEVER write "verified" or "OK"
82
- without a pointer.
@@ -53,19 +53,10 @@ approved / changes-required
53
53
 
54
54
  ## Machine-Verifiable Evidence
55
55
 
56
- After completing your task, include an **## Agent Log** section at the end of your response with this exact structure (lines starting with `- ` are required). The calling skill will write this block to `specs/changes/<change-id>/agent-log/visual-reviewer.md`.
57
-
58
- ```
59
- ## Agent Log
60
- # Visual Reviewer Log
61
- - change-id: <id>
62
- - timestamp: <ISO 8601, e.g. 2026-04-27T14:30:00Z>
63
- - status: complete | needs-review | blocked
64
- - artifacts:
65
- - <evidence-type>: <concrete pointer>
66
- - <evidence-type>: <concrete pointer>
67
- - next-action: <one line, or "none">
68
- ```
56
+ After completing your task, write or append to
57
+ `specs/changes/<change-id>/agent-log/<your-agent-name>.md`. Required fields,
58
+ field rules, and gate-enforcement behavior are defined once in
59
+ `references/agent-log-protocol.md` do not duplicate them in this prompt.
69
60
 
70
61
  ### Required artifacts for this agent
71
62
  - `screenshots-compared`: list of `<screen>: baseline → current`
@@ -73,12 +64,3 @@ After completing your task, include an **## Agent Log** section at the end of yo
73
64
  - `state-coverage`: matrix
74
65
  - `tokens-violated`: list of CSS contract violations or "none"
75
66
 
76
- ### Rules
77
- - NEVER omit this log file. `cdd-kit gate` rejects changes whose agent-log
78
- is missing the `status:` line or has an invalid status.
79
- - If you cannot complete the task, set `status: blocked` and write a
80
- concrete `next-action` (NOT "investigate further" — write the actual
81
- next step a human can act on).
82
- - Evidence must be concrete: file:line, command name + last-10-line stdout,
83
- contract path + section, test name, etc. NEVER write "verified" or "OK"
84
- without a pointer.
@@ -0,0 +1,25 @@
1
+ {
2
+ "forbiddenPaths": [
3
+ ".claude/worktrees/**",
4
+ ".git/**",
5
+ "node_modules/**",
6
+ "dist/**",
7
+ "build/**",
8
+ "assets/**",
9
+ "specs/archive/**",
10
+ "specs/changes/*"
11
+ ],
12
+ "contextExpansion": {
13
+ "mode": "auto-safe",
14
+ "autoApprovePatterns": [
15
+ "src/**",
16
+ "tests/**",
17
+ "contracts/**",
18
+ "specs/changes/<current-change-id>/**"
19
+ ]
20
+ },
21
+ "audit": {
22
+ "requireFilesRead": true,
23
+ "unknownFilesRead": "warn-for-legacy-fail-for-new"
24
+ }
25
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "provider": "claude",
3
+ "generated_at": null,
4
+ "schema-version": "0.2.0",
5
+ "roles": {
6
+ "change-classifier": "claude-opus-4-7",
7
+ "spec-architect": "claude-opus-4-7",
8
+ "qa-reviewer": "claude-opus-4-7",
9
+ "contract-reviewer": "claude-sonnet-4-6",
10
+ "test-strategist": "claude-sonnet-4-6",
11
+ "backend-engineer": "claude-sonnet-4-6",
12
+ "frontend-engineer": "claude-sonnet-4-6",
13
+ "ci-cd-gatekeeper": "claude-sonnet-4-6",
14
+ "e2e-resilience-engineer": "claude-sonnet-4-6",
15
+ "monkey-test-engineer": "claude-sonnet-4-6",
16
+ "stress-soak-engineer": "claude-sonnet-4-6",
17
+ "ui-ux-reviewer": "claude-sonnet-4-6",
18
+ "visual-reviewer": "claude-sonnet-4-6",
19
+ "dependency-security-reviewer": "claude-sonnet-4-6",
20
+ "spec-drift-auditor": "claude-sonnet-4-6",
21
+ "repo-context-scanner": "claude-haiku-4-5"
22
+ },
23
+ "_notes": "Roles map agent name -> model ID. Override per-project as needed. cdd-kit doctor warns when an installed agent's frontmatter `model:` does not match this policy."
24
+ }
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  contract: api
3
+ summary: API behavior, compatibility rules, and endpoint contract requirements.
4
+ owner: application-team
5
+ surface: api
3
6
  schema-version: 0.1.0
4
7
  last-changed: 2026-04-27
5
8
  breaking-change-policy: deprecate-2-minors
@@ -1,3 +1,10 @@
1
+ ---
2
+ contract: api-inventory
3
+ summary: Endpoint inventory categories and ownership map for non-standard API surfaces.
4
+ owner: application-team
5
+ surface: api
6
+ ---
7
+
1
8
  # API Inventory
2
9
 
3
10
  | method | path | category | owner | contract test | notes |
@@ -1,3 +1,10 @@
1
+ ---
2
+ contract: api-error-format
3
+ summary: Standard error payload shape, safety rules, and reusable error code table.
4
+ owner: application-team
5
+ surface: api
6
+ ---
7
+
1
8
  # API Error Format
2
9
 
3
10
  ## Standard Error Shape
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  contract: business
3
+ summary: Business decision tables, rule inventory, and change policy for behavior updates.
4
+ owner: application-team
5
+ surface: domain-behavior
3
6
  schema-version: 0.1.0
4
7
  last-changed: 2026-04-27
5
8
  breaking-change-policy: deprecate-2-minors
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  contract: ci
3
+ summary: CI gate inventory, artifact retention, and rollback requirements.
4
+ owner: platform-team
5
+ surface: delivery-pipeline
3
6
  schema-version: 0.1.0
4
7
  last-changed: 2026-04-27
5
8
  breaking-change-policy: deprecate-2-minors
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  contract: css
3
+ summary: UI token policy, component styling rules, and visual review constraints.
4
+ owner: application-team
5
+ surface: ui
3
6
  schema-version: 0.1.0
4
7
  last-changed: 2026-04-27
5
8
  breaking-change-policy: deprecate-2-minors
@@ -1,3 +1,10 @@
1
+ ---
2
+ contract: design-tokens
3
+ summary: Canonical design token inventory for colors, spacing, typography, and layering.
4
+ owner: design-system
5
+ surface: ui
6
+ ---
7
+
1
8
  # Design Tokens
2
9
 
3
10
  ## Colors
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  contract: data
3
+ summary: Data schema, invalid-data handling, and row-level compatibility rules.
4
+ owner: application-team
5
+ surface: data
3
6
  schema-version: 0.1.0
4
7
  last-changed: 2026-04-27
5
8
  breaking-change-policy: deprecate-2-minors
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  contract: env
3
+ summary: Environment variable inventory, secret handling, and deployment sync policy.
4
+ owner: platform-team
5
+ surface: runtime-config
3
6
  schema-version: 0.1.0
4
7
  last-changed: 2026-04-27
5
8
  breaking-change-policy: deprecate-2-minors
@@ -0,0 +1,55 @@
1
+ #!/bin/sh
2
+ # cdd-kit PostToolUse hook (B3): append actual Read/Grep/Glob targets to a
3
+ # runtime audit log so `cdd-kit gate` can reconcile them against the agent-log
4
+ # self-report. This turns Context Governance from a trust contract into a
5
+ # verified contract.
6
+ #
7
+ # Wire into Claude Code (~/.claude/settings.json):
8
+ #
9
+ # {
10
+ # "hooks": {
11
+ # "PostToolUse": [
12
+ # { "matcher": "Read|Grep|Glob", "command": "/path/to/hooks/post-tool-use-files-read.sh" }
13
+ # ]
14
+ # }
15
+ # }
16
+ #
17
+ # The hook receives the tool-call payload as JSON on stdin. We extract the
18
+ # best-effort path candidate and append `<change-id>\t<path>` to a JSONL audit
19
+ # file. CURRENT_CHANGE_ID is read from environment (cdd-new sets it on every
20
+ # agent invocation as of v1.10.0+).
21
+
22
+ set -eu
23
+
24
+ CDD_RUNTIME_DIR="${CDD_RUNTIME_DIR:-./.cdd/runtime}"
25
+ CHANGE_ID="${CURRENT_CHANGE_ID:-unknown}"
26
+
27
+ mkdir -p "$CDD_RUNTIME_DIR"
28
+ LOG_FILE="$CDD_RUNTIME_DIR/${CHANGE_ID}-files-read.jsonl"
29
+
30
+ # Read JSON payload from stdin without choking if jq is missing.
31
+ payload="$(cat || true)"
32
+ [ -z "$payload" ] && exit 0
33
+
34
+ # Try to extract the path field. Common Claude Code tool inputs:
35
+ # Read → tool_input.file_path
36
+ # Grep → tool_input.path / glob / pattern
37
+ # Glob → tool_input.path / pattern
38
+ # We grep first then fall back to jq when available.
39
+ path_value=""
40
+ if command -v jq >/dev/null 2>&1; then
41
+ path_value="$(printf '%s' "$payload" | jq -r '
42
+ .tool_input.file_path
43
+ // .tool_input.path
44
+ // .tool_input.pattern
45
+ // empty
46
+ ' 2>/dev/null || true)"
47
+ fi
48
+ if [ -z "$path_value" ]; then
49
+ path_value="$(printf '%s' "$payload" | grep -oE '"file_path"[[:space:]]*:[[:space:]]*"[^"]+"' | head -n1 | sed -E 's/.*"file_path"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')"
50
+ fi
51
+
52
+ [ -z "$path_value" ] && exit 0
53
+
54
+ timestamp="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
55
+ printf '{"ts":"%s","change":"%s","path":"%s"}\n' "$timestamp" "$CHANGE_ID" "$path_value" >> "$LOG_FILE"
@@ -10,10 +10,18 @@ description: Close and archive a completed change. Confirms all tasks are done,
10
10
  A change is "done" when:
11
11
  1. Gate has passed (`cdd-kit gate <change-id>` exits 0)
12
12
  2. PR is merged (or change is abandoned)
13
- 3. Durable learnings have been promoted to `contracts/` or `CLAUDE.md`
13
+ 3. Durable learnings have been promoted to hot sources: `contracts/`, `CLAUDE.md`, or `CODEX.md`
14
14
 
15
15
  This skill drives steps 2–3 and physically moves the change to `specs/archive/`.
16
16
 
17
+ ## Hot / Warm / Cold Data Rules
18
+
19
+ - Hot data: `contracts/`, source files, tests, CI config, `CLAUDE.md`, `CODEX.md`.
20
+ - Warm data: the active `specs/changes/<change-id>/` directory while the change is open.
21
+ - Cold data: `specs/archive/` after close.
22
+
23
+ Cold data is historical evidence, not current requirements. Do not promote claims from old specs or archive prose unless they are backed by agent-log evidence, QA evidence, changed contracts, changed tests, or passing gates from this change.
24
+
17
25
  ## Input
18
26
 
19
27
  The skill argument is the change-id (e.g., `add-jwt-auth`).
@@ -58,7 +66,14 @@ If `7.2` is `[ ]`, proceed to Step 2.5. If already `[x]` or `[-]`, skip Steps 2.
58
66
 
59
67
  ## Step 2.5: Create archive.md
60
68
 
61
- Read `specs/changes/<change-id>/agent-log/` (all log files) and `specs/changes/<change-id>/qa-report.md` (if exists).
69
+ Read only active evidence for this change:
70
+ - `specs/changes/<change-id>/agent-log/` (all log files)
71
+ - `specs/changes/<change-id>/qa-report.md` (if exists)
72
+ - `specs/changes/<change-id>/ci-gates.md`
73
+ - `specs/changes/<change-id>/context-manifest.md`
74
+ - `specs/changes/<change-id>/tasks.md`
75
+
76
+ Do not read `specs/archive/` while closing a change. Historical archives are cold data and must not be used as current requirements.
62
77
 
63
78
  Synthesize a `specs/changes/<change-id>/archive.md` file with:
64
79
  - **Change Summary**: 1 paragraph what was changed and why
@@ -69,24 +84,33 @@ Synthesize a `specs/changes/<change-id>/archive.md` file with:
69
84
  - **Production Reality Findings**: any surprises or deviations from the plan (from qa-reviewer agent-log)
70
85
  - **Lessons Promoted to Standards**: (leave blank — to be filled in Step 3)
71
86
  - **Follow-up Work**: any known issues deferred
87
+ - **Cold Data Warning**: "This archive is historical evidence. Current requirements live in contracts/ and active project guidance."
72
88
 
73
- This file is the source for Step 3's learning promotion.
89
+ This file records the close-out evidence, but Step 3 promotion must still be evidence-gated. Archive prose alone is not enough to change hot data.
74
90
 
75
91
  ---
76
92
 
77
93
  ## Step 3: Promote learnings (task 7.2)
78
94
 
79
- Read `specs/changes/<change-id>/archive.md` section `## Lessons Promoted to Standards`.
95
+ Read `specs/changes/<change-id>/archive.md` section `## Lessons Promoted to Standards` and cross-check every proposed lesson against agent-log, QA report, contract/test changes, or gate evidence from this change.
96
+
97
+ Classify each candidate:
98
+ - **promote-to-contract**: stable product/system behavior, API/data/env/business/CI rule, compatibility rule, or testable invariant.
99
+ - **promote-to-guidance**: durable workflow guidance for future agents, provider-specific operating instructions, or project-specific agent constraints. Target `CLAUDE.md` and/or `CODEX.md`.
100
+ - **do-not-promote**: one-off implementation detail, abandoned approach, temporary workaround, historical rationale, or anything contradicted by current contracts.
80
101
 
81
102
  If there are lessons to promote, invoke `contract-reviewer` with:
82
103
  - The archive.md lessons section
83
- - Instruction: "Review these lessons and propose specific additions to the relevant contract files. For each lesson, output: target file, target section, proposed text (≤ 5 lines), schema-version bump required (yes/no)."
104
+ - Supporting evidence from agent-log / QA / changed contracts / changed tests
105
+ - Instruction: "Review these lessons and propose specific additions only for evidence-backed durable rules. For each lesson, output: classification, target file, target section, proposed text (≤ 5 lines), evidence path, schema-version bump required (yes/no). Reject any cold-data-only or one-off lesson."
84
106
 
85
107
  After contract-reviewer responds:
86
- 1. Apply each proposed addition to the contract file (YOU write)
87
- 2. Run `cdd-kit validate --contracts` to confirm format is preserved
88
- 3. Fill in `## Lessons Promoted to Standards` in archive.md with what was promoted
89
- 4. Tick `7.2` in tasks.md
108
+ 1. Apply each approved contract addition to the contract file (YOU write)
109
+ 2. Apply each approved guidance addition to `CLAUDE.md` and/or `CODEX.md` only if it is provider/project guidance, not product behavior
110
+ 3. Run `cdd-kit validate --contracts` to confirm contract format is preserved
111
+ 4. Run `cdd-kit context-scan` so future classifiers see updated hot context indexes
112
+ 5. Fill in `## Lessons Promoted to Standards` in archive.md with what was promoted, where, and evidence path
113
+ 6. Tick `7.2` in tasks.md
90
114
 
91
115
  If there are no lessons to promote, mark `[-]` for 7.2 with rationale.
92
116
 
@@ -108,7 +132,7 @@ If successful, tick `7.1` in tasks.md (the file is now in specs/archive/, update
108
132
 
109
133
  Change ID: <change-id>
110
134
  Archived to: specs/archive/<year>/<change-id>/
111
- Learnings promoted: <list what was added to contracts/CLAUDE.md, or "none">
135
+ Learnings promoted: <list what was added to contracts/CLAUDE.md/CODEX.md, or "none">
112
136
 
113
137
  specs/changes/<change-id>/ has been removed from the active surface.
114
138
  Token cost of future sessions reduced by ~<N> files.
@@ -120,4 +144,7 @@ Token cost of future sessions reduced by ~<N> files.
120
144
 
121
145
  - NEVER archive before gate passes (unless user explicitly confirms abandoned)
122
146
  - NEVER skip Step 3 — lessons rot if not promoted
147
+ - NEVER treat `specs/archive/` as hot requirements
148
+ - NEVER promote a lesson without an evidence path from this change
149
+ - Product behavior belongs in `contracts/`; agent workflow guidance belongs in `CLAUDE.md` and/or `CODEX.md`
123
150
  - The archive command is irreversible without git — remind user to commit after archiving