dev-playbooks 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/devbooks.js CHANGED
@@ -305,6 +305,160 @@ function getCliVersion() {
305
305
  }
306
306
  }
307
307
 
308
+ // ============================================================================
309
+ // Auto-update .gitignore and .npmignore
310
+ // ============================================================================
311
+
312
+ const IGNORE_MARKERS = {
313
+ start: '# DevBooks managed - DO NOT EDIT',
314
+ end: '# End DevBooks managed'
315
+ };
316
+
317
+ /**
318
+ * Get entries to add to .gitignore
319
+ * @param {string[]} toolIds - Selected AI tool IDs
320
+ * @returns {string[]} - Entries to ignore
321
+ */
322
+ function getGitIgnoreEntries(toolIds) {
323
+ const entries = [
324
+ '# DevBooks local config (contains user preferences, should not be committed)',
325
+ '.devbooks/'
326
+ ];
327
+
328
+ // Add corresponding AI tool directories based on selected tools
329
+ for (const toolId of toolIds) {
330
+ const tool = AI_TOOLS.find(t => t.id === toolId);
331
+ if (!tool) continue;
332
+
333
+ // Add slash command directory
334
+ if (tool.slashDir) {
335
+ const topDir = tool.slashDir.split('/')[0];
336
+ if (!entries.includes(topDir + '/')) {
337
+ entries.push(`${topDir}/`);
338
+ }
339
+ }
340
+
341
+ // Add rules directory
342
+ if (tool.rulesDir) {
343
+ const topDir = tool.rulesDir.split('/')[0];
344
+ if (!entries.includes(topDir + '/')) {
345
+ entries.push(`${topDir}/`);
346
+ }
347
+ }
348
+
349
+ // Add agents directory (e.g., .github/instructions)
350
+ if (tool.instructionsDir) {
351
+ const topDir = tool.instructionsDir.split('/')[0];
352
+ if (topDir !== '.github') { // .github directory usually needs to be kept
353
+ if (!entries.includes(topDir + '/')) {
354
+ entries.push(`${topDir}/`);
355
+ }
356
+ }
357
+ }
358
+ }
359
+
360
+ return entries;
361
+ }
362
+
363
+ /**
364
+ * Get entries to add to .npmignore
365
+ * @returns {string[]} - Entries to ignore
366
+ */
367
+ function getNpmIgnoreEntries() {
368
+ return [
369
+ '# DevBooks development docs (not needed at runtime)',
370
+ 'dev-playbooks/',
371
+ '.devbooks/',
372
+ '',
373
+ '# AI tool config directories',
374
+ '.claude/',
375
+ '.cursor/',
376
+ '.windsurf/',
377
+ '.gemini/',
378
+ '.agent/',
379
+ '.opencode/',
380
+ '.continue/',
381
+ '.qoder/',
382
+ '.github/instructions/',
383
+ '.github/copilot-instructions.md',
384
+ '',
385
+ '# DevBooks instruction files',
386
+ 'CLAUDE.md',
387
+ 'AGENTS.md',
388
+ 'GEMINI.md'
389
+ ];
390
+ }
391
+
392
+ /**
393
+ * Update ignore file, preserving user-defined content
394
+ * @param {string} filePath - ignore file path
395
+ * @param {string[]} entries - Entries to add
396
+ * @returns {object} - { updated: boolean, action: 'created' | 'updated' | 'unchanged' }
397
+ */
398
+ function updateIgnoreFile(filePath, entries) {
399
+ const managedBlock = [
400
+ IGNORE_MARKERS.start,
401
+ ...entries,
402
+ IGNORE_MARKERS.end
403
+ ].join('\n');
404
+
405
+ if (!fs.existsSync(filePath)) {
406
+ // File doesn't exist, create new file
407
+ fs.writeFileSync(filePath, managedBlock + '\n');
408
+ return { updated: true, action: 'created' };
409
+ }
410
+
411
+ const content = fs.readFileSync(filePath, 'utf-8');
412
+ const startIdx = content.indexOf(IGNORE_MARKERS.start);
413
+ const endIdx = content.indexOf(IGNORE_MARKERS.end);
414
+
415
+ if (startIdx !== -1 && endIdx !== -1 && startIdx < endIdx) {
416
+ // Managed block exists, update it
417
+ const before = content.slice(0, startIdx);
418
+ const after = content.slice(endIdx + IGNORE_MARKERS.end.length);
419
+ const newContent = before + managedBlock + after;
420
+
421
+ if (newContent !== content) {
422
+ fs.writeFileSync(filePath, newContent);
423
+ return { updated: true, action: 'updated' };
424
+ }
425
+ return { updated: false, action: 'unchanged' };
426
+ }
427
+
428
+ // No managed block, append to end of file
429
+ const newContent = content.trimEnd() + '\n\n' + managedBlock + '\n';
430
+ fs.writeFileSync(filePath, newContent);
431
+ return { updated: true, action: 'updated' };
432
+ }
433
+
434
+ /**
435
+ * Setup project's ignore files
436
+ * @param {string[]} toolIds - Selected AI tool IDs
437
+ * @param {string} projectDir - Project directory
438
+ * @returns {object[]} - Results array
439
+ */
440
+ function setupIgnoreFiles(toolIds, projectDir) {
441
+ const results = [];
442
+
443
+ // Update .gitignore
444
+ const gitIgnorePath = path.join(projectDir, '.gitignore');
445
+ const gitIgnoreEntries = getGitIgnoreEntries(toolIds);
446
+ const gitResult = updateIgnoreFile(gitIgnorePath, gitIgnoreEntries);
447
+ if (gitResult.updated) {
448
+ results.push({ file: '.gitignore', action: gitResult.action });
449
+ }
450
+
451
+ // Update .npmignore
452
+ const npmIgnorePath = path.join(projectDir, '.npmignore');
453
+ const npmIgnoreEntries = getNpmIgnoreEntries();
454
+ const npmResult = updateIgnoreFile(npmIgnorePath, npmIgnoreEntries);
455
+ if (npmResult.updated) {
456
+ results.push({ file: '.npmignore', action: npmResult.action });
457
+ }
458
+
459
+ return results;
460
+ }
461
+
308
462
  function showVersion() {
309
463
  console.log(`${CLI_COMMAND} v${getCliVersion()}`);
310
464
  }
@@ -459,7 +613,53 @@ function installSkills(toolIds, update = false) {
459
613
  }
460
614
 
461
615
  // ============================================================================
462
- // 安装 Rules(Cursor, Windsurf, Gemini, Antigravity, OpenCode, Continue)
616
+ // Install Claude Code Custom Subagents (solves built-in subagents cannot access Skills)
617
+ // ============================================================================
618
+
619
+ function installClaudeAgents(toolIds, projectDir, update = false) {
620
+ const results = [];
621
+
622
+ // Only Claude Code needs custom subagents
623
+ if (!toolIds.includes('claude')) return results;
624
+
625
+ const agentsSrcDir = path.join(__dirname, '..', 'templates', 'claude-agents');
626
+ const agentsDestDir = path.join(projectDir, '.claude', 'agents');
627
+
628
+ if (!fs.existsSync(agentsSrcDir)) return results;
629
+
630
+ const agentFiles = fs.readdirSync(agentsSrcDir)
631
+ .filter(name => name.endsWith('.md'));
632
+
633
+ if (agentFiles.length === 0) return results;
634
+
635
+ fs.mkdirSync(agentsDestDir, { recursive: true });
636
+
637
+ let installedCount = 0;
638
+ for (const agentFile of agentFiles) {
639
+ const srcPath = path.join(agentsSrcDir, agentFile);
640
+ const destPath = path.join(agentsDestDir, agentFile);
641
+
642
+ if (fs.existsSync(destPath) && !update) continue;
643
+
644
+ fs.copyFileSync(srcPath, destPath);
645
+ installedCount++;
646
+ }
647
+
648
+ if (installedCount > 0) {
649
+ results.push({
650
+ tool: 'Claude Code',
651
+ type: 'agents',
652
+ count: installedCount,
653
+ total: agentFiles.length,
654
+ path: agentsDestDir
655
+ });
656
+ }
657
+
658
+ return results;
659
+ }
660
+
661
+ // ============================================================================
662
+ // Install Rules (Cursor, Windsurf, Gemini, Antigravity, OpenCode, Continue)
463
663
  // ============================================================================
464
664
 
465
665
  function installRules(toolIds, projectDir, update = false) {
@@ -838,17 +1038,25 @@ async function initCommand(projectDir, options) {
838
1038
  });
839
1039
 
840
1040
  if (fullSupportTools.length > 0) {
841
- const skillsSpinner = ora('安装 Skills...').start();
1041
+ const skillsSpinner = ora('Installing Skills...').start();
842
1042
  const skillsResults = installSkills(fullSupportTools);
843
- skillsSpinner.succeed('Skills 安装完成');
1043
+ skillsSpinner.succeed('Skills installed');
844
1044
 
845
1045
  for (const result of skillsResults) {
846
1046
  if (result.count > 0) {
847
- console.log(chalk.gray(` └ ${result.tool}: ${result.count}/${result.total} ${result.type}`));
1047
+ console.log(chalk.gray(` └ ${result.tool}: ${result.count}/${result.total} ${result.type}`));
848
1048
  } else if (result.note) {
849
1049
  console.log(chalk.gray(` └ ${result.tool}: ${result.note}`));
850
1050
  }
851
1051
  }
1052
+
1053
+ // Install Claude Code custom subagents (solves built-in subagents cannot access Skills)
1054
+ const agentsResults = installClaudeAgents(fullSupportTools, projectDir);
1055
+ for (const result of agentsResults) {
1056
+ if (result.count > 0) {
1057
+ console.log(chalk.gray(` └ ${result.tool}: ${result.count} custom subagents → ${result.path}`));
1058
+ }
1059
+ }
852
1060
  }
853
1061
 
854
1062
  // 安装 Rules(Rules 类似系统的工具)
@@ -867,16 +1075,28 @@ async function initCommand(projectDir, options) {
867
1075
  }
868
1076
  }
869
1077
 
870
- // 安装指令文件
871
- const instructionSpinner = ora('创建指令文件...').start();
1078
+ // Install instruction files
1079
+ const instructionSpinner = ora('Creating instruction files...').start();
872
1080
  const instructionResults = installInstructionFiles(selectedTools, projectDir);
873
- instructionSpinner.succeed(`创建了 ${instructionResults.length} 个指令文件`);
1081
+ instructionSpinner.succeed(`Created ${instructionResults.length} instruction files`);
874
1082
 
875
1083
  for (const result of instructionResults) {
876
1084
  console.log(chalk.gray(` └ ${result.tool}: ${path.relative(projectDir, result.path)}`));
877
1085
  }
878
1086
 
879
- // 完成
1087
+ // Setup ignore files
1088
+ const ignoreSpinner = ora('Configuring ignore files...').start();
1089
+ const ignoreResults = setupIgnoreFiles(selectedTools, projectDir);
1090
+ if (ignoreResults.length > 0) {
1091
+ ignoreSpinner.succeed('Ignore files configured');
1092
+ for (const result of ignoreResults) {
1093
+ console.log(chalk.gray(` └ ${result.file}: ${result.action}`));
1094
+ }
1095
+ } else {
1096
+ ignoreSpinner.succeed('Ignore files already up to date');
1097
+ }
1098
+
1099
+ // Done
880
1100
  console.log();
881
1101
  console.log(chalk.green('══════════════════════════════════════'));
882
1102
  console.log(chalk.green('✓') + chalk.bold(' DevBooks 初始化完成!'));
@@ -942,6 +1162,14 @@ async function updateCommand(projectDir) {
942
1162
  }
943
1163
  }
944
1164
 
1165
+ // Update Claude Code custom subagents (project directory)
1166
+ const agentsResults = installClaudeAgents(configuredTools, projectDir, true);
1167
+ for (const result of agentsResults) {
1168
+ if (result.count > 0) {
1169
+ console.log(chalk.green('✓') + ` ${result.tool}: updated ${result.count} custom subagents`);
1170
+ }
1171
+ }
1172
+
945
1173
  // Update Rules (project directory)
946
1174
  const rulesTools = configuredTools.filter(id => {
947
1175
  const tool = AI_TOOLS.find(t => t.id === id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dev-playbooks",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "AI-powered spec-driven development workflow",
5
5
  "keywords": [
6
6
  "devbooks",
@@ -0,0 +1,199 @@
1
+ # Deviation Detection and Routing Protocol
2
+
3
+ > This protocol defines the deviation detection, recording, and routing mechanisms during skill execution.
4
+ > All Apply phase skills (coder, test-owner, reviewer) must follow this protocol.
5
+
6
+ ## Core Problem
7
+
8
+ During long tasks (e.g., coder), the following may occur:
9
+ 1. Unplanned feature modifications or additions
10
+ 2. Discovery that design document constraints need adjustment
11
+ 3. Context overflow triggers compact, causing deviation information loss
12
+
13
+ **Solution**: Real-time persistence + completion-time detection + structured routing
14
+
15
+ ---
16
+
17
+ ## Completion Status Classification (MECE)
18
+
19
+ Each skill must identify and declare its current status upon completion:
20
+
21
+ | Code | Status | Meaning | Next Step |
22
+ |:----:|--------|---------|-----------|
23
+ | ✅ | COMPLETED | Completed normally, no deviations | Enter next skill |
24
+ | ⚠️ | COMPLETED_WITH_DEVIATION | Completed but with deviations/additions | design-backport first, then next step |
25
+ | 🔄 | HANDOFF | Needs another role to handle | Return to specified skill |
26
+ | ❌ | BLOCKED | Blocked, needs external input | Record breakpoint, wait |
27
+ | 💥 | FAILED | Failed, gates not passed | Fix and retry |
28
+
29
+ ### Status Determination Rules
30
+
31
+ ```
32
+ If deviation-log.md has unwritten records
33
+ → COMPLETED_WITH_DEVIATION
34
+
35
+ If tasks.md has incomplete items
36
+ → BLOCKED or FAILED (depends on reason)
37
+
38
+ If tests/ modification needed (for coder)
39
+ → HANDOFF to test-owner
40
+
41
+ If all tasks completed and no deviations
42
+ → COMPLETED
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Deviation Log Protocol
48
+
49
+ ### File Location
50
+
51
+ ```
52
+ <change-root>/<change-id>/deviation-log.md
53
+ ```
54
+
55
+ ### File Format
56
+
57
+ ```markdown
58
+ # Deviation Log
59
+
60
+ > This file records all deviations, additions, and temporary decisions during implementation.
61
+ > **Important**: This file persists after compact, ensuring information is not lost.
62
+
63
+ ## Pending Backport Records
64
+
65
+ | Time | Type | Description | Affected Files | Backported |
66
+ |------|------|-------------|----------------|:----------:|
67
+ | YYYY-MM-DD HH:mm | NEW_FEATURE | Added X feature | src/x.ts | ❌ |
68
+ | YYYY-MM-DD HH:mm | CONSTRAINT_CHANGE | Timeout changed to 60s | config.ts | ❌ |
69
+ | YYYY-MM-DD HH:mm | DESIGN_GAP | Found uncovered edge case | - | ❌ |
70
+
71
+ ## Completed Backport Records
72
+
73
+ (Move here after design-backport completes)
74
+
75
+ | Time | Type | Description | Backported To |
76
+ |------|------|-------------|---------------|
77
+ ```
78
+
79
+ ### Deviation Type Definitions
80
+
81
+ | Type | Code | Description | Example |
82
+ |------|------|-------------|---------|
83
+ | New Feature | NEW_FEATURE | Added feature not in design | New warmup() method |
84
+ | Constraint Change | CONSTRAINT_CHANGE | Modified constraint/config from design | Timeout from 30s to 60s |
85
+ | Design Gap | DESIGN_GAP | Found scenario not covered by design | Concurrency not considered |
86
+ | API Change | API_CHANGE | Public interface differs from design | Added options parameter |
87
+ | Dependency Change | DEPENDENCY_CHANGE | Introduced unplanned dependency | Added lodash |
88
+
89
+ ---
90
+
91
+ ## Real-time Persistence Protocol
92
+
93
+ ### When to Write to deviation-log.md
94
+
95
+ **Must write immediately** in these situations:
96
+
97
+ 1. **Added new files/functions** not in tasks.md
98
+ 2. **Modified config/constraints** inconsistent with design.md
99
+ 3. **Found edge cases** not covered by design.md
100
+ 4. **Temporary decisions** needing later confirmation
101
+
102
+ ### How to Write
103
+
104
+ ```markdown
105
+ ## Example: Found need to add feature
106
+
107
+ Append a line to deviation-log.md:
108
+
109
+ | 2024-01-15 10:30 | NEW_FEATURE | Added cache warmup for better first-access performance | src/cache.ts | ❌ |
110
+ ```
111
+
112
+ ### Compact Protection
113
+
114
+ deviation-log.md is a **persistent file** unaffected by compact. Even if conversation context is compressed:
115
+ - File content still exists
116
+ - Next skill can read and process
117
+
118
+ ---
119
+
120
+ ## Next Step Routing Rules
121
+
122
+ ### General Routing Table
123
+
124
+ | Current Skill | Completion Status | Next Step |
125
+ |---------------|-------------------|-----------|
126
+ | Any | COMPLETED_WITH_DEVIATION | `devbooks-design-backport` |
127
+ | coder | COMPLETED | `devbooks-code-review` |
128
+ | coder | HANDOFF (test issue) | `devbooks-test-owner` |
129
+ | test-owner | COMPLETED | `devbooks-coder` |
130
+ | test-owner | HANDOFF (design issue) | `devbooks-design-backport` |
131
+ | code-review | COMPLETED (has spec delta) | `devbooks-spec-gardener` |
132
+ | code-review | COMPLETED (no spec delta) | Archive complete |
133
+ | Any | BLOCKED | Record breakpoint, wait for user |
134
+ | Any | FAILED | Fix and retry current skill |
135
+
136
+ ### Routing Output Template
137
+
138
+ After completing a skill, must output in this format:
139
+
140
+ ```markdown
141
+ ## Completion Status
142
+
143
+ **Status**: [COMPLETED / COMPLETED_WITH_DEVIATION / HANDOFF / BLOCKED / FAILED]
144
+
145
+ **Deviation Records**: [Has N pending / None]
146
+
147
+ ## Next Step
148
+
149
+ **Recommended**: `devbooks-xxx skill`
150
+
151
+ **Reason**: [specific reason]
152
+
153
+ **How to invoke**:
154
+ Run devbooks-xxx skill for change <change-id>
155
+ ```
156
+
157
+ ---
158
+
159
+ ## Interaction with design-backport
160
+
161
+ ### Trigger Conditions
162
+
163
+ When deviation-log.md has **pending records** (Backported=❌), must execute design-backport first.
164
+
165
+ ### Backport Completion Marking
166
+
167
+ After design-backport completes:
168
+ 1. Move record from "Pending" to "Completed"
169
+ 2. Update "Backported" column to ✅
170
+ 3. Record specific location backported to
171
+
172
+ ---
173
+
174
+ ## Detection Script (Optional)
175
+
176
+ ```bash
177
+ # Check for pending deviation backports
178
+ check_deviation() {
179
+ local change_dir="$1"
180
+ local log_file="${change_dir}/deviation-log.md"
181
+
182
+ if [[ ! -f "$log_file" ]]; then
183
+ echo "NO_DEVIATION"
184
+ return 0
185
+ fi
186
+
187
+ if grep -q "| ❌" "$log_file"; then
188
+ echo "HAS_PENDING_DEVIATION"
189
+ return 1
190
+ fi
191
+
192
+ echo "ALL_BACKPORTED"
193
+ return 0
194
+ }
195
+ ```
196
+
197
+ ---
198
+
199
+ *This protocol is core to the DevBooks Apply phase. All implementation skills must follow it.*
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: devbooks-brownfield-bootstrap
3
3
  description: "devbooks-brownfield-bootstrap: Brownfield project initialization. When the truth directory is empty, generate project profile, glossary, baseline specs, and minimum verification anchors to avoid 'patching specs while changing behavior'. Use when user says 'brownfield init/baseline specs/project profile/establish glossary/onboard legacy project to context protocol' etc."
4
- tools:
4
+ allowed-tools:
5
5
  - Glob
6
6
  - Grep
7
7
  - Read
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: devbooks-code-review
3
3
  description: devbooks-code-review: Perform readability/consistency/dependency health/code smell reviews as a Reviewer role, outputting only review comments and actionable suggestions without discussing business correctness. Use when user says "help me do code review/review maintainability/code smells/dependency risks/consistency suggestions", or when executing as reviewer during DevBooks apply phase.
4
- tools:
4
+ allowed-tools:
5
5
  - Glob
6
6
  - Grep
7
7
  - Read
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: devbooks-coder
3
3
  description: "devbooks-coder: Implements features strictly following tasks.md as the Coder role and runs quality gates. Modifying tests/ is prohibited; tests and static checks serve as the sole completion criteria. Use when the user says 'implement as planned/fix failing tests/make all gates green/implement task items/don't modify tests', or when executing as coder during the DevBooks apply phase."
4
- tools:
4
+ allowed-tools:
5
5
  - Glob
6
6
  - Grep
7
7
  - Read
@@ -245,45 +245,104 @@ Detection Results:
245
245
 
246
246
  ---
247
247
 
248
- ## Next Step Recommendations
248
+ ## Deviation Detection and Persistence Protocol
249
249
 
250
- **Reference**: `skills/_shared/workflow-next-steps.md`
250
+ **Reference**: `skills/_shared/references/deviation-detection-routing-protocol.md`
251
251
 
252
- After completing coder (all tasks done, gates Green), the next step is:
252
+ ### Real-time Persistence Requirements
253
253
 
254
- | Condition | Next Skill | Reason |
255
- |-----------|------------|--------|
256
- | All tasks completed | `devbooks-code-review` | Review for readability/consistency |
257
- | Test changes needed | Hand back to `devbooks-test-owner` | Coder cannot modify tests |
254
+ During implementation, you **must immediately** write to `deviation-log.md` in these situations:
255
+
256
+ | Situation | Type | Example |
257
+ |-----------|------|---------|
258
+ | Added functionality not in tasks.md | NEW_FEATURE | Added warmup() method |
259
+ | Modified constraint from design.md | CONSTRAINT_CHANGE | Timeout changed to 60s |
260
+ | Found edge case not covered by design | DESIGN_GAP | Concurrency scenario |
261
+ | Public interface differs from design | API_CHANGE | Added parameter |
262
+
263
+ ### deviation-log.md Format
264
+
265
+ ```markdown
266
+ # Deviation Log
267
+
268
+ ## Pending Backport Records
269
+
270
+ | Time | Type | Description | Affected Files | Backported |
271
+ |------|------|-------------|----------------|:----------:|
272
+ | 2024-01-15 10:30 | NEW_FEATURE | Added cache warmup feature | src/cache.ts | ❌ |
273
+ ```
274
+
275
+ ### Compact Protection
276
+
277
+ **Important**: deviation-log.md is a persistent file unaffected by compact. Even if the conversation is compressed, deviation information is preserved.
278
+
279
+ ---
280
+
281
+ ## Completion Status and Routing
282
+
283
+ ### Completion Status Classification (MECE)
284
+
285
+ | Code | Status | Determination Criteria | Next Step |
286
+ |:----:|--------|------------------------|-----------|
287
+ | ✅ | COMPLETED | All tasks done, no deviations | `devbooks-code-review` |
288
+ | ⚠️ | COMPLETED_WITH_DEVIATION | Tasks done, deviation-log has pending records | `devbooks-design-backport` |
289
+ | 🔄 | HANDOFF | Found test issues needing modification | `devbooks-test-owner` |
290
+ | ❌ | BLOCKED | Needs external input/decision | Record breakpoint, wait for user |
291
+ | 💥 | FAILED | Gates not passed | Fix and retry |
292
+
293
+ ### Status Determination Flow
258
294
 
259
- **CRITICAL**:
260
- - Coder **cannot modify** `tests/**`
261
- - If test issues are found, hand back to Test Owner (separate chat)
262
- - The workflow order is:
263
295
  ```
264
- coder code-review → spec-gardener (if spec deltas) → archive
296
+ 1. Check if deviation-log.md has "| ❌" records
297
+ → Yes: COMPLETED_WITH_DEVIATION
298
+
299
+ 2. Check if tests/ modification needed
300
+ → Yes: HANDOFF to test-owner
301
+
302
+ 3. Check if tasks.md is fully completed
303
+ → No: BLOCKED or FAILED
304
+
305
+ 4. All checks passed
306
+ → COMPLETED
265
307
  ```
266
308
 
267
- ### Output Template
309
+ ### Routing Output Template (Required)
268
310
 
269
- After completing coder (all gates Green), output:
311
+ After completing coder, you **must** output in this format:
270
312
 
271
313
  ```markdown
272
- ## Recommended Next Step
314
+ ## Completion Status
315
+
316
+ **Status**: ✅ COMPLETED / ⚠️ COMPLETED_WITH_DEVIATION / 🔄 HANDOFF / ❌ BLOCKED / 💥 FAILED
317
+
318
+ **Task Progress**: X/Y completed
273
319
 
274
- **Next: `devbooks-code-review`**
320
+ **Deviation Records**: Has N pending / None
275
321
 
276
- Reason: All tasks are complete and gates are Green. The next step is code review for readability, consistency, and maintainability.
322
+ ## Next Step
323
+
324
+ **Recommended**: `devbooks-xxx skill`
325
+
326
+ **Reason**: [specific reason]
277
327
 
278
328
  ### How to invoke
279
- ```
280
- Run devbooks-code-review skill for change <change-id>
329
+ Run devbooks-xxx skill for change <change-id>
281
330
  ```
282
331
 
283
- ### After Review
284
- - If spec deltas exist: `devbooks-spec-gardener` to merge into truth
285
- - If no spec deltas: Archive complete
286
- ```
332
+ ### Specific Routing Rules
333
+
334
+ | My Status | Next Step | Reason |
335
+ |-----------|-----------|--------|
336
+ | COMPLETED | `devbooks-code-review` | Review readability/consistency |
337
+ | COMPLETED_WITH_DEVIATION | `devbooks-design-backport` | Backport design first, then review |
338
+ | HANDOFF (test issue) | `devbooks-test-owner` | Coder cannot modify tests |
339
+ | BLOCKED | Wait for user | Record breakpoint area |
340
+ | FAILED | Fix and retry | Analyze failure reason |
341
+
342
+ **Critical Constraints**:
343
+ - Coder **can never modify** `tests/**`
344
+ - If test issues found, must HANDOFF to Test Owner (separate session)
345
+ - If deviations exist, must design-backport first before continuing
287
346
 
288
347
  ---
289
348
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: devbooks-delivery-workflow
3
3
  description: devbooks-delivery-workflow: Run a change through a traceable closed-loop workflow (Design->Plan->Trace->Verify->Implement->Archive), with clear DoD, traceability matrix, and role isolation (Test Owner and Coder separation). Use when the user says "run closed-loop/delivery acceptance/traceability matrix/DoD/close and archive/acceptance workflow" etc.
4
- tools:
4
+ allowed-tools:
5
5
  - Glob
6
6
  - Grep
7
7
  - Read
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: devbooks-design-backport
3
3
  description: devbooks-design-backport: Backport newly discovered constraints, conflicts, or gaps from implementation back to design.md (keeping design as the golden truth), with annotated decisions and impacts. Use when the user says "backport design/update design doc/Design Backport/design-implementation mismatch/need to clarify constraints" etc.
4
- tools:
4
+ allowed-tools:
5
5
  - Glob
6
6
  - Grep
7
7
  - Read
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: devbooks-design-doc
3
3
  description: devbooks-design-doc: Produce design documents (design.md) for change packages, focusing only on What/Constraints and AC-xxx, without implementation steps. Use when user says "write design doc/Design Doc/architecture design/constraints/acceptance criteria/AC/C4 Delta" etc.
4
- tools:
4
+ allowed-tools:
5
5
  - Glob
6
6
  - Grep
7
7
  - Read