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,332 +1,332 @@
1
- ---
2
- name: update-full
3
- description: Update all CLAUDE.md files using layer-based execution (Layer 3→1) with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <20 modules uses direct parallel
4
- argument-hint: "[--tool gemini|qwen|codex] [--path <directory>]"
5
- ---
6
-
7
- # Full Documentation Update (/memory:update-full)
8
-
9
- ## Overview
10
-
11
- Orchestrates project-wide CLAUDE.md updates using batched agent execution with automatic tool fallback and 3-layer architecture support.
12
-
13
- **Parameters**:
14
- - `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
15
- - `--path <directory>`: Target specific directory (default: entire project)
16
-
17
- **Execution Flow**: Discovery → Plan Presentation → Execution → Safety Verification
18
-
19
- ## 3-Layer Architecture & Auto-Strategy Selection
20
-
21
- ### Layer Definition & Strategy Assignment
22
-
23
- | Layer | Depth | Strategy | Purpose | Context Pattern |
24
- |-------|-------|----------|---------|----------------|
25
- | **Layer 3** (Deepest) | ≥3 | `multi-layer` | Handle unstructured files, generate docs for all subdirectories | `@**/*` (all files) |
26
- | **Layer 2** (Middle) | 1-2 | `single-layer` | Aggregate from children + current code | `@*/CLAUDE.md @*.{ts,tsx,js,...}` |
27
- | **Layer 1** (Top) | 0 | `single-layer` | Aggregate from children + current code | `@*/CLAUDE.md @*.{ts,tsx,js,...}` |
28
-
29
- **Update Direction**: Layer 3 → Layer 2 → Layer 1 (bottom-up dependency flow)
30
-
31
- **Strategy Auto-Selection**: Strategies are automatically determined by directory depth - no user configuration needed.
32
-
33
- ### Strategy Details
34
-
35
- #### Multi-Layer Strategy (Layer 3 Only)
36
- - **Use Case**: Deepest directories with unstructured file layouts
37
- - **Behavior**: Generates CLAUDE.md for current directory AND each subdirectory containing files
38
- - **Context**: All files in current directory tree (`@**/*`)
39
-
40
-
41
- #### Single-Layer Strategy (Layers 1-2)
42
- - **Use Case**: Upper layers that aggregate from existing documentation
43
- - **Behavior**: Generates CLAUDE.md only for current directory
44
- - **Context**: Direct children CLAUDE.md files + current directory code files
45
-
46
- ### Example Flow
47
- ```
48
- src/auth/handlers/ (depth 3) → MULTI-LAYER STRATEGY
49
- CONTEXT: @**/* (all files in handlers/ and subdirs)
50
- GENERATES: ./CLAUDE.md + CLAUDE.md in each subdir with files
51
-
52
- src/auth/ (depth 2) → SINGLE-LAYER STRATEGY
53
- CONTEXT: @*/CLAUDE.md @*.ts (handlers/CLAUDE.md + current code)
54
- GENERATES: ./CLAUDE.md only
55
-
56
- src/ (depth 1) → SINGLE-LAYER STRATEGY
57
- CONTEXT: @*/CLAUDE.md (auth/CLAUDE.md, utils/CLAUDE.md)
58
- GENERATES: ./CLAUDE.md only
59
-
60
- ./ (depth 0) → SINGLE-LAYER STRATEGY
61
- CONTEXT: @*/CLAUDE.md (src/CLAUDE.md, tests/CLAUDE.md)
62
- GENERATES: ./CLAUDE.md only
63
- ```
64
-
65
- ## Core Execution Rules
66
-
67
- 1. **Analyze First**: Git cache + module discovery before updates
68
- 2. **Wait for Approval**: Present plan, no execution without user confirmation
69
- 3. **Execution Strategy**:
70
- - **<20 modules**: Direct parallel execution (max 4 concurrent per layer)
71
- - **≥20 modules**: Agent batch processing (4 modules/agent, 73% overhead reduction)
72
- 4. **Tool Fallback**: Auto-retry with fallback tools on failure
73
- 5. **Layer Sequential**: Process layers 3→2→1 (bottom-up), parallel batches within layer
74
- 6. **Safety Check**: Verify only CLAUDE.md files modified
75
- 7. **Layer-based Grouping**: Group modules by LAYER (not depth) for execution
76
-
77
- ## Tool Fallback Hierarchy
78
-
79
- ```javascript
80
- --tool gemini → [gemini, qwen, codex] // default
81
- --tool qwen → [qwen, gemini, codex]
82
- --tool codex → [codex, gemini, qwen]
83
- ```
84
-
85
- **Trigger**: Non-zero exit code from update script
86
-
87
- | Tool | Best For | Fallback To |
88
- |--------|--------------------------------|----------------|
89
- | gemini | Documentation, patterns | qwen → codex |
90
- | qwen | Architecture, system design | gemini → codex |
91
- | codex | Implementation, code quality | gemini → qwen |
92
-
93
- ## Execution Phases
94
-
95
- ### Phase 1: Discovery & Analysis
96
-
97
- ```javascript
98
- // Cache git changes
99
- Bash({command: "git add -A 2>/dev/null || true", run_in_background: false});
100
-
101
- // Get module structure
102
- Bash({command: "~/.claude/scripts/get_modules_by_depth.sh list", run_in_background: false});
103
-
104
- // OR with --path
105
- Bash({command: "cd <target-path> && ~/.claude/scripts/get_modules_by_depth.sh list", run_in_background: false});
106
- ```
107
-
108
- **Parse output** `depth:N|path:<PATH>|...` to extract module paths and count.
109
-
110
- **Smart filter**: Auto-detect and skip tests/build/config/docs based on project tech stack.
111
-
112
- ### Phase 2: Plan Presentation
113
-
114
- **For <20 modules**:
115
- ```
116
- Update Plan:
117
- Tool: gemini (fallback: qwen → codex)
118
- Total: 7 modules
119
- Execution: Direct parallel (< 20 modules threshold)
120
-
121
- Will update:
122
- - ./core/interfaces (12 files) - depth 2 [Layer 2] - single-layer strategy
123
- - ./core (22 files) - depth 1 [Layer 2] - single-layer strategy
124
- - ./models (9 files) - depth 1 [Layer 2] - single-layer strategy
125
- - ./utils (12 files) - depth 1 [Layer 2] - single-layer strategy
126
- - . (5 files) - depth 0 [Layer 1] - single-layer strategy
127
-
128
- Context Strategy (Auto-Selected):
129
- - Layer 2 (depth 1-2): @*/CLAUDE.md + current code files
130
- - Layer 1 (depth 0): @*/CLAUDE.md + current code files
131
-
132
- Auto-skipped: ./tests, __pycache__, setup.py (15 paths)
133
- Execution order: Layer 2 → Layer 1
134
- Estimated time: ~5-10 minutes
135
-
136
- Confirm execution? (y/n)
137
- ```
138
-
139
- **For ≥20 modules**:
140
- ```
141
- Update Plan:
142
- Tool: gemini (fallback: qwen → codex)
143
- Total: 31 modules
144
- Execution: Agent batch processing (4 modules/agent)
145
-
146
- Will update:
147
- - ./src/features/auth (12 files) - depth 3 [Layer 3] - multi-layer strategy
148
- - ./.claude/commands/cli (6 files) - depth 3 [Layer 3] - multi-layer strategy
149
- - ./src/utils (8 files) - depth 2 [Layer 2] - single-layer strategy
150
- ...
151
-
152
- Context Strategy (Auto-Selected):
153
- - Layer 3 (depth ≥3): @**/* (all files)
154
- - Layer 2 (depth 1-2): @*/CLAUDE.md + current code files
155
- - Layer 1 (depth 0): @*/CLAUDE.md + current code files
156
-
157
- Auto-skipped: ./tests, __pycache__, setup.py (15 paths)
158
- Execution order: Layer 2 → Layer 1
159
- Estimated time: ~5-10 minutes
160
-
161
- Agent allocation (by LAYER):
162
- - Layer 3 (14 modules, depth ≥3): 4 agents [4, 4, 4, 2]
163
- - Layer 2 (15 modules, depth 1-2): 4 agents [4, 4, 4, 3]
164
- - Layer 1 (2 modules, depth 0): 1 agent [2]
165
-
166
- Estimated time: ~15-25 minutes
167
-
168
- Confirm execution? (y/n)
169
- ```
170
-
171
- ### Phase 3A: Direct Execution (<20 modules)
172
-
173
- **Strategy**: Parallel execution within layer (max 4 concurrent), no agent overhead.
174
-
175
- **CRITICAL**: All Bash commands use `run_in_background: false` for synchronous execution.
176
-
177
- ```javascript
178
- for (let layer of [3, 2, 1]) {
179
- if (modules_by_layer[layer].length === 0) continue;
180
- let batches = batch_modules(modules_by_layer[layer], 4);
181
-
182
- for (let batch of batches) {
183
- let parallel_tasks = batch.map(module => {
184
- return async () => {
185
- let strategy = module.depth >= 3 ? "multi-layer" : "single-layer";
186
- for (let tool of tool_order) {
187
- Bash({
188
- command: `cd ${module.path} && ~/.claude/scripts/update_module_claude.sh "${strategy}" "." "${tool}"`,
189
- run_in_background: false
190
- });
191
- if (bash_result.exit_code === 0) {
192
- report(`✅ ${module.path} (Layer ${layer}) updated with ${tool}`);
193
- return true;
194
- }
195
- }
196
- report(`❌ FAILED: ${module.path} (Layer ${layer}) failed all tools`);
197
- return false;
198
- };
199
- });
200
- await Promise.all(parallel_tasks.map(task => task()));
201
- }
202
- }
203
- ```
204
-
205
- ### Phase 3B: Agent Batch Execution (≥20 modules)
206
-
207
- **Strategy**: Batch modules into groups of 4, spawn memory-bridge agents per batch.
208
-
209
- ```javascript
210
- // Group modules by LAYER and batch within each layer
211
- let modules_by_layer = group_by_layer(module_list);
212
- let tool_order = construct_tool_order(primary_tool);
213
-
214
- for (let layer of [3, 2, 1]) {
215
- if (modules_by_layer[layer].length === 0) continue;
216
-
217
- let batches = batch_modules(modules_by_layer[layer], 4);
218
- let worker_tasks = [];
219
-
220
- for (let batch of batches) {
221
- worker_tasks.push(
222
- Task(
223
- subagent_type="memory-bridge",
224
- description=`Update ${batch.length} modules in Layer ${layer}`,
225
- prompt=generate_batch_worker_prompt(batch, tool_order, layer)
226
- )
227
- );
228
- }
229
-
230
- await parallel_execute(worker_tasks);
231
- }
232
- ```
233
-
234
- **Batch Worker Prompt Template**:
235
- ```
236
- PURPOSE: Update CLAUDE.md for assigned modules with tool fallback
237
-
238
- TASK: Update documentation for assigned modules using specified strategies.
239
-
240
- MODULES:
241
- {{module_path_1}} (strategy: {{strategy_1}})
242
- {{module_path_2}} (strategy: {{strategy_2}})
243
- ...
244
-
245
- TOOLS (try in order): {{tool_1}}, {{tool_2}}, {{tool_3}}
246
-
247
- EXECUTION SCRIPT: ~/.claude/scripts/update_module_claude.sh
248
- - Accepts strategy parameter: multi-layer | single-layer
249
- - Tool execution via direct CLI commands (gemini/qwen/codex)
250
-
251
- EXECUTION FLOW (for each module):
252
- 1. Tool fallback loop (exit on first success):
253
- for tool in {{tool_1}} {{tool_2}} {{tool_3}}; do
254
- Bash({
255
- command: `cd "{{module_path}}" && ~/.claude/scripts/update_module_claude.sh "{{strategy}}" "." "${tool}"`,
256
- run_in_background: false
257
- })
258
- exit_code=$?
259
-
260
- if [ $exit_code -eq 0 ]; then
261
- report "✅ {{module_path}} updated with $tool"
262
- break
263
- else
264
- report "⚠️ {{module_path}} failed with $tool, trying next..."
265
- continue
266
- fi
267
- done
268
-
269
- 2. Handle complete failure (all tools failed):
270
- if [ $exit_code -ne 0 ]; then
271
- report "❌ FAILED: {{module_path}} - all tools exhausted"
272
- # Continue to next module (do not abort batch)
273
- fi
274
-
275
- FAILURE HANDLING:
276
- - Module-level isolation: One module's failure does not affect others
277
- - Exit code detection: Non-zero exit code triggers next tool
278
- - Exhaustion reporting: Log modules where all tools failed
279
- - Batch continuation: Always process remaining modules
280
-
281
- REPORTING FORMAT:
282
- Per-module status:
283
- ✅ path/to/module updated with {tool}
284
- ⚠️ path/to/module failed with {tool}, trying next...
285
- ❌ FAILED: path/to/module - all tools exhausted
286
- ```
287
- ### Phase 4: Safety Verification
288
-
289
- ```javascript
290
- // Check only CLAUDE.md files modified
291
- Bash({command: 'git diff --cached --name-only | grep -v "CLAUDE.md" || echo "Only CLAUDE.md files modified"', run_in_background: false});
292
-
293
- // Display status
294
- Bash({command: "git status --short", run_in_background: false});
295
- ```
296
-
297
- **Result Summary**:
298
- ```
299
- Update Summary:
300
- Total: 31 | Success: 29 | Failed: 2
301
- Tool usage: gemini: 25, qwen: 4, codex: 0
302
- Failed: path1, path2
303
- ```
304
-
305
- ## Error Handling
306
-
307
- **Batch Worker**: Tool fallback per module, batch isolation, clear status reporting
308
- **Coordinator**: Invalid path abort, user decline handling, safety check with auto-revert
309
- **Fallback Triggers**: Non-zero exit code, script timeout, unexpected output
310
-
311
- ## Usage Examples
312
-
313
- ```bash
314
- # Full project update (auto-strategy selection)
315
- /memory:update-full
316
-
317
- # Target specific directory
318
- /memory:update-full --path .claude
319
- /memory:update-full --path src/features/auth
320
-
321
- # Use specific tool
322
- /memory:update-full --tool qwen
323
- /memory:update-full --path .claude --tool qwen
324
- ```
325
-
326
- ## Key Advantages
327
-
328
- - **Efficiency**: 30 modules → 8 agents (73% reduction from sequential)
329
- - **Resilience**: 3-tier tool fallback per module
330
- - **Performance**: Parallel batches, no concurrency limits
331
- - **Observability**: Per-module tool usage, batch-level metrics
332
- - **Automation**: Zero configuration - strategy auto-selected by directory depth
1
+ ---
2
+ name: update-full
3
+ description: Update all CLAUDE.md files using layer-based execution (Layer 3→1) with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <20 modules uses direct parallel
4
+ argument-hint: "[--tool gemini|qwen|codex] [--path <directory>]"
5
+ ---
6
+
7
+ # Full Documentation Update (/memory:update-full)
8
+
9
+ ## Overview
10
+
11
+ Orchestrates project-wide CLAUDE.md updates using batched agent execution with automatic tool fallback and 3-layer architecture support.
12
+
13
+ **Parameters**:
14
+ - `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
15
+ - `--path <directory>`: Target specific directory (default: entire project)
16
+
17
+ **Execution Flow**: Discovery → Plan Presentation → Execution → Safety Verification
18
+
19
+ ## 3-Layer Architecture & Auto-Strategy Selection
20
+
21
+ ### Layer Definition & Strategy Assignment
22
+
23
+ | Layer | Depth | Strategy | Purpose | Context Pattern |
24
+ |-------|-------|----------|---------|----------------|
25
+ | **Layer 3** (Deepest) | ≥3 | `multi-layer` | Handle unstructured files, generate docs for all subdirectories | `@**/*` (all files) |
26
+ | **Layer 2** (Middle) | 1-2 | `single-layer` | Aggregate from children + current code | `@*/CLAUDE.md @*.{ts,tsx,js,...}` |
27
+ | **Layer 1** (Top) | 0 | `single-layer` | Aggregate from children + current code | `@*/CLAUDE.md @*.{ts,tsx,js,...}` |
28
+
29
+ **Update Direction**: Layer 3 → Layer 2 → Layer 1 (bottom-up dependency flow)
30
+
31
+ **Strategy Auto-Selection**: Strategies are automatically determined by directory depth - no user configuration needed.
32
+
33
+ ### Strategy Details
34
+
35
+ #### Multi-Layer Strategy (Layer 3 Only)
36
+ - **Use Case**: Deepest directories with unstructured file layouts
37
+ - **Behavior**: Generates CLAUDE.md for current directory AND each subdirectory containing files
38
+ - **Context**: All files in current directory tree (`@**/*`)
39
+
40
+
41
+ #### Single-Layer Strategy (Layers 1-2)
42
+ - **Use Case**: Upper layers that aggregate from existing documentation
43
+ - **Behavior**: Generates CLAUDE.md only for current directory
44
+ - **Context**: Direct children CLAUDE.md files + current directory code files
45
+
46
+ ### Example Flow
47
+ ```
48
+ src/auth/handlers/ (depth 3) → MULTI-LAYER STRATEGY
49
+ CONTEXT: @**/* (all files in handlers/ and subdirs)
50
+ GENERATES: ./CLAUDE.md + CLAUDE.md in each subdir with files
51
+
52
+ src/auth/ (depth 2) → SINGLE-LAYER STRATEGY
53
+ CONTEXT: @*/CLAUDE.md @*.ts (handlers/CLAUDE.md + current code)
54
+ GENERATES: ./CLAUDE.md only
55
+
56
+ src/ (depth 1) → SINGLE-LAYER STRATEGY
57
+ CONTEXT: @*/CLAUDE.md (auth/CLAUDE.md, utils/CLAUDE.md)
58
+ GENERATES: ./CLAUDE.md only
59
+
60
+ ./ (depth 0) → SINGLE-LAYER STRATEGY
61
+ CONTEXT: @*/CLAUDE.md (src/CLAUDE.md, tests/CLAUDE.md)
62
+ GENERATES: ./CLAUDE.md only
63
+ ```
64
+
65
+ ## Core Execution Rules
66
+
67
+ 1. **Analyze First**: Git cache + module discovery before updates
68
+ 2. **Wait for Approval**: Present plan, no execution without user confirmation
69
+ 3. **Execution Strategy**:
70
+ - **<20 modules**: Direct parallel execution (max 4 concurrent per layer)
71
+ - **≥20 modules**: Agent batch processing (4 modules/agent, 73% overhead reduction)
72
+ 4. **Tool Fallback**: Auto-retry with fallback tools on failure
73
+ 5. **Layer Sequential**: Process layers 3→2→1 (bottom-up), parallel batches within layer
74
+ 6. **Safety Check**: Verify only CLAUDE.md files modified
75
+ 7. **Layer-based Grouping**: Group modules by LAYER (not depth) for execution
76
+
77
+ ## Tool Fallback Hierarchy
78
+
79
+ ```javascript
80
+ --tool gemini → [gemini, qwen, codex] // default
81
+ --tool qwen → [qwen, gemini, codex]
82
+ --tool codex → [codex, gemini, qwen]
83
+ ```
84
+
85
+ **Trigger**: Non-zero exit code from update script
86
+
87
+ | Tool | Best For | Fallback To |
88
+ |--------|--------------------------------|----------------|
89
+ | gemini | Documentation, patterns | qwen → codex |
90
+ | qwen | Architecture, system design | gemini → codex |
91
+ | codex | Implementation, code quality | gemini → qwen |
92
+
93
+ ## Execution Phases
94
+
95
+ ### Phase 1: Discovery & Analysis
96
+
97
+ ```javascript
98
+ // Cache git changes
99
+ Bash({command: "git add -A 2>/dev/null || true", run_in_background: false});
100
+
101
+ // Get module structure
102
+ Bash({command: "ccw tool exec get_modules_by_depth '{\"format\":\"list\"}'", run_in_background: false});
103
+
104
+ // OR with --path
105
+ Bash({command: "cd <target-path> && ccw tool exec get_modules_by_depth '{\"format\":\"list\"}'", run_in_background: false});
106
+ ```
107
+
108
+ **Parse output** `depth:N|path:<PATH>|...` to extract module paths and count.
109
+
110
+ **Smart filter**: Auto-detect and skip tests/build/config/docs based on project tech stack.
111
+
112
+ ### Phase 2: Plan Presentation
113
+
114
+ **For <20 modules**:
115
+ ```
116
+ Update Plan:
117
+ Tool: gemini (fallback: qwen → codex)
118
+ Total: 7 modules
119
+ Execution: Direct parallel (< 20 modules threshold)
120
+
121
+ Will update:
122
+ - ./core/interfaces (12 files) - depth 2 [Layer 2] - single-layer strategy
123
+ - ./core (22 files) - depth 1 [Layer 2] - single-layer strategy
124
+ - ./models (9 files) - depth 1 [Layer 2] - single-layer strategy
125
+ - ./utils (12 files) - depth 1 [Layer 2] - single-layer strategy
126
+ - . (5 files) - depth 0 [Layer 1] - single-layer strategy
127
+
128
+ Context Strategy (Auto-Selected):
129
+ - Layer 2 (depth 1-2): @*/CLAUDE.md + current code files
130
+ - Layer 1 (depth 0): @*/CLAUDE.md + current code files
131
+
132
+ Auto-skipped: ./tests, __pycache__, setup.py (15 paths)
133
+ Execution order: Layer 2 → Layer 1
134
+ Estimated time: ~5-10 minutes
135
+
136
+ Confirm execution? (y/n)
137
+ ```
138
+
139
+ **For ≥20 modules**:
140
+ ```
141
+ Update Plan:
142
+ Tool: gemini (fallback: qwen → codex)
143
+ Total: 31 modules
144
+ Execution: Agent batch processing (4 modules/agent)
145
+
146
+ Will update:
147
+ - ./src/features/auth (12 files) - depth 3 [Layer 3] - multi-layer strategy
148
+ - ./.claude/commands/cli (6 files) - depth 3 [Layer 3] - multi-layer strategy
149
+ - ./src/utils (8 files) - depth 2 [Layer 2] - single-layer strategy
150
+ ...
151
+
152
+ Context Strategy (Auto-Selected):
153
+ - Layer 3 (depth ≥3): @**/* (all files)
154
+ - Layer 2 (depth 1-2): @*/CLAUDE.md + current code files
155
+ - Layer 1 (depth 0): @*/CLAUDE.md + current code files
156
+
157
+ Auto-skipped: ./tests, __pycache__, setup.py (15 paths)
158
+ Execution order: Layer 2 → Layer 1
159
+ Estimated time: ~5-10 minutes
160
+
161
+ Agent allocation (by LAYER):
162
+ - Layer 3 (14 modules, depth ≥3): 4 agents [4, 4, 4, 2]
163
+ - Layer 2 (15 modules, depth 1-2): 4 agents [4, 4, 4, 3]
164
+ - Layer 1 (2 modules, depth 0): 1 agent [2]
165
+
166
+ Estimated time: ~15-25 minutes
167
+
168
+ Confirm execution? (y/n)
169
+ ```
170
+
171
+ ### Phase 3A: Direct Execution (<20 modules)
172
+
173
+ **Strategy**: Parallel execution within layer (max 4 concurrent), no agent overhead.
174
+
175
+ **CRITICAL**: All Bash commands use `run_in_background: false` for synchronous execution.
176
+
177
+ ```javascript
178
+ for (let layer of [3, 2, 1]) {
179
+ if (modules_by_layer[layer].length === 0) continue;
180
+ let batches = batch_modules(modules_by_layer[layer], 4);
181
+
182
+ for (let batch of batches) {
183
+ let parallel_tasks = batch.map(module => {
184
+ return async () => {
185
+ let strategy = module.depth >= 3 ? "multi-layer" : "single-layer";
186
+ for (let tool of tool_order) {
187
+ Bash({
188
+ command: `cd ${module.path} && ccw tool exec update_module_claude '{"strategy":"${strategy}","path":".","tool":"${tool}"}'`,
189
+ run_in_background: false
190
+ });
191
+ if (bash_result.exit_code === 0) {
192
+ report(`✅ ${module.path} (Layer ${layer}) updated with ${tool}`);
193
+ return true;
194
+ }
195
+ }
196
+ report(`❌ FAILED: ${module.path} (Layer ${layer}) failed all tools`);
197
+ return false;
198
+ };
199
+ });
200
+ await Promise.all(parallel_tasks.map(task => task()));
201
+ }
202
+ }
203
+ ```
204
+
205
+ ### Phase 3B: Agent Batch Execution (≥20 modules)
206
+
207
+ **Strategy**: Batch modules into groups of 4, spawn memory-bridge agents per batch.
208
+
209
+ ```javascript
210
+ // Group modules by LAYER and batch within each layer
211
+ let modules_by_layer = group_by_layer(module_list);
212
+ let tool_order = construct_tool_order(primary_tool);
213
+
214
+ for (let layer of [3, 2, 1]) {
215
+ if (modules_by_layer[layer].length === 0) continue;
216
+
217
+ let batches = batch_modules(modules_by_layer[layer], 4);
218
+ let worker_tasks = [];
219
+
220
+ for (let batch of batches) {
221
+ worker_tasks.push(
222
+ Task(
223
+ subagent_type="memory-bridge",
224
+ description=`Update ${batch.length} modules in Layer ${layer}`,
225
+ prompt=generate_batch_worker_prompt(batch, tool_order, layer)
226
+ )
227
+ );
228
+ }
229
+
230
+ await parallel_execute(worker_tasks);
231
+ }
232
+ ```
233
+
234
+ **Batch Worker Prompt Template**:
235
+ ```
236
+ PURPOSE: Update CLAUDE.md for assigned modules with tool fallback
237
+
238
+ TASK: Update documentation for assigned modules using specified strategies.
239
+
240
+ MODULES:
241
+ {{module_path_1}} (strategy: {{strategy_1}})
242
+ {{module_path_2}} (strategy: {{strategy_2}})
243
+ ...
244
+
245
+ TOOLS (try in order): {{tool_1}}, {{tool_2}}, {{tool_3}}
246
+
247
+ EXECUTION SCRIPT: ccw tool exec update_module_claude
248
+ - Accepts strategy parameter: multi-layer | single-layer
249
+ - Tool execution via direct CLI commands (gemini/qwen/codex)
250
+
251
+ EXECUTION FLOW (for each module):
252
+ 1. Tool fallback loop (exit on first success):
253
+ for tool in {{tool_1}} {{tool_2}} {{tool_3}}; do
254
+ Bash({
255
+ command: `cd "{{module_path}}" && ccw tool exec update_module_claude '{"strategy":"{{strategy}}","path":".","tool":"${tool}"}'`,
256
+ run_in_background: false
257
+ })
258
+ exit_code=$?
259
+
260
+ if [ $exit_code -eq 0 ]; then
261
+ report "✅ {{module_path}} updated with $tool"
262
+ break
263
+ else
264
+ report "⚠️ {{module_path}} failed with $tool, trying next..."
265
+ continue
266
+ fi
267
+ done
268
+
269
+ 2. Handle complete failure (all tools failed):
270
+ if [ $exit_code -ne 0 ]; then
271
+ report "❌ FAILED: {{module_path}} - all tools exhausted"
272
+ # Continue to next module (do not abort batch)
273
+ fi
274
+
275
+ FAILURE HANDLING:
276
+ - Module-level isolation: One module's failure does not affect others
277
+ - Exit code detection: Non-zero exit code triggers next tool
278
+ - Exhaustion reporting: Log modules where all tools failed
279
+ - Batch continuation: Always process remaining modules
280
+
281
+ REPORTING FORMAT:
282
+ Per-module status:
283
+ ✅ path/to/module updated with {tool}
284
+ ⚠️ path/to/module failed with {tool}, trying next...
285
+ ❌ FAILED: path/to/module - all tools exhausted
286
+ ```
287
+ ### Phase 4: Safety Verification
288
+
289
+ ```javascript
290
+ // Check only CLAUDE.md files modified
291
+ Bash({command: 'git diff --cached --name-only | grep -v "CLAUDE.md" || echo "Only CLAUDE.md files modified"', run_in_background: false});
292
+
293
+ // Display status
294
+ Bash({command: "git status --short", run_in_background: false});
295
+ ```
296
+
297
+ **Result Summary**:
298
+ ```
299
+ Update Summary:
300
+ Total: 31 | Success: 29 | Failed: 2
301
+ Tool usage: gemini: 25, qwen: 4, codex: 0
302
+ Failed: path1, path2
303
+ ```
304
+
305
+ ## Error Handling
306
+
307
+ **Batch Worker**: Tool fallback per module, batch isolation, clear status reporting
308
+ **Coordinator**: Invalid path abort, user decline handling, safety check with auto-revert
309
+ **Fallback Triggers**: Non-zero exit code, script timeout, unexpected output
310
+
311
+ ## Usage Examples
312
+
313
+ ```bash
314
+ # Full project update (auto-strategy selection)
315
+ /memory:update-full
316
+
317
+ # Target specific directory
318
+ /memory:update-full --path .claude
319
+ /memory:update-full --path src/features/auth
320
+
321
+ # Use specific tool
322
+ /memory:update-full --tool qwen
323
+ /memory:update-full --path .claude --tool qwen
324
+ ```
325
+
326
+ ## Key Advantages
327
+
328
+ - **Efficiency**: 30 modules → 8 agents (73% reduction from sequential)
329
+ - **Resilience**: 3-tier tool fallback per module
330
+ - **Performance**: Parallel batches, no concurrency limits
331
+ - **Observability**: Per-module tool usage, batch-level metrics
332
+ - **Automation**: Zero configuration - strategy auto-selected by directory depth