dev-playbooks 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +463 -0
  3. package/bin/devbooks.js +986 -0
  4. package/package.json +41 -0
  5. package/skills/Skill-Development-Guide.md +249 -0
  6. package/skills/Skills-Usage-Guide.md +447 -0
  7. package/skills/_shared/context-detection-template.md +315 -0
  8. package/skills/_shared/mcp-enhancement-template.md +144 -0
  9. package/skills/_shared/references/universal-gating-protocol.md +114 -0
  10. package/skills/_template/config-discovery-template.md +126 -0
  11. package/skills/devbooks-brownfield-bootstrap/SKILL.md +168 -0
  12. package/skills/devbooks-brownfield-bootstrap/references/10-glossary-template.md +42 -0
  13. package/skills/devbooks-brownfield-bootstrap/references/brownfield-bootstrap-prompt.md +115 -0
  14. package/skills/devbooks-brownfield-bootstrap/references/brownfield-bootstrap.md +96 -0
  15. package/skills/devbooks-brownfield-bootstrap/references/code-navigation-strategy.md +203 -0
  16. package/skills/devbooks-brownfield-bootstrap/scripts/cod-update.sh +357 -0
  17. package/skills/devbooks-brownfield-bootstrap/templates/project-profile-template.md +172 -0
  18. package/skills/devbooks-c4-map/SKILL.md +151 -0
  19. package/skills/devbooks-c4-map/references/c4-architecture-map-prompt.md +33 -0
  20. package/skills/devbooks-c4-map/references/layered-constraint-checklist.md +185 -0
  21. package/skills/devbooks-code-review/SKILL.md +175 -0
  22. package/skills/devbooks-code-review/references/code-review-prompt.md +100 -0
  23. package/skills/devbooks-code-review/references/code-smell-cheatsheet.md +498 -0
  24. package/skills/devbooks-code-review/references/pr-template-and-guidelines.md +321 -0
  25. package/skills/devbooks-code-review/references/resource-management-review-checklist.md +311 -0
  26. package/skills/devbooks-coder/SKILL.md +219 -0
  27. package/skills/devbooks-coder/references/code-implementation-prompt.md +74 -0
  28. package/skills/devbooks-coder/references/coding-style-guidelines.md +351 -0
  29. package/skills/devbooks-coder/references/error-code-standard.md +463 -0
  30. package/skills/devbooks-coder/references/logging-standard.md +329 -0
  31. package/skills/devbooks-coder/references/low-risk-modification-techniques.md +275 -0
  32. package/skills/devbooks-delivery-workflow/SKILL.md +217 -0
  33. package/skills/devbooks-delivery-workflow/references/9-change-verification-traceability-template.md +133 -0
  34. package/skills/devbooks-delivery-workflow/references/delivery-acceptance-workflow.md +177 -0
  35. package/skills/devbooks-delivery-workflow/references/prototype-production-dual-track.md +169 -0
  36. package/skills/devbooks-delivery-workflow/scripts/ac-trace-check.sh +330 -0
  37. package/skills/devbooks-delivery-workflow/scripts/audit-scope.sh +262 -0
  38. package/skills/devbooks-delivery-workflow/scripts/change-check.sh +1039 -0
  39. package/skills/devbooks-delivery-workflow/scripts/change-codemod-scaffold.sh +135 -0
  40. package/skills/devbooks-delivery-workflow/scripts/change-evidence.sh +152 -0
  41. package/skills/devbooks-delivery-workflow/scripts/change-scaffold.sh +467 -0
  42. package/skills/devbooks-delivery-workflow/scripts/change-spec-delta-scaffold.sh +135 -0
  43. package/skills/devbooks-delivery-workflow/scripts/constitution-check.sh +237 -0
  44. package/skills/devbooks-delivery-workflow/scripts/env-match-check.sh +128 -0
  45. package/skills/devbooks-delivery-workflow/scripts/fitness-check.sh +365 -0
  46. package/skills/devbooks-delivery-workflow/scripts/guardrail-check.sh +516 -0
  47. package/skills/devbooks-delivery-workflow/scripts/handoff-check.sh +141 -0
  48. package/skills/devbooks-delivery-workflow/scripts/hygiene-check.sh +340 -0
  49. package/skills/devbooks-delivery-workflow/scripts/migrate-from-openspec.sh +385 -0
  50. package/skills/devbooks-delivery-workflow/scripts/migrate-to-v2-gates.sh +202 -0
  51. package/skills/devbooks-delivery-workflow/scripts/progress-dashboard.sh +319 -0
  52. package/skills/devbooks-delivery-workflow/scripts/prototype-promote.sh +341 -0
  53. package/skills/devbooks-delivery-workflow/scripts/spec-preview.sh +203 -0
  54. package/skills/devbooks-delivery-workflow/scripts/spec-promote.sh +118 -0
  55. package/skills/devbooks-delivery-workflow/scripts/spec-rollback.sh +124 -0
  56. package/skills/devbooks-delivery-workflow/scripts/spec-stage.sh +117 -0
  57. package/skills/devbooks-delivery-workflow/scripts/verify-all.sh +78 -0
  58. package/skills/devbooks-delivery-workflow/scripts/verify-npm-package.sh +123 -0
  59. package/skills/devbooks-delivery-workflow/scripts/verify-openspec-free.sh +81 -0
  60. package/skills/devbooks-delivery-workflow/scripts/verify-slash-commands.sh +146 -0
  61. package/skills/devbooks-delivery-workflow/templates/handoff.md +50 -0
  62. package/skills/devbooks-design-backport/SKILL.md +73 -0
  63. package/skills/devbooks-design-backport/references/design-backport-prompt.md +132 -0
  64. package/skills/devbooks-design-doc/SKILL.md +121 -0
  65. package/skills/devbooks-design-doc/references/design-doc-prompt.md +188 -0
  66. package/skills/devbooks-design-doc/references/microservice-design-checklist.md +149 -0
  67. package/skills/devbooks-design-doc/references/privacy-compliance-checklist.md +240 -0
  68. package/skills/devbooks-entropy-monitor/SKILL.md +188 -0
  69. package/skills/devbooks-entropy-monitor/references/entropy-metrics-methodology.md +218 -0
  70. package/skills/devbooks-entropy-monitor/scripts/entropy-measure.sh +449 -0
  71. package/skills/devbooks-entropy-monitor/scripts/entropy-report.sh +303 -0
  72. package/skills/devbooks-entropy-monitor/templates/thresholds.json +99 -0
  73. package/skills/devbooks-federation/SKILL.md +264 -0
  74. package/skills/devbooks-federation/scripts/federation-check.sh +144 -0
  75. package/skills/devbooks-federation/templates/federation.yaml +89 -0
  76. package/skills/devbooks-impact-analysis/SKILL.md +135 -0
  77. package/skills/devbooks-impact-analysis/references/impact-analysis-prompt.md +82 -0
  78. package/skills/devbooks-impact-analysis/scripts/graph-cache.sh +214 -0
  79. package/skills/devbooks-implementation-plan/SKILL.md +83 -0
  80. package/skills/devbooks-implementation-plan/references/implementation-plan-prompt.md +95 -0
  81. package/skills/devbooks-index-bootstrap/SKILL.md +240 -0
  82. package/skills/devbooks-proposal-author/SKILL.md +83 -0
  83. package/skills/devbooks-proposal-author/references/proposal-authoring-prompt.md +66 -0
  84. package/skills/devbooks-proposal-challenger/SKILL.md +86 -0
  85. package/skills/devbooks-proposal-challenger/references/ethics-and-compliance-checklist.md +176 -0
  86. package/skills/devbooks-proposal-challenger/references/proposal-challenge-prompt.md +57 -0
  87. package/skills/devbooks-proposal-debate-workflow/SKILL.md +78 -0
  88. package/skills/devbooks-proposal-debate-workflow/references/11-proposal-debate-template.md +35 -0
  89. package/skills/devbooks-proposal-debate-workflow/references/proposal-debate-workflow.md +24 -0
  90. package/skills/devbooks-proposal-debate-workflow/scripts/proposal-debate-check.sh +102 -0
  91. package/skills/devbooks-proposal-judge/SKILL.md +78 -0
  92. package/skills/devbooks-proposal-judge/references/proposal-judge-prompt.md +37 -0
  93. package/skills/devbooks-router/SKILL.md +346 -0
  94. package/skills/devbooks-spec-contract/SKILL.md +191 -0
  95. package/skills/devbooks-spec-contract/references/api-design-guide.md +349 -0
  96. package/skills/devbooks-spec-contract/references/contract-and-data-definition-prompt.md +85 -0
  97. package/skills/devbooks-spec-contract/references/implicit-change-detection-prompt.md +183 -0
  98. package/skills/devbooks-spec-contract/references/spec-change-prompt.md +63 -0
  99. package/skills/devbooks-spec-contract/scripts/implicit-change-detect.sh +378 -0
  100. package/skills/devbooks-spec-gardener/SKILL.md +73 -0
  101. package/skills/devbooks-spec-gardener/references/spec-gardener-prompt.md +41 -0
  102. package/skills/devbooks-test-owner/SKILL.md +173 -0
  103. package/skills/devbooks-test-owner/references/9-change-verification-traceability-template.md +133 -0
  104. package/skills/devbooks-test-owner/references/async-system-test-strategy.md +316 -0
  105. package/skills/devbooks-test-owner/references/decoupling-techniques-cheatsheet.md +269 -0
  106. package/skills/devbooks-test-owner/references/test-code-prompt.md +171 -0
  107. package/skills/devbooks-test-owner/references/test-driven-development.md +351 -0
  108. package/skills/devbooks-test-owner/references/test-layering-strategy.md +281 -0
  109. package/skills/devbooks-test-reviewer/SKILL.md +189 -0
  110. package/templates/.devbooks/config.yaml +88 -0
  111. package/templates/claude-commands/devbooks/apply.md +38 -0
  112. package/templates/claude-commands/devbooks/archive.md +33 -0
  113. package/templates/claude-commands/devbooks/backport.md +19 -0
  114. package/templates/claude-commands/devbooks/bootstrap.md +20 -0
  115. package/templates/claude-commands/devbooks/c4.md +20 -0
  116. package/templates/claude-commands/devbooks/challenger.md +19 -0
  117. package/templates/claude-commands/devbooks/code.md +20 -0
  118. package/templates/claude-commands/devbooks/debate.md +20 -0
  119. package/templates/claude-commands/devbooks/delivery.md +20 -0
  120. package/templates/claude-commands/devbooks/design.md +20 -0
  121. package/templates/claude-commands/devbooks/entropy.md +19 -0
  122. package/templates/claude-commands/devbooks/federation.md +19 -0
  123. package/templates/claude-commands/devbooks/gardener.md +19 -0
  124. package/templates/claude-commands/devbooks/impact.md +19 -0
  125. package/templates/claude-commands/devbooks/index.md +19 -0
  126. package/templates/claude-commands/devbooks/judge.md +19 -0
  127. package/templates/claude-commands/devbooks/plan.md +20 -0
  128. package/templates/claude-commands/devbooks/proposal.md +20 -0
  129. package/templates/claude-commands/devbooks/quick.md +43 -0
  130. package/templates/claude-commands/devbooks/review.md +20 -0
  131. package/templates/claude-commands/devbooks/router.md +19 -0
  132. package/templates/claude-commands/devbooks/spec.md +20 -0
  133. package/templates/claude-commands/devbooks/test-review.md +19 -0
  134. package/templates/claude-commands/devbooks/test.md +20 -0
  135. package/templates/dev-playbooks/changes/.gitkeep +1 -0
  136. package/templates/dev-playbooks/constitution.md +116 -0
  137. package/templates/dev-playbooks/project.md +96 -0
  138. package/templates/dev-playbooks/scripts/.gitkeep +1 -0
  139. package/templates/dev-playbooks/specs/_meta/anti-patterns/.gitkeep +2 -0
  140. package/templates/dev-playbooks/specs/_meta/glossary.md +48 -0
  141. package/templates/dev-playbooks/specs/_meta/project-profile.md +79 -0
  142. package/templates/dev-playbooks/specs/architecture/fitness-rules.md +95 -0
@@ -0,0 +1,346 @@
1
+ ---
2
+ name: devbooks-router
3
+ description: "devbooks-router: DevBooks workflow routing and next-step recommendations. Routes user requests (proposal/design/spec/plan/test/implement/review/archive, or DevBooks proposal/apply/archive) to appropriate devbooks-* Skills, providing artifact destinations and shortest closed-loop paths. Use when user asks 'what's next/route to appropriate skill/run DevBooks closed-loop' etc."
4
+ tools:
5
+ - Glob
6
+ - Grep
7
+ - Read
8
+ - Bash
9
+ - mcp__ckb__getStatus
10
+ ---
11
+
12
+ # DevBooks: Workflow Router
13
+
14
+ ## Prerequisites: Configuration Discovery (Protocol-Agnostic)
15
+
16
+ - `<truth-root>`: Current truth directory root
17
+ - `<change-root>`: Change package directory root
18
+
19
+ Before execution, you **must** search for configuration in the following order (stop when found):
20
+ 1. `.devbooks/config.yaml` (if exists) → Parse and use its mappings
21
+ 2. `dev-playbooks/project.md` (if exists) → DevBooks 2.0 protocol, use default mappings
22
+ 4. `project.md` (if exists) → Template protocol, use default mappings
23
+ 5. If still undetermined → **Stop and ask user**
24
+
25
+ **Key Constraints**:
26
+ - If configuration specifies `agents_doc` (rules document), **you must read that document first** before executing any operations
27
+ - Do not guess directory roots
28
+ - Do not skip reading the rules document
29
+
30
+ ## Prerequisites: Graph Index Health Check (Automatic)
31
+
32
+ **Automatically executed before routing**, checks CKB graph index status:
33
+
34
+ 1. Call `mcp__ckb__getStatus` to check SCIP backend
35
+ 2. If `backends.scip.healthy = false`:
36
+ - Prompt user: "Code graph index not activated detected, impact analysis/call graph and other graph-based capabilities unavailable"
37
+ - Ask if they want to generate index now (approximately 1-5 minutes)
38
+ - If user agrees, execute `devbooks-index-bootstrap` workflow
39
+ - If user declines, continue routing but mark "graph capabilities degraded"
40
+
41
+ 3. If `backends.scip.healthy = true`:
42
+ - Pass silently, continue routing
43
+
44
+ **Check Script** (for reference):
45
+ ```bash
46
+ # Detect language and generate index
47
+ if [ -f "tsconfig.json" ]; then
48
+ scip-typescript index --output index.scip
49
+ elif [ -f "pyproject.toml" ]; then
50
+ scip-python index . --output index.scip
51
+ elif [ -f "go.mod" ]; then
52
+ scip-go --output index.scip
53
+ fi
54
+ ```
55
+
56
+ **Degraded Mode Notes**:
57
+ - Without index, `devbooks-impact-analysis` degrades to Grep text search (reduced accuracy)
58
+ - Without index, `devbooks-code-review` cannot obtain call graph context
59
+ - Recommend completing index generation before the Apply phase
60
+
61
+ ## Your Task
62
+
63
+ Map the user's natural language request to:
64
+ 1) Current phase (proposal / apply / review / archive)
65
+ 2) Required artifacts for this change (proposal/design/tasks/verification) and optional artifacts (spec deltas/contract/c4/evidence)
66
+ 3) Which `devbooks-*` Skill(s) to use next
67
+ 4) File path for each artifact
68
+
69
+ ## Output Requirements (Mandatory)
70
+
71
+ 1) **Ask 2 minimum key questions first** (skip if context already provides answers):
72
+ - What is the `<change-id>`?
73
+ - What are the final values of `<truth-root>` / `<change-root>` for this project?
74
+ 2) Provide "next-step routing results" (3-6 items):
75
+ - Each item includes: Skill to use + artifact path + why it's needed
76
+ 3) Only enter the corresponding Skill's output mode if the user explicitly asks you to "start producing file content directly."
77
+
78
+ ---
79
+
80
+ ## Impact Profile Parsing (AC-003 / AC-012)
81
+
82
+ When `proposal.md` exists, Router **should automatically parse** the Impact section to generate a more precise execution plan.
83
+
84
+ ### Impact Profile Structure
85
+
86
+ ```yaml
87
+ impact_profile:
88
+ external_api: true/false # External API changes
89
+ architecture_boundary: true/false # Architecture boundary changes
90
+ data_model: true/false # Data model changes
91
+ cross_repo: true/false # Cross-repository impact
92
+ risk_level: high/medium/low # Risk level
93
+ affected_modules: # List of affected modules
94
+ - name: <module-path>
95
+ type: add/modify/delete
96
+ files: <count>
97
+ ```
98
+
99
+ ### Parsing Flow
100
+
101
+ 1. Check if `proposal.md` exists
102
+ 2. If exists, find `## Impact` section
103
+ 3. Extract `impact_profile:` YAML block
104
+ 4. Validate required fields: `external_api`, `risk_level`, `affected_modules`
105
+
106
+ ### Routing Enhancement Based on Impact Profile
107
+
108
+ | Impact Field | Value | Auto-Append Skill |
109
+ |--------------|-------|-------------------|
110
+ | `external_api: true` | - | `devbooks-spec-contract` |
111
+ | `architecture_boundary: true` | - | `devbooks-c4-map` |
112
+ | `cross_repo: true` | - | `devbooks-federation` |
113
+ | `risk_level: high` | - | `devbooks-proposal-debate-workflow` |
114
+ | `affected_modules` count > 5 | - | `devbooks-impact-analysis` (deep analysis) |
115
+
116
+ ### Execution Plan Output Format
117
+
118
+ ```markdown
119
+ ## Execution Plan (Based on Impact Profile)
120
+
121
+ ### Must Execute
122
+ 1. `/devbooks:proposal` → proposal.md (proposal exists, skip)
123
+ 2. `/devbooks:design` → design.md (required)
124
+ 3. `/devbooks:plan` → tasks.md (required)
125
+
126
+ ### Recommended (Based on Impact Analysis)
127
+ 4. `/devbooks:spec` → specs/** (detected external_api: true)
128
+ 5. `/devbooks:c4` → architecture/c4.md (detected architecture_boundary: true)
129
+
130
+ ### Optional
131
+ 6. `/devbooks:impact` → Deep impact analysis (affected_modules > 5)
132
+ ```
133
+
134
+ ### Parse Failure Handling (AC-012)
135
+
136
+ **When Impact Profile is missing**:
137
+
138
+ ```
139
+ Warning: Impact profile not found in proposal.md.
140
+
141
+ Missing items:
142
+ - Impact section does not exist
143
+ - Or impact_profile YAML block is missing
144
+
145
+ Suggested actions:
146
+ 1. Run `/devbooks:impact` to generate impact analysis
147
+ 2. Or use direct command `/devbooks:<skill>` directly
148
+
149
+ Direct command list:
150
+ - /devbooks:design → Design document
151
+ - /devbooks:plan → Implementation plan
152
+ - /devbooks:spec → Specification definition
153
+ ```
154
+
155
+ **When YAML parsing fails**:
156
+
157
+ ```
158
+ Warning: Impact profile parsing failed.
159
+
160
+ Error: <specific error message>
161
+
162
+ Suggested actions:
163
+ 1. Check impact_profile YAML format in proposal.md
164
+ 2. Or use direct command `/devbooks:<skill>` to bypass Router
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Routing Rules (Quality-First Default)
170
+
171
+ ### A) Proposal (Proposal Phase)
172
+
173
+ Trigger signals: User says "proposal/why change/scope/risk/code smell refactoring/should we do this/don't write code yet" etc.
174
+
175
+ Default routing:
176
+ - `devbooks-proposal-author` → `(<change-root>/<change-id>/proposal.md)` (required)
177
+ - `devbooks-design-doc` → `(<change-root>/<change-id>/design.md)` (required for non-trivial changes; only write What/Constraints + AC-xxx)
178
+ - `devbooks-implementation-plan` → `(<change-root>/<change-id>/tasks.md)` (required; derive only from design)
179
+
180
+ Append as needed (add only when conditions are met):
181
+ - **Cross-module/unclear impact**: `devbooks-impact-analysis` (recommend writing back to proposal Impact)
182
+ - **Obvious risks/controversies/trade-offs**: `devbooks-proposal-debate-workflow` (Author/Challenger/Judge, write back to Decision Log after debate)
183
+ - **External behavior/contract/data invariant changes**: `devbooks-spec-contract` → `(<change-root>/<change-id>/specs/**)` + `design.md` Contract section
184
+ - If you need "deterministic spec delta file creation/avoid path errors": `change-spec-delta-scaffold.sh <change-id> <capability> ...`
185
+ - **Module boundary/dependency direction/architecture shape changes**: `devbooks-c4-map` → `(<truth-root>/architecture/c4.md)`
186
+
187
+ Hard constraint reminders:
188
+ - Proposal phase prohibits writing implementation code; implementation happens in apply phase with tests/gates as completion criteria.
189
+ - If you need "deterministic scaffold creation/avoid missing files": prefer running `devbooks-delivery-workflow` scripts
190
+ - `change-scaffold.sh <change-id> ...`
191
+ - `change-check.sh <change-id> --mode proposal ...`
192
+
193
+ ### B) Apply (Implementation Phase: Test Owner / Coder)
194
+
195
+ Trigger signals: User says "start implementation/run tests/fix failures/follow tasks/make all gates green" etc.
196
+
197
+ Default routing (mandatory role separation):
198
+ - Test Owner (separate conversation/separate instance): `devbooks-test-owner`
199
+ - Artifacts: `(<change-root>/<change-id>/verification.md)` + `tests/**`
200
+ - First run to produce **Red** baseline, and record evidence (e.g., `(<change-root>/<change-id>/evidence/**)`)
201
+ - Coder (separate conversation/separate instance): `devbooks-coder`
202
+ - Input: `tasks.md` + test errors + codebase
203
+ - Prohibited from modifying `tests/**`
204
+
205
+ Apply phase deterministic checks (recommended):
206
+ - Test Owner: `change-check.sh <change-id> --mode apply --role test-owner ...`
207
+ - Test Owner (evidence recording): `change-evidence.sh <change-id> --label red-baseline -- <test-command>`
208
+ - Coder: `change-check.sh <change-id> --mode apply --role coder ...` (additionally checks that `tests/**` is unmodified in git diff)
209
+
210
+ LSC (Large-Scale Codemods) recommendations:
211
+ - First use `change-codemod-scaffold.sh <change-id> --name <codemod-name> ...` to generate codemod script scaffold, then use script for batch changes and record evidence
212
+
213
+ ### C) Review (Review Phase)
214
+
215
+ Trigger signals: User says "review/code smells/maintainability/dependency risks/consistency" etc.
216
+
217
+ Default routing:
218
+ - `devbooks-code-review` (output actionable suggestions; do not change business conclusions or tests)
219
+
220
+ ### D) Archive (Archive Phase)
221
+
222
+ Trigger signals: User says "archive/merge specs/close out/wrap up" etc.
223
+
224
+ Default routing:
225
+ - If spec deltas were produced this time: `devbooks-spec-gardener` (prune `<truth-root>/**` before archive merge)
226
+ - If design decisions need to be written back: `devbooks-design-backport` (as needed)
227
+
228
+ Pre-archive deterministic checks (recommended):
229
+ - `change-check.sh <change-id> --mode strict ...` (requires: proposal Approved, tasks all checked, trace matrix has no TODOs, structural gate decisions filled in)
230
+
231
+ ### E) Prototype (Prototype Mode)
232
+
233
+ > Source: "The Mythical Man-Month" Chapter 11 "Plan to Throw One Away" — "The first system built is never suitable for use...plan to throw one away"
234
+
235
+ Trigger signals: User says "prototype first/quick validation/spike/--prototype/throwaway prototype/Plan to Throw One Away" etc.
236
+
237
+ **Prototype mode applicable scenarios**:
238
+ - Technical approach uncertain, need quick feasibility validation
239
+ - First time building this type of feature, expect to rewrite
240
+ - Need to explore actual behavior of APIs/libraries/frameworks
241
+
242
+ **Default routing (prototype track constraints)**:
243
+
244
+ 1. Create prototype scaffold:
245
+ - `change-scaffold.sh <change-id> --prototype ...`
246
+ - Artifacts: `(<change-root>/<change-id>/prototype/)`
247
+
248
+ 2. Test Owner (separate conversation) uses `devbooks-test-owner --prototype`:
249
+ - Artifacts: `(<change-root>/<change-id>/prototype/characterization/)`
250
+ - Generate **characterization tests** (record actual behavior) rather than acceptance tests
251
+ - **No Red baseline required** — characterization tests assert "current state"
252
+
253
+ 3. Coder (separate conversation) uses `devbooks-coder --prototype`:
254
+ - Output path: `(<change-root>/<change-id>/prototype/src/)`
255
+ - Allowed to bypass lint/complexity thresholds
256
+ - **Prohibited from landing directly to repository `src/`**
257
+
258
+ **Hard constraints (must follow)**:
259
+ - Prototype code and production code are **physically isolated** (different directories)
260
+ - Test Owner and Coder must still have **separate conversations/instances** (role separation unchanged)
261
+ - Promoting prototype to production requires **explicit trigger** `prototype-promote.sh <change-id>`
262
+
263
+ **Prerequisites for promoting prototype to production**:
264
+ 1. Create production-grade `design.md` (distill What/Constraints/AC-xxx from prototype learnings)
265
+ 2. Test Owner produces acceptance tests `verification.md` (replacing characterization tests)
266
+ 3. Complete the promotion checklist in `prototype/PROTOTYPE.md`
267
+ 4. Run `prototype-promote.sh <change-id>` and pass all gates
268
+
269
+ **Prototype discard flow**:
270
+ 1. Record key insights learned to `proposal.md` Decision Log
271
+ 2. Delete `prototype/` directory
272
+
273
+ ## DevBooks Command Adaptation
274
+
275
+ DevBooks uses `/devbooks:proposal`, `/devbooks:apply`, `/devbooks:archive` as entry points.
276
+ Route according to A/B/C/D above, artifact paths follow `<truth-root>/<change-root>` mappings in project signposts.
277
+
278
+ ---
279
+
280
+ ## Context Awareness
281
+
282
+ This Skill automatically detects context before execution, selecting appropriate routing strategy.
283
+
284
+ Detection rules reference: `skills/_shared/context-detection-template.md`
285
+
286
+ ### Detection Flow
287
+
288
+ 1. Detect if change package exists
289
+ 2. Detect existing artifacts (proposal/design/tasks/verification)
290
+ 3. Infer current phase (proposal/apply/archive)
291
+ 4. Select default routing based on phase
292
+
293
+ ### Modes Supported by This Skill
294
+
295
+ | Mode | Trigger Condition | Behavior |
296
+ |------|-------------------|----------|
297
+ | **New Change** | Change package doesn't exist or is empty | Route to proposal phase, suggest creating proposal.md |
298
+ | **In Progress** | Change package exists, has partial artifacts | Recommend next step based on missing artifacts |
299
+ | **Ready to Archive** | Gates passed, `evidence/green-final/` exists | Route to archive phase |
300
+
301
+ ### Detection Output Example
302
+
303
+ ```
304
+ Detection results:
305
+ - Change package status: exists
306
+ - Existing artifacts: proposal.md ✓, design.md ✓, tasks.md ✓, verification.md ✗
307
+ - Current phase: apply
308
+ - Suggested routing: devbooks-test-owner (establish Red baseline first)
309
+ ```
310
+
311
+ ---
312
+
313
+ ## MCP Enhancement
314
+
315
+ This Skill supports MCP runtime enhancement, automatically detecting and enabling advanced features.
316
+
317
+ MCP enhancement rules reference: `skills/_shared/mcp-enhancement-template.md`
318
+
319
+ ### Required MCP Services
320
+
321
+ | Service | Purpose | Timeout |
322
+ |---------|---------|---------|
323
+ | `mcp__ckb__getStatus` | Detect CKB index availability | 2s |
324
+
325
+ ### Detection Flow
326
+
327
+ 1. Call `mcp__ckb__getStatus` (2s timeout)
328
+ 2. If CKB available → Mark "graph capabilities activated" in routing suggestions
329
+ 3. If timeout or failure → Mark "graph capabilities degraded" in routing suggestions, recommend running /devbooks:index
330
+
331
+ ### Enhanced Mode vs Basic Mode
332
+
333
+ | Feature | Enhanced Mode | Basic Mode |
334
+ |---------|---------------|------------|
335
+ | Impact analysis recommendation | Use CKB precise analysis | Use Grep text search |
336
+ | Code navigation | Symbol-level navigation available | File-level search |
337
+ | Hotspot detection | CKB real-time analysis | Unavailable |
338
+
339
+ ### Degradation Notice
340
+
341
+ When MCP is unavailable, output the following notice:
342
+
343
+ ```
344
+ Warning: CKB index not activated, graph capabilities (impact analysis, call graph, etc.) will be degraded.
345
+ Recommend running /devbooks:index to generate index for full functionality.
346
+ ```
@@ -0,0 +1,191 @@
1
+ ---
2
+ name: devbooks-spec-contract
3
+ description: devbooks-spec-contract: Define external behavior specifications and contracts (Requirements/Scenarios/API/Schema/compatibility strategies/migrations), and suggest or generate contract tests. Combines the functionality of the original spec-delta and contract-data. Use when the user says "write spec/specification/contract/OpenAPI/Schema/compatibility strategy/contract tests" etc.
4
+ tools:
5
+ - Glob
6
+ - Grep
7
+ - Read
8
+ - Write
9
+ - Edit
10
+ - Bash
11
+ ---
12
+
13
+ # DevBooks: Spec & Contract
14
+
15
+ > This skill combines the functionality of the original `devbooks-spec-delta` and `devbooks-contract-data`, reducing decision fatigue.
16
+
17
+ ## Prerequisites: Configuration Discovery (Protocol-Agnostic)
18
+
19
+ - `<truth-root>`: Current truth directory root
20
+ - `<change-root>`: Change package directory root
21
+
22
+ Before execution, you **must** search for configuration in the following order (stop when found):
23
+ 1. `.devbooks/config.yaml` (if exists) -> Parse and use its mappings
24
+ 2. `dev-playbooks/project.md` (if exists) -> DevBooks 2.0 protocol, use default mappings
25
+ 4. `project.md` (if exists) -> Template protocol, use default mappings
26
+ 5. If still unable to determine -> **Stop and ask the user**
27
+
28
+ **Key Constraints**:
29
+ - If `agents_doc` (rules document) is specified in the configuration, **you must read that document first** before executing any operations
30
+ - Do not guess directory roots
31
+ - Do not skip reading the rules document
32
+
33
+ ---
34
+
35
+ ## Artifact Destinations
36
+
37
+ | Artifact Type | Destination Path |
38
+ |---------------|------------------|
39
+ | Spec delta | `<change-root>/<change-id>/specs/<capability>/spec.md` |
40
+ | Contract plan | `<change-root>/<change-id>/design.md` (Contract section) or standalone `contract-plan.md` |
41
+ | Contract Test IDs | Written to traceability matrix in `verification.md` |
42
+ | Implicit change report | `<change-root>/<change-id>/evidence/implicit-changes.json` |
43
+
44
+ ---
45
+
46
+ ## Use Case Determination
47
+
48
+ | Scenario | What to Do |
49
+ |----------|------------|
50
+ | Behavior changes only (no API/Schema) | Output only spec.md (Requirements/Scenarios) |
51
+ | API/Schema/event changes | Output spec.md + contract plan + Contract Test IDs |
52
+ | Compatibility risks | Additionally output compatibility strategy, deprecation policy, migration plan |
53
+ | Dependency/configuration/build changes | Run implicit change detection |
54
+
55
+ ---
56
+
57
+ ## Execution Method
58
+
59
+ ### Standard Process
60
+
61
+ 1) First read and follow: `_shared/references/universal-gating-protocol.md`
62
+ 2) Specification part: Output Requirements/Scenarios per `references/spec-change-prompt.md`
63
+ 3) Contract part: Output contract plan per `references/contract-and-data-definition-prompt.md`
64
+ 4) **Implicit change detection (as needed)**: `references/implicit-change-detection-prompt.md`
65
+
66
+ ### Output Structure (Single Output)
67
+
68
+ ```markdown
69
+ ## Spec Delta
70
+
71
+ ### Requirements
72
+ - REQ-XXX-001: <requirement description>
73
+
74
+ ### Scenarios
75
+ - SC-001: <scenario description>
76
+ - Given: ...
77
+ - When: ...
78
+ - Then: ...
79
+
80
+ ---
81
+
82
+ ## Contract Plan
83
+
84
+ ### API Changes
85
+ - New/modified endpoint: `POST /api/v1/orders`
86
+ - OpenAPI diff location: `contracts/openapi/orders.yaml`
87
+
88
+ ### Compatibility Strategy
89
+ - Backward compatible: Yes/No
90
+ - Deprecation policy: <if applicable>
91
+ - Migration plan: <if applicable>
92
+
93
+ ### Contract Test IDs
94
+ | Test ID | Type | Covered Scenario |
95
+ |---------|------|------------------|
96
+ | CT-001 | schema | REQ-XXX-001 |
97
+ | CT-002 | behavior | SC-001 |
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Scripts
103
+
104
+ - Implicit change detection: `scripts/implicit-change-detect.sh <change-id> [--base <commit>] [--project-root <dir>] [--change-root <dir>]`
105
+
106
+ ---
107
+
108
+ ## Context Awareness
109
+
110
+ This Skill automatically detects context before execution and selects the appropriate operating mode.
111
+
112
+ Detection rules reference: `skills/_shared/context-detection-template.md`
113
+
114
+ ### Detection Process
115
+
116
+ 1. Detect whether `<change-root>/<change-id>/specs/` exists
117
+ 2. If exists, assess completeness (whether there are placeholders, whether REQs have Scenarios)
118
+ 3. Select operating mode based on detection results
119
+
120
+ ### Supported Modes for This Skill
121
+
122
+ | Mode | Trigger Condition | Behavior |
123
+ |------|-------------------|----------|
124
+ | **Create from scratch** | `specs/` directory doesn't exist or is empty | Create complete spec document structure, including Requirements/Scenarios |
125
+ | **Gap-filling mode** | `specs/` exists but incomplete (has `[TODO]`, REQ missing Scenario) | Fill in missing Requirements/Scenarios, preserve existing content |
126
+ | **Sync mode** | `specs/` complete, needs synchronization with implementation | Check consistency between implementation and specs, output diff report |
127
+
128
+ ### Detection Output Example
129
+
130
+ ```
131
+ Detection Results:
132
+ - Artifact existence: specs/ exists
133
+ - Completeness: Incomplete (missing: REQ-002 has no Scenario)
134
+ - Current phase: apply
135
+ - Operating mode: Gap-filling mode
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Implicit Change Detection (Extended Feature)
141
+
142
+ > Source: "The Mythical Man-Month" Chapter 7 "The Tower of Babel" - "Teams slowly modify the functions of their own programs, implicitly changing the conventions"
143
+
144
+ Implicit changes = changes that are not explicitly declared but alter system behavior.
145
+
146
+ **Detection Scope**:
147
+ - Dependency changes (package.json / requirements.txt / go.mod etc.)
148
+ - Configuration changes (*.env / *.config.* / *.yaml etc.)
149
+ - Build changes (tsconfig.json / Dockerfile / CI configs etc.)
150
+
151
+ **Integration with change-check.sh**:
152
+ - Automatically checks implicit change reports in `apply` / `archive` / `strict` modes
153
+ - High-risk implicit changes must be declared in `design.md`
154
+
155
+ ---
156
+
157
+ ## MCP Enhancement
158
+
159
+ This Skill supports MCP runtime enhancement, automatically detecting and enabling advanced features.
160
+
161
+ MCP enhancement rules reference: `skills/_shared/mcp-enhancement-template.md`
162
+
163
+ ### Dependent MCP Services
164
+
165
+ | Service | Purpose | Timeout |
166
+ |---------|---------|---------|
167
+ | `mcp__ckb__findReferences` | Detect contract reference scope | 2s |
168
+ | `mcp__ckb__getStatus` | Detect CKB index availability | 2s |
169
+
170
+ ### Detection Process
171
+
172
+ 1. Call `mcp__ckb__getStatus` (2s timeout)
173
+ 2. If CKB available -> Use `findReferences` to detect reference scope of contract symbols
174
+ 3. If timeout or failure -> Fallback to Grep text search
175
+
176
+ ### Enhanced Mode vs Basic Mode
177
+
178
+ | Feature | Enhanced Mode | Basic Mode |
179
+ |---------|---------------|------------|
180
+ | Reference detection | Symbol-level precise matching | Grep text search |
181
+ | Contract impact scope | Call graph analysis | Direct reference counting |
182
+ | Compatibility risk | Automatic assessment | Manual judgment |
183
+
184
+ ### Fallback Notice
185
+
186
+ When MCP is unavailable, output the following notice:
187
+
188
+ ```
189
+ Warning: CKB unavailable, using Grep text search for contract reference detection.
190
+ Results may be less precise. Consider running /devbooks:index to generate the index.
191
+ ```