claude-code-workflow 6.0.5 → 6.1.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 (117) hide show
  1. package/.claude/agents/action-planning-agent.md +1 -1
  2. package/.claude/agents/cli-execution-agent.md +269 -269
  3. package/.claude/agents/cli-explore-agent.md +182 -182
  4. package/.claude/agents/context-search-agent.md +582 -582
  5. package/.claude/agents/memory-bridge.md +93 -93
  6. package/.claude/commands/cli/cli-init.md +1 -1
  7. package/.claude/commands/memory/docs-full-cli.md +471 -471
  8. package/.claude/commands/memory/docs-related-cli.md +386 -386
  9. package/.claude/commands/memory/docs.md +615 -615
  10. package/.claude/commands/memory/load.md +1 -1
  11. package/.claude/commands/memory/update-full.md +332 -332
  12. package/.claude/commands/memory/update-related.md +5 -5
  13. package/.claude/commands/workflow/init.md +1 -1
  14. package/.claude/commands/workflow/lite-fix.md +621 -621
  15. package/.claude/commands/workflow/lite-plan.md +592 -592
  16. package/.claude/commands/workflow/tools/context-gather.md +434 -434
  17. package/.claude/commands/workflow/ui-design/generate.md +504 -504
  18. package/.claude/commands/workflow/ui-design/import-from-code.md +537 -537
  19. package/.claude/scripts/classify-folders.sh +4 -0
  20. package/.claude/scripts/convert_tokens_to_css.sh +4 -0
  21. package/.claude/scripts/detect_changed_modules.sh +5 -1
  22. package/.claude/scripts/discover-design-files.sh +87 -83
  23. package/.claude/scripts/generate_module_docs.sh +717 -713
  24. package/.claude/scripts/get_modules_by_depth.sh +5 -1
  25. package/.claude/scripts/ui-generate-preview.sh +4 -0
  26. package/.claude/scripts/ui-instantiate-prototypes.sh +4 -0
  27. package/.claude/scripts/update_module_claude.sh +4 -0
  28. package/.claude/skills/command-guide/index/all-commands.json +1 -12
  29. package/.claude/skills/command-guide/index/by-category.json +1 -12
  30. package/.claude/skills/command-guide/index/by-use-case.json +1 -12
  31. package/.claude/skills/command-guide/index/essential-commands.json +1 -12
  32. package/.claude/skills/command-guide/reference/agents/action-planning-agent.md +127 -71
  33. package/.claude/skills/command-guide/reference/agents/cli-execution-agent.md +269 -269
  34. package/.claude/skills/command-guide/reference/agents/cli-explore-agent.md +182 -182
  35. package/.claude/skills/command-guide/reference/agents/conceptual-planning-agent.md +18 -38
  36. package/.claude/skills/command-guide/reference/agents/context-search-agent.md +582 -577
  37. package/.claude/skills/command-guide/reference/agents/memory-bridge.md +93 -93
  38. package/.claude/skills/command-guide/reference/commands/cli/cli-init.md +1 -1
  39. package/.claude/skills/command-guide/reference/commands/memory/docs-full-cli.md +471 -471
  40. package/.claude/skills/command-guide/reference/commands/memory/docs-related-cli.md +386 -386
  41. package/.claude/skills/command-guide/reference/commands/memory/docs.md +615 -610
  42. package/.claude/skills/command-guide/reference/commands/memory/load.md +1 -1
  43. package/.claude/skills/command-guide/reference/commands/memory/update-full.md +332 -332
  44. package/.claude/skills/command-guide/reference/commands/memory/update-related.md +5 -5
  45. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/artifacts.md +299 -451
  46. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/auto-parallel.md +14 -37
  47. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/synthesis.md +252 -350
  48. package/.claude/skills/command-guide/reference/commands/workflow/init.md +2 -2
  49. package/.claude/skills/command-guide/reference/commands/workflow/lite-execute.md +52 -0
  50. package/.claude/skills/command-guide/reference/commands/workflow/lite-fix.md +621 -602
  51. package/.claude/skills/command-guide/reference/commands/workflow/lite-plan.md +46 -36
  52. package/.claude/skills/command-guide/reference/commands/workflow/review-fix.md +18 -58
  53. package/.claude/skills/command-guide/reference/commands/workflow/review-module-cycle.md +22 -52
  54. package/.claude/skills/command-guide/reference/commands/workflow/review-session-cycle.md +19 -48
  55. package/.claude/skills/command-guide/reference/commands/workflow/session/start.md +25 -5
  56. package/.claude/skills/command-guide/reference/commands/workflow/tdd-plan.md +1 -1
  57. package/.claude/skills/command-guide/reference/commands/workflow/test-fix-gen.md +7 -7
  58. package/.claude/skills/command-guide/reference/commands/workflow/tools/context-gather.md +434 -434
  59. package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-agent.md +151 -11
  60. package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-tdd.md +4 -4
  61. package/.claude/skills/command-guide/reference/commands/workflow/tools/test-task-generate.md +1 -1
  62. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/generate.md +504 -504
  63. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/import-from-code.md +537 -537
  64. package/.claude/workflows/context-search-strategy.md +77 -77
  65. package/.claude/workflows/tool-strategy.md +90 -71
  66. package/.claude/workflows/workflow-architecture.md +1 -1
  67. package/ccw/src/cli.js +7 -0
  68. package/ccw/src/commands/tool.js +181 -0
  69. package/ccw/src/core/dashboard-generator.js +18 -3
  70. package/ccw/src/core/lite-scanner.js +35 -11
  71. package/ccw/src/core/server.js +531 -46
  72. package/ccw/src/templates/dashboard-css/01-base.css +161 -0
  73. package/ccw/src/templates/dashboard-css/02-session.css +726 -0
  74. package/ccw/src/templates/dashboard-css/03-tasks.css +512 -0
  75. package/ccw/src/templates/dashboard-css/04-lite-tasks.css +843 -0
  76. package/ccw/src/templates/dashboard-css/05-context.css +2206 -0
  77. package/ccw/src/templates/dashboard-css/06-cards.css +1570 -0
  78. package/ccw/src/templates/dashboard-css/07-managers.css +936 -0
  79. package/ccw/src/templates/dashboard-css/08-review.css +1266 -0
  80. package/ccw/src/templates/dashboard-css/09-explorer.css +1397 -0
  81. package/ccw/src/templates/dashboard-js/components/global-notifications.js +219 -0
  82. package/ccw/src/templates/dashboard-js/components/hook-manager.js +10 -0
  83. package/ccw/src/templates/dashboard-js/components/mcp-manager.js +11 -1
  84. package/ccw/src/templates/dashboard-js/components/navigation.js +11 -5
  85. package/ccw/src/templates/dashboard-js/components/tabs-context.js +20 -20
  86. package/ccw/src/templates/dashboard-js/components/tabs-other.js +11 -11
  87. package/ccw/src/templates/dashboard-js/components/theme.js +29 -1
  88. package/ccw/src/templates/dashboard-js/main.js +4 -0
  89. package/ccw/src/templates/dashboard-js/state.js +5 -0
  90. package/ccw/src/templates/dashboard-js/views/explorer.js +852 -0
  91. package/ccw/src/templates/dashboard-js/views/home.js +13 -9
  92. package/ccw/src/templates/dashboard-js/views/hook-manager.js +8 -5
  93. package/ccw/src/templates/dashboard-js/views/lite-tasks.js +21 -16
  94. package/ccw/src/templates/dashboard-js/views/mcp-manager.js +90 -19
  95. package/ccw/src/templates/dashboard-js/views/project-overview.js +15 -11
  96. package/ccw/src/templates/dashboard-js/views/review-session.js +3 -3
  97. package/ccw/src/templates/dashboard-js/views/session-detail.js +38 -28
  98. package/ccw/src/templates/dashboard.html +129 -28
  99. package/ccw/src/tools/classify-folders.js +204 -0
  100. package/ccw/src/tools/convert-tokens-to-css.js +250 -0
  101. package/ccw/src/tools/detect-changed-modules.js +288 -0
  102. package/ccw/src/tools/discover-design-files.js +134 -0
  103. package/ccw/src/tools/edit-file.js +266 -0
  104. package/ccw/src/tools/generate-module-docs.js +416 -0
  105. package/ccw/src/tools/get-modules-by-depth.js +308 -0
  106. package/ccw/src/tools/index.js +176 -0
  107. package/ccw/src/tools/ui-generate-preview.js +327 -0
  108. package/ccw/src/tools/ui-instantiate-prototypes.js +301 -0
  109. package/ccw/src/tools/update-module-claude.js +380 -0
  110. package/package.json +1 -1
  111. package/.claude/skills/command-guide/reference/commands/workflow/status.md +0 -352
  112. package/ccw/src/core/server.js.bak +0 -385
  113. package/ccw/src/core/server_original.bak +0 -385
  114. package/ccw/src/templates/dashboard.css +0 -8187
  115. package/ccw/src/templates/dashboard_tailwind.html +0 -42
  116. package/ccw/src/templates/dashboard_test.html +0 -37
  117. package/ccw/src/templates/tailwind-base.css +0 -212
@@ -1,386 +1,386 @@
1
- ---
2
- name: docs-related-cli
3
- description: Generate/update documentation for git-changed modules using CLI execution with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <15 modules uses direct parallel
4
- argument-hint: "[--tool <gemini|qwen|codex>]"
5
- ---
6
-
7
- # Related Documentation Generation - CLI Mode (/memory:docs-related-cli)
8
-
9
- ## Overview
10
-
11
- Orchestrates context-aware documentation generation/update for changed modules using CLI-based execution with batched agents and automatic tool fallback (gemini→qwen→codex).
12
-
13
- **Parameters**:
14
- - `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
15
-
16
- **Execution Flow**:
17
- 1. Change Detection → 2. Plan Presentation → 3. Batched Execution → 4. Verification
18
-
19
- ## Core Rules
20
-
21
- 1. **Detect Changes First**: Use git diff to identify affected modules
22
- 2. **Wait for Approval**: Present plan, no execution without user confirmation
23
- 3. **Execution Strategy**:
24
- - **<15 modules**: Direct parallel execution (max 4 concurrent per depth, no agent overhead)
25
- - **≥15 modules**: Agent batch processing (4 modules/agent, 73% overhead reduction)
26
- 4. **Tool Fallback**: Auto-retry with fallback tools on failure
27
- 5. **Depth Sequential**: Process depths N→0, parallel batches within depth (both modes)
28
- 6. **Related Mode**: Generate/update only changed modules and their parent contexts
29
- 7. **Single Strategy**: Always use `single` strategy (incremental update)
30
-
31
- ## Tool Fallback Hierarchy
32
-
33
- ```javascript
34
- --tool gemini → [gemini, qwen, codex] // default
35
- --tool qwen → [qwen, gemini, codex]
36
- --tool codex → [codex, gemini, qwen]
37
- ```
38
-
39
- **Trigger**: Non-zero exit code from generation script
40
-
41
- | Tool | Best For | Fallback To |
42
- |--------|--------------------------------|----------------|
43
- | gemini | Documentation, patterns | qwen → codex |
44
- | qwen | Architecture, system design | gemini → codex |
45
- | codex | Implementation, code quality | gemini → qwen |
46
-
47
- ## Phase 1: Change Detection & Analysis
48
-
49
- ```javascript
50
- // Get project metadata
51
- Bash({command: "pwd && basename \"$(pwd)\" && git rev-parse --show-toplevel 2>/dev/null || pwd", run_in_background: false});
52
-
53
- // Detect changed modules
54
- Bash({command: "~/.claude/scripts/detect_changed_modules.sh list", run_in_background: false});
55
-
56
- // Cache git changes
57
- Bash({command: "git add -A 2>/dev/null || true", run_in_background: false});
58
- ```
59
-
60
- **Parse output** `depth:N|path:<PATH>|change:<TYPE>|type:<code|navigation>` to extract affected modules.
61
-
62
- **Smart filter**: Auto-detect and skip tests/build/config/vendor based on project tech stack (Node.js/Python/Go/Rust/etc).
63
-
64
- **Fallback**: If no changes detected, use recent modules (first 10 by depth).
65
-
66
- ## Phase 2: Plan Presentation
67
-
68
- **Present filtered plan**:
69
- ```
70
- Related Documentation Generation Plan:
71
- Tool: gemini (fallback: qwen → codex)
72
- Changed: 4 modules | Batching: 4 modules/agent
73
- Project: myproject
74
- Output: .workflow/docs/myproject/
75
-
76
- Will generate/update docs for:
77
- - ./src/api/auth (5 files, type: code) [new module]
78
- - ./src/api (12 files, type: code) [parent of changed auth/]
79
- - ./src (8 files, type: code) [parent context]
80
- - . (14 files, type: code) [root level]
81
-
82
- Documentation Strategy:
83
- - Strategy: single (all modules - incremental update)
84
- - Output: API.md + README.md (code folders), README.md only (navigation folders)
85
- - Context: Current dir code + child docs
86
-
87
- Auto-skipped (12 paths):
88
- - Tests: ./src/api/auth.test.ts (8 paths)
89
- - Config: tsconfig.json (3 paths)
90
- - Other: node_modules (1 path)
91
-
92
- Agent allocation:
93
- - Depth 3 (1 module): 1 agent [1]
94
- - Depth 2 (1 module): 1 agent [1]
95
- - Depth 1 (1 module): 1 agent [1]
96
- - Depth 0 (1 module): 1 agent [1]
97
-
98
- Estimated time: ~5-10 minutes
99
-
100
- Confirm execution? (y/n)
101
- ```
102
-
103
- **Decision logic**:
104
- - User confirms "y": Proceed with execution
105
- - User declines "n": Abort, no changes
106
- - <15 modules: Direct execution
107
- - ≥15 modules: Agent batch execution
108
-
109
- ## Phase 3A: Direct Execution (<15 modules)
110
-
111
- **Strategy**: Parallel execution within depth (max 4 concurrent), no agent overhead.
112
-
113
- **CRITICAL**: All Bash commands use `run_in_background: false` for synchronous execution.
114
-
115
- ```javascript
116
- let project_name = detect_project_name();
117
-
118
- for (let depth of sorted_depths.reverse()) { // N → 0
119
- let batches = batch_modules(modules_by_depth[depth], 4);
120
-
121
- for (let batch of batches) {
122
- let parallel_tasks = batch.map(module => {
123
- return async () => {
124
- for (let tool of tool_order) {
125
- Bash({
126
- command: `cd ${module.path} && ~/.claude/scripts/generate_module_docs.sh "single" "." "${project_name}" "${tool}"`,
127
- run_in_background: false
128
- });
129
- if (bash_result.exit_code === 0) {
130
- report(`✅ ${module.path} docs generated with ${tool}`);
131
- return true;
132
- }
133
- }
134
- report(`❌ FAILED: ${module.path} failed all tools`);
135
- return false;
136
- };
137
- });
138
- await Promise.all(parallel_tasks.map(task => task()));
139
- }
140
- }
141
- ```
142
-
143
- ## Phase 3B: Agent Batch Execution (≥15 modules)
144
-
145
- ### Batching Strategy
146
-
147
- ```javascript
148
- // Batch modules into groups of 4
149
- function batch_modules(modules, batch_size = 4) {
150
- let batches = [];
151
- for (let i = 0; i < modules.length; i += batch_size) {
152
- batches.push(modules.slice(i, i + batch_size));
153
- }
154
- return batches;
155
- }
156
- // Examples: 10→[4,4,2] | 8→[4,4] | 3→[3]
157
- ```
158
-
159
- ### Coordinator Orchestration
160
-
161
- ```javascript
162
- let modules_by_depth = group_by_depth(changed_modules);
163
- let tool_order = construct_tool_order(primary_tool);
164
- let project_name = detect_project_name();
165
-
166
- for (let depth of sorted_depths.reverse()) { // N → 0
167
- let batches = batch_modules(modules_by_depth[depth], 4);
168
- let worker_tasks = [];
169
-
170
- for (let batch of batches) {
171
- worker_tasks.push(
172
- Task(
173
- subagent_type="memory-bridge",
174
- description=`Generate docs for ${batch.length} modules at depth ${depth}`,
175
- prompt=generate_batch_worker_prompt(batch, tool_order, depth, project_name, "related")
176
- )
177
- );
178
- }
179
-
180
- await parallel_execute(worker_tasks); // Batches run in parallel
181
- }
182
- ```
183
-
184
- ### Batch Worker Prompt Template
185
-
186
- ```
187
- PURPOSE: Generate/update documentation for assigned modules with tool fallback (related mode)
188
-
189
- TASK:
190
- Generate documentation for the following modules based on recent changes. For each module, try tools in order until success.
191
-
192
- PROJECT: {{project_name}}
193
- OUTPUT: .workflow/docs/{{project_name}}/
194
-
195
- MODULES:
196
- {{module_path_1}} (type: {{folder_type_1}})
197
- {{module_path_2}} (type: {{folder_type_2}})
198
- {{module_path_3}} (type: {{folder_type_3}})
199
- {{module_path_4}} (type: {{folder_type_4}})
200
-
201
- TOOLS (try in order):
202
- 1. {{tool_1}}
203
- 2. {{tool_2}}
204
- 3. {{tool_3}}
205
-
206
- EXECUTION:
207
- For each module above:
208
- 1. Try tool 1:
209
- Bash({
210
- command: `cd "{{module_path}}" && ~/.claude/scripts/generate_module_docs.sh "single" "." "{{project_name}}" "{{tool_1}}"`,
211
- run_in_background: false
212
- })
213
- → Success: Report "✅ {{module_path}} docs generated with {{tool_1}}", proceed to next module
214
- → Failure: Try tool 2
215
- 2. Try tool 2:
216
- Bash({
217
- command: `cd "{{module_path}}" && ~/.claude/scripts/generate_module_docs.sh "single" "." "{{project_name}}" "{{tool_2}}"`,
218
- run_in_background: false
219
- })
220
- → Success: Report "✅ {{module_path}} docs generated with {{tool_2}}", proceed to next module
221
- → Failure: Try tool 3
222
- 3. Try tool 3:
223
- Bash({
224
- command: `cd "{{module_path}}" && ~/.claude/scripts/generate_module_docs.sh "single" "." "{{project_name}}" "{{tool_3}}"`,
225
- run_in_background: false
226
- })
227
- → Success: Report "✅ {{module_path}} docs generated with {{tool_3}}", proceed to next module
228
- → Failure: Report "❌ FAILED: {{module_path}} failed all tools", proceed to next module
229
-
230
- FOLDER TYPE HANDLING:
231
- - code: Generate API.md + README.md
232
- - navigation: Generate README.md only
233
-
234
- REPORTING:
235
- Report final summary with:
236
- - Total processed: X modules
237
- - Successful: Y modules
238
- - Failed: Z modules
239
- - Tool usage: {{tool_1}}:X, {{tool_2}}:Y, {{tool_3}}:Z
240
- ```
241
-
242
- ## Phase 4: Verification
243
-
244
- ```javascript
245
- // Check documentation files created/updated
246
- Bash({command: 'find .workflow/docs -type f -name "*.md" 2>/dev/null | wc -l', run_in_background: false});
247
-
248
- // Display recent changes
249
- Bash({command: 'find .workflow/docs -type f -name "*.md" -mmin -60 2>/dev/null', run_in_background: false});
250
- ```
251
-
252
- **Aggregate results**:
253
- ```
254
- Documentation Generation Summary:
255
- Total: 4 | Success: 4 | Failed: 0
256
-
257
- Tool usage:
258
- - gemini: 4 modules
259
- - qwen: 0 modules (fallback)
260
- - codex: 0 modules
261
-
262
- Changes:
263
- .workflow/docs/myproject/src/api/auth/API.md (new)
264
- .workflow/docs/myproject/src/api/auth/README.md (new)
265
- .workflow/docs/myproject/src/api/API.md (updated)
266
- .workflow/docs/myproject/src/api/README.md (updated)
267
- .workflow/docs/myproject/src/API.md (updated)
268
- .workflow/docs/myproject/src/README.md (updated)
269
- .workflow/docs/myproject/API.md (updated)
270
- .workflow/docs/myproject/README.md (updated)
271
- ```
272
-
273
- ## Execution Summary
274
-
275
- **Module Count Threshold**:
276
- - **<15 modules**: Coordinator executes Phase 3A (Direct Execution)
277
- - **≥15 modules**: Coordinator executes Phase 3B (Agent Batch Execution)
278
-
279
- **Agent Hierarchy** (for ≥15 modules):
280
- - **Coordinator**: Handles batch division, spawns worker agents per depth
281
- - **Worker Agents**: Each processes 4 modules with tool fallback (related mode)
282
-
283
- ## Error Handling
284
-
285
- **Batch Worker**:
286
- - Tool fallback per module (auto-retry)
287
- - Batch isolation (failures don't propagate)
288
- - Clear per-module status reporting
289
-
290
- **Coordinator**:
291
- - No changes: Use fallback (recent 10 modules)
292
- - User decline: No execution
293
- - Verification fail: Report incomplete modules
294
- - Partial failures: Continue execution, report failed modules
295
-
296
- **Fallback Triggers**:
297
- - Non-zero exit code
298
- - Script timeout
299
- - Unexpected output
300
-
301
- ## Output Structure
302
-
303
- ```
304
- .workflow/docs/{project_name}/
305
- ├── src/ # Mirrors source structure
306
- │ ├── modules/
307
- │ │ ├── README.md
308
- │ │ ├── auth/
309
- │ │ │ ├── API.md # Updated based on code changes
310
- │ │ │ └── README.md # Updated based on code changes
311
- │ │ └── api/
312
- │ │ ├── API.md
313
- │ │ └── README.md
314
- │ └── utils/
315
- │ └── README.md
316
- └── README.md
317
- ```
318
-
319
- ## Usage Examples
320
-
321
- ```bash
322
- # Daily development documentation update
323
- /memory:docs-related-cli
324
-
325
- # After feature work with specific tool
326
- /memory:docs-related-cli --tool qwen
327
-
328
- # Code quality documentation review after implementation
329
- /memory:docs-related-cli --tool codex
330
- ```
331
-
332
- ## Key Advantages
333
-
334
- **Efficiency**: 30 modules → 8 agents (73% reduction)
335
- **Resilience**: 3-tier fallback per module
336
- **Performance**: Parallel batches, no concurrency limits
337
- **Context-aware**: Updates based on actual git changes
338
- **Fast**: Only affected modules, not entire project
339
- **Incremental**: Single strategy for focused updates
340
-
341
- ## Coordinator Checklist
342
-
343
- - Parse `--tool` (default: gemini)
344
- - Get project metadata (name, root)
345
- - Detect changed modules via detect_changed_modules.sh
346
- - **Smart filter modules** (auto-detect tech stack, skip tests/build/config/vendor)
347
- - Cache git changes
348
- - Apply fallback if no changes (recent 10 modules)
349
- - Construct tool fallback order
350
- - **Present filtered plan** with skip reasons and change types
351
- - **Wait for y/n confirmation**
352
- - Determine execution mode:
353
- - **<15 modules**: Direct execution (Phase 3A)
354
- - For each depth (N→0): Sequential module updates with tool fallback
355
- - **≥15 modules**: Agent batch execution (Phase 3B)
356
- - For each depth (N→0): Batch modules (4 per batch), spawn batch workers in parallel
357
- - Wait for depth/batch completion
358
- - Aggregate results
359
- - Verification check (documentation files created/updated)
360
- - Display summary + recent changes
361
-
362
- ## Comparison with Full Documentation Generation
363
-
364
- | Aspect | Related Generation | Full Generation |
365
- |--------|-------------------|-----------------|
366
- | **Scope** | Changed modules only | All project modules |
367
- | **Speed** | Fast (minutes) | Slower (10-30 min) |
368
- | **Use case** | Daily development | Initial setup, major refactoring |
369
- | **Strategy** | `single` (all) | `full` (L3) + `single` (L1-2) |
370
- | **Trigger** | After commits | After setup or major changes |
371
- | **Batching** | 4 modules/agent | 4 modules/agent |
372
- | **Fallback** | gemini→qwen→codex | gemini→qwen→codex |
373
- | **Complexity threshold** | ≤15 modules | ≤20 modules |
374
-
375
- ## Template Reference
376
-
377
- Templates used from `~/.claude/workflows/cli-templates/prompts/documentation/`:
378
- - `api.txt`: Code API documentation
379
- - `module-readme.txt`: Module purpose, usage, dependencies
380
- - `folder-navigation.txt`: Navigation README for folders
381
-
382
- ## Related Commands
383
-
384
- - `/memory:docs-full-cli` - Full project documentation generation
385
- - `/memory:docs` - Agent-based documentation planning workflow
386
- - `/memory:update-related` - Update CLAUDE.md for changed modules
1
+ ---
2
+ name: docs-related-cli
3
+ description: Generate/update documentation for git-changed modules using CLI execution with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <15 modules uses direct parallel
4
+ argument-hint: "[--tool <gemini|qwen|codex>]"
5
+ ---
6
+
7
+ # Related Documentation Generation - CLI Mode (/memory:docs-related-cli)
8
+
9
+ ## Overview
10
+
11
+ Orchestrates context-aware documentation generation/update for changed modules using CLI-based execution with batched agents and automatic tool fallback (gemini→qwen→codex).
12
+
13
+ **Parameters**:
14
+ - `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
15
+
16
+ **Execution Flow**:
17
+ 1. Change Detection → 2. Plan Presentation → 3. Batched Execution → 4. Verification
18
+
19
+ ## Core Rules
20
+
21
+ 1. **Detect Changes First**: Use git diff to identify affected modules
22
+ 2. **Wait for Approval**: Present plan, no execution without user confirmation
23
+ 3. **Execution Strategy**:
24
+ - **<15 modules**: Direct parallel execution (max 4 concurrent per depth, no agent overhead)
25
+ - **≥15 modules**: Agent batch processing (4 modules/agent, 73% overhead reduction)
26
+ 4. **Tool Fallback**: Auto-retry with fallback tools on failure
27
+ 5. **Depth Sequential**: Process depths N→0, parallel batches within depth (both modes)
28
+ 6. **Related Mode**: Generate/update only changed modules and their parent contexts
29
+ 7. **Single Strategy**: Always use `single` strategy (incremental update)
30
+
31
+ ## Tool Fallback Hierarchy
32
+
33
+ ```javascript
34
+ --tool gemini → [gemini, qwen, codex] // default
35
+ --tool qwen → [qwen, gemini, codex]
36
+ --tool codex → [codex, gemini, qwen]
37
+ ```
38
+
39
+ **Trigger**: Non-zero exit code from generation script
40
+
41
+ | Tool | Best For | Fallback To |
42
+ |--------|--------------------------------|----------------|
43
+ | gemini | Documentation, patterns | qwen → codex |
44
+ | qwen | Architecture, system design | gemini → codex |
45
+ | codex | Implementation, code quality | gemini → qwen |
46
+
47
+ ## Phase 1: Change Detection & Analysis
48
+
49
+ ```javascript
50
+ // Get project metadata
51
+ Bash({command: "pwd && basename \"$(pwd)\" && git rev-parse --show-toplevel 2>/dev/null || pwd", run_in_background: false});
52
+
53
+ // Detect changed modules
54
+ Bash({command: "ccw tool exec detect_changed_modules '{\"format\":\"list\"}'", run_in_background: false});
55
+
56
+ // Cache git changes
57
+ Bash({command: "git add -A 2>/dev/null || true", run_in_background: false});
58
+ ```
59
+
60
+ **Parse output** `depth:N|path:<PATH>|change:<TYPE>|type:<code|navigation>` to extract affected modules.
61
+
62
+ **Smart filter**: Auto-detect and skip tests/build/config/vendor based on project tech stack (Node.js/Python/Go/Rust/etc).
63
+
64
+ **Fallback**: If no changes detected, use recent modules (first 10 by depth).
65
+
66
+ ## Phase 2: Plan Presentation
67
+
68
+ **Present filtered plan**:
69
+ ```
70
+ Related Documentation Generation Plan:
71
+ Tool: gemini (fallback: qwen → codex)
72
+ Changed: 4 modules | Batching: 4 modules/agent
73
+ Project: myproject
74
+ Output: .workflow/docs/myproject/
75
+
76
+ Will generate/update docs for:
77
+ - ./src/api/auth (5 files, type: code) [new module]
78
+ - ./src/api (12 files, type: code) [parent of changed auth/]
79
+ - ./src (8 files, type: code) [parent context]
80
+ - . (14 files, type: code) [root level]
81
+
82
+ Documentation Strategy:
83
+ - Strategy: single (all modules - incremental update)
84
+ - Output: API.md + README.md (code folders), README.md only (navigation folders)
85
+ - Context: Current dir code + child docs
86
+
87
+ Auto-skipped (12 paths):
88
+ - Tests: ./src/api/auth.test.ts (8 paths)
89
+ - Config: tsconfig.json (3 paths)
90
+ - Other: node_modules (1 path)
91
+
92
+ Agent allocation:
93
+ - Depth 3 (1 module): 1 agent [1]
94
+ - Depth 2 (1 module): 1 agent [1]
95
+ - Depth 1 (1 module): 1 agent [1]
96
+ - Depth 0 (1 module): 1 agent [1]
97
+
98
+ Estimated time: ~5-10 minutes
99
+
100
+ Confirm execution? (y/n)
101
+ ```
102
+
103
+ **Decision logic**:
104
+ - User confirms "y": Proceed with execution
105
+ - User declines "n": Abort, no changes
106
+ - <15 modules: Direct execution
107
+ - ≥15 modules: Agent batch execution
108
+
109
+ ## Phase 3A: Direct Execution (<15 modules)
110
+
111
+ **Strategy**: Parallel execution within depth (max 4 concurrent), no agent overhead.
112
+
113
+ **CRITICAL**: All Bash commands use `run_in_background: false` for synchronous execution.
114
+
115
+ ```javascript
116
+ let project_name = detect_project_name();
117
+
118
+ for (let depth of sorted_depths.reverse()) { // N → 0
119
+ let batches = batch_modules(modules_by_depth[depth], 4);
120
+
121
+ for (let batch of batches) {
122
+ let parallel_tasks = batch.map(module => {
123
+ return async () => {
124
+ for (let tool of tool_order) {
125
+ Bash({
126
+ command: `cd ${module.path} && ccw tool exec generate_module_docs '{"strategy":"single","sourcePath":".","projectName":"${project_name}","tool":"${tool}"}'`,
127
+ run_in_background: false
128
+ });
129
+ if (bash_result.exit_code === 0) {
130
+ report(`✅ ${module.path} docs generated with ${tool}`);
131
+ return true;
132
+ }
133
+ }
134
+ report(`❌ FAILED: ${module.path} failed all tools`);
135
+ return false;
136
+ };
137
+ });
138
+ await Promise.all(parallel_tasks.map(task => task()));
139
+ }
140
+ }
141
+ ```
142
+
143
+ ## Phase 3B: Agent Batch Execution (≥15 modules)
144
+
145
+ ### Batching Strategy
146
+
147
+ ```javascript
148
+ // Batch modules into groups of 4
149
+ function batch_modules(modules, batch_size = 4) {
150
+ let batches = [];
151
+ for (let i = 0; i < modules.length; i += batch_size) {
152
+ batches.push(modules.slice(i, i + batch_size));
153
+ }
154
+ return batches;
155
+ }
156
+ // Examples: 10→[4,4,2] | 8→[4,4] | 3→[3]
157
+ ```
158
+
159
+ ### Coordinator Orchestration
160
+
161
+ ```javascript
162
+ let modules_by_depth = group_by_depth(changed_modules);
163
+ let tool_order = construct_tool_order(primary_tool);
164
+ let project_name = detect_project_name();
165
+
166
+ for (let depth of sorted_depths.reverse()) { // N → 0
167
+ let batches = batch_modules(modules_by_depth[depth], 4);
168
+ let worker_tasks = [];
169
+
170
+ for (let batch of batches) {
171
+ worker_tasks.push(
172
+ Task(
173
+ subagent_type="memory-bridge",
174
+ description=`Generate docs for ${batch.length} modules at depth ${depth}`,
175
+ prompt=generate_batch_worker_prompt(batch, tool_order, depth, project_name, "related")
176
+ )
177
+ );
178
+ }
179
+
180
+ await parallel_execute(worker_tasks); // Batches run in parallel
181
+ }
182
+ ```
183
+
184
+ ### Batch Worker Prompt Template
185
+
186
+ ```
187
+ PURPOSE: Generate/update documentation for assigned modules with tool fallback (related mode)
188
+
189
+ TASK:
190
+ Generate documentation for the following modules based on recent changes. For each module, try tools in order until success.
191
+
192
+ PROJECT: {{project_name}}
193
+ OUTPUT: .workflow/docs/{{project_name}}/
194
+
195
+ MODULES:
196
+ {{module_path_1}} (type: {{folder_type_1}})
197
+ {{module_path_2}} (type: {{folder_type_2}})
198
+ {{module_path_3}} (type: {{folder_type_3}})
199
+ {{module_path_4}} (type: {{folder_type_4}})
200
+
201
+ TOOLS (try in order):
202
+ 1. {{tool_1}}
203
+ 2. {{tool_2}}
204
+ 3. {{tool_3}}
205
+
206
+ EXECUTION:
207
+ For each module above:
208
+ 1. Try tool 1:
209
+ Bash({
210
+ command: `cd "{{module_path}}" && ccw tool exec generate_module_docs '{"strategy":"single","sourcePath":".","projectName":"{{project_name}}","tool":"{{tool_1}}"}'`,
211
+ run_in_background: false
212
+ })
213
+ → Success: Report "✅ {{module_path}} docs generated with {{tool_1}}", proceed to next module
214
+ → Failure: Try tool 2
215
+ 2. Try tool 2:
216
+ Bash({
217
+ command: `cd "{{module_path}}" && ccw tool exec generate_module_docs '{"strategy":"single","sourcePath":".","projectName":"{{project_name}}","tool":"{{tool_2}}"}'`,
218
+ run_in_background: false
219
+ })
220
+ → Success: Report "✅ {{module_path}} docs generated with {{tool_2}}", proceed to next module
221
+ → Failure: Try tool 3
222
+ 3. Try tool 3:
223
+ Bash({
224
+ command: `cd "{{module_path}}" && ccw tool exec generate_module_docs '{"strategy":"single","sourcePath":".","projectName":"{{project_name}}","tool":"{{tool_3}}"}'`,
225
+ run_in_background: false
226
+ })
227
+ → Success: Report "✅ {{module_path}} docs generated with {{tool_3}}", proceed to next module
228
+ → Failure: Report "❌ FAILED: {{module_path}} failed all tools", proceed to next module
229
+
230
+ FOLDER TYPE HANDLING:
231
+ - code: Generate API.md + README.md
232
+ - navigation: Generate README.md only
233
+
234
+ REPORTING:
235
+ Report final summary with:
236
+ - Total processed: X modules
237
+ - Successful: Y modules
238
+ - Failed: Z modules
239
+ - Tool usage: {{tool_1}}:X, {{tool_2}}:Y, {{tool_3}}:Z
240
+ ```
241
+
242
+ ## Phase 4: Verification
243
+
244
+ ```javascript
245
+ // Check documentation files created/updated
246
+ Bash({command: 'find .workflow/docs -type f -name "*.md" 2>/dev/null | wc -l', run_in_background: false});
247
+
248
+ // Display recent changes
249
+ Bash({command: 'find .workflow/docs -type f -name "*.md" -mmin -60 2>/dev/null', run_in_background: false});
250
+ ```
251
+
252
+ **Aggregate results**:
253
+ ```
254
+ Documentation Generation Summary:
255
+ Total: 4 | Success: 4 | Failed: 0
256
+
257
+ Tool usage:
258
+ - gemini: 4 modules
259
+ - qwen: 0 modules (fallback)
260
+ - codex: 0 modules
261
+
262
+ Changes:
263
+ .workflow/docs/myproject/src/api/auth/API.md (new)
264
+ .workflow/docs/myproject/src/api/auth/README.md (new)
265
+ .workflow/docs/myproject/src/api/API.md (updated)
266
+ .workflow/docs/myproject/src/api/README.md (updated)
267
+ .workflow/docs/myproject/src/API.md (updated)
268
+ .workflow/docs/myproject/src/README.md (updated)
269
+ .workflow/docs/myproject/API.md (updated)
270
+ .workflow/docs/myproject/README.md (updated)
271
+ ```
272
+
273
+ ## Execution Summary
274
+
275
+ **Module Count Threshold**:
276
+ - **<15 modules**: Coordinator executes Phase 3A (Direct Execution)
277
+ - **≥15 modules**: Coordinator executes Phase 3B (Agent Batch Execution)
278
+
279
+ **Agent Hierarchy** (for ≥15 modules):
280
+ - **Coordinator**: Handles batch division, spawns worker agents per depth
281
+ - **Worker Agents**: Each processes 4 modules with tool fallback (related mode)
282
+
283
+ ## Error Handling
284
+
285
+ **Batch Worker**:
286
+ - Tool fallback per module (auto-retry)
287
+ - Batch isolation (failures don't propagate)
288
+ - Clear per-module status reporting
289
+
290
+ **Coordinator**:
291
+ - No changes: Use fallback (recent 10 modules)
292
+ - User decline: No execution
293
+ - Verification fail: Report incomplete modules
294
+ - Partial failures: Continue execution, report failed modules
295
+
296
+ **Fallback Triggers**:
297
+ - Non-zero exit code
298
+ - Script timeout
299
+ - Unexpected output
300
+
301
+ ## Output Structure
302
+
303
+ ```
304
+ .workflow/docs/{project_name}/
305
+ ├── src/ # Mirrors source structure
306
+ │ ├── modules/
307
+ │ │ ├── README.md
308
+ │ │ ├── auth/
309
+ │ │ │ ├── API.md # Updated based on code changes
310
+ │ │ │ └── README.md # Updated based on code changes
311
+ │ │ └── api/
312
+ │ │ ├── API.md
313
+ │ │ └── README.md
314
+ │ └── utils/
315
+ │ └── README.md
316
+ └── README.md
317
+ ```
318
+
319
+ ## Usage Examples
320
+
321
+ ```bash
322
+ # Daily development documentation update
323
+ /memory:docs-related-cli
324
+
325
+ # After feature work with specific tool
326
+ /memory:docs-related-cli --tool qwen
327
+
328
+ # Code quality documentation review after implementation
329
+ /memory:docs-related-cli --tool codex
330
+ ```
331
+
332
+ ## Key Advantages
333
+
334
+ **Efficiency**: 30 modules → 8 agents (73% reduction)
335
+ **Resilience**: 3-tier fallback per module
336
+ **Performance**: Parallel batches, no concurrency limits
337
+ **Context-aware**: Updates based on actual git changes
338
+ **Fast**: Only affected modules, not entire project
339
+ **Incremental**: Single strategy for focused updates
340
+
341
+ ## Coordinator Checklist
342
+
343
+ - Parse `--tool` (default: gemini)
344
+ - Get project metadata (name, root)
345
+ - Detect changed modules via detect_changed_modules.sh
346
+ - **Smart filter modules** (auto-detect tech stack, skip tests/build/config/vendor)
347
+ - Cache git changes
348
+ - Apply fallback if no changes (recent 10 modules)
349
+ - Construct tool fallback order
350
+ - **Present filtered plan** with skip reasons and change types
351
+ - **Wait for y/n confirmation**
352
+ - Determine execution mode:
353
+ - **<15 modules**: Direct execution (Phase 3A)
354
+ - For each depth (N→0): Sequential module updates with tool fallback
355
+ - **≥15 modules**: Agent batch execution (Phase 3B)
356
+ - For each depth (N→0): Batch modules (4 per batch), spawn batch workers in parallel
357
+ - Wait for depth/batch completion
358
+ - Aggregate results
359
+ - Verification check (documentation files created/updated)
360
+ - Display summary + recent changes
361
+
362
+ ## Comparison with Full Documentation Generation
363
+
364
+ | Aspect | Related Generation | Full Generation |
365
+ |--------|-------------------|-----------------|
366
+ | **Scope** | Changed modules only | All project modules |
367
+ | **Speed** | Fast (minutes) | Slower (10-30 min) |
368
+ | **Use case** | Daily development | Initial setup, major refactoring |
369
+ | **Strategy** | `single` (all) | `full` (L3) + `single` (L1-2) |
370
+ | **Trigger** | After commits | After setup or major changes |
371
+ | **Batching** | 4 modules/agent | 4 modules/agent |
372
+ | **Fallback** | gemini→qwen→codex | gemini→qwen→codex |
373
+ | **Complexity threshold** | ≤15 modules | ≤20 modules |
374
+
375
+ ## Template Reference
376
+
377
+ Templates used from `~/.claude/workflows/cli-templates/prompts/documentation/`:
378
+ - `api.txt`: Code API documentation
379
+ - `module-readme.txt`: Module purpose, usage, dependencies
380
+ - `folder-navigation.txt`: Navigation README for folders
381
+
382
+ ## Related Commands
383
+
384
+ - `/memory:docs-full-cli` - Full project documentation generation
385
+ - `/memory:docs` - Agent-based documentation planning workflow
386
+ - `/memory:update-related` - Update CLAUDE.md for changed modules