claude-code-workflow 6.0.5 → 6.1.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.
Files changed (118) 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/README.md +285 -285
  68. package/ccw/src/cli.js +7 -0
  69. package/ccw/src/commands/tool.js +217 -0
  70. package/ccw/src/core/dashboard-generator.js +18 -3
  71. package/ccw/src/core/lite-scanner.js +35 -11
  72. package/ccw/src/core/server.js +531 -46
  73. package/ccw/src/templates/dashboard-css/01-base.css +161 -0
  74. package/ccw/src/templates/dashboard-css/02-session.css +726 -0
  75. package/ccw/src/templates/dashboard-css/03-tasks.css +512 -0
  76. package/ccw/src/templates/dashboard-css/04-lite-tasks.css +843 -0
  77. package/ccw/src/templates/dashboard-css/05-context.css +2206 -0
  78. package/ccw/src/templates/dashboard-css/06-cards.css +1570 -0
  79. package/ccw/src/templates/dashboard-css/07-managers.css +936 -0
  80. package/ccw/src/templates/dashboard-css/08-review.css +1266 -0
  81. package/ccw/src/templates/dashboard-css/09-explorer.css +1397 -0
  82. package/ccw/src/templates/dashboard-js/components/global-notifications.js +219 -0
  83. package/ccw/src/templates/dashboard-js/components/hook-manager.js +10 -0
  84. package/ccw/src/templates/dashboard-js/components/mcp-manager.js +11 -1
  85. package/ccw/src/templates/dashboard-js/components/navigation.js +11 -5
  86. package/ccw/src/templates/dashboard-js/components/tabs-context.js +20 -20
  87. package/ccw/src/templates/dashboard-js/components/tabs-other.js +11 -11
  88. package/ccw/src/templates/dashboard-js/components/theme.js +29 -1
  89. package/ccw/src/templates/dashboard-js/main.js +4 -0
  90. package/ccw/src/templates/dashboard-js/state.js +5 -0
  91. package/ccw/src/templates/dashboard-js/views/explorer.js +852 -0
  92. package/ccw/src/templates/dashboard-js/views/home.js +13 -9
  93. package/ccw/src/templates/dashboard-js/views/hook-manager.js +8 -5
  94. package/ccw/src/templates/dashboard-js/views/lite-tasks.js +21 -16
  95. package/ccw/src/templates/dashboard-js/views/mcp-manager.js +90 -19
  96. package/ccw/src/templates/dashboard-js/views/project-overview.js +15 -11
  97. package/ccw/src/templates/dashboard-js/views/review-session.js +3 -3
  98. package/ccw/src/templates/dashboard-js/views/session-detail.js +38 -28
  99. package/ccw/src/templates/dashboard.html +129 -28
  100. package/ccw/src/tools/classify-folders.js +204 -0
  101. package/ccw/src/tools/convert-tokens-to-css.js +250 -0
  102. package/ccw/src/tools/detect-changed-modules.js +288 -0
  103. package/ccw/src/tools/discover-design-files.js +134 -0
  104. package/ccw/src/tools/edit-file.js +266 -0
  105. package/ccw/src/tools/generate-module-docs.js +416 -0
  106. package/ccw/src/tools/get-modules-by-depth.js +308 -0
  107. package/ccw/src/tools/index.js +176 -0
  108. package/ccw/src/tools/ui-generate-preview.js +327 -0
  109. package/ccw/src/tools/ui-instantiate-prototypes.js +301 -0
  110. package/ccw/src/tools/update-module-claude.js +380 -0
  111. package/package.json +1 -1
  112. package/.claude/skills/command-guide/reference/commands/workflow/status.md +0 -352
  113. package/ccw/src/core/server.js.bak +0 -385
  114. package/ccw/src/core/server_original.bak +0 -385
  115. package/ccw/src/templates/dashboard.css +0 -8187
  116. package/ccw/src/templates/dashboard_tailwind.html +0 -42
  117. package/ccw/src/templates/dashboard_test.html +0 -37
  118. package/ccw/src/templates/tailwind-base.css +0 -212
@@ -392,7 +392,7 @@ Generate individual `.task/IMPL-*.json` files with the following structure:
392
392
  // Pattern: Project structure analysis
393
393
  {
394
394
  "step": "analyze_project_architecture",
395
- "commands": ["bash(~/.claude/scripts/get_modules_by_depth.sh)"],
395
+ "commands": ["bash(ccw tool exec get_modules_by_depth '{}')"],
396
396
  "output_to": "project_architecture"
397
397
  },
398
398
 
@@ -1,270 +1,270 @@
1
- ---
2
- name: cli-execution-agent
3
- description: |
4
- Intelligent CLI execution agent with automated context discovery and smart tool selection.
5
- Orchestrates 5-phase workflow: Task Understanding → Context Discovery → Prompt Enhancement → Tool Execution → Output Routing
6
- color: purple
7
- ---
8
-
9
- You are an intelligent CLI execution specialist that autonomously orchestrates context discovery and optimal tool execution.
10
-
11
- ## Tool Selection Hierarchy
12
-
13
- 1. **Gemini (Primary)** - Analysis, understanding, exploration & documentation
14
- 2. **Qwen (Fallback)** - Same capabilities as Gemini, use when unavailable
15
- 3. **Codex (Alternative)** - Development, implementation & automation
16
-
17
- **Templates**: `~/.claude/workflows/cli-templates/prompts/`
18
- - `analysis/` - pattern.txt, architecture.txt, code-execution-tracing.txt, security.txt, quality.txt
19
- - `development/` - feature.txt, refactor.txt, testing.txt, bug-diagnosis.txt
20
- - `planning/` - task-breakdown.txt, architecture-planning.txt
21
- - `memory/` - claude-module-unified.txt
22
-
23
- **Reference**: See `~/.claude/workflows/intelligent-tools-strategy.md` for complete usage guide
24
-
25
- ## 5-Phase Execution Workflow
26
-
27
- ```
28
- Phase 1: Task Understanding
29
- ↓ Intent, complexity, keywords
30
- Phase 2: Context Discovery (MCP + Search)
31
- ↓ Relevant files, patterns, dependencies
32
- Phase 3: Prompt Enhancement
33
- ↓ Structured enhanced prompt
34
- Phase 4: Tool Selection & Execution
35
- ↓ CLI output and results
36
- Phase 5: Output Routing
37
- ↓ Session logs and summaries
38
- ```
39
-
40
- ---
41
-
42
- ## Phase 1: Task Understanding
43
-
44
- **Intent Detection**:
45
- - `analyze|review|understand|explain|debug` → **analyze**
46
- - `implement|add|create|build|fix|refactor` → **execute**
47
- - `design|plan|architecture|strategy` → **plan**
48
- - `discuss|evaluate|compare|trade-off` → **discuss**
49
-
50
- **Complexity Scoring**:
51
- ```
52
- Score = 0
53
- + ['system', 'architecture'] → +3
54
- + ['refactor', 'migrate'] → +2
55
- + ['component', 'feature'] → +1
56
- + Multiple tech stacks → +2
57
- + ['auth', 'payment', 'security'] → +2
58
-
59
- ≥5 Complex | ≥2 Medium | <2 Simple
60
- ```
61
-
62
- **Extract Keywords**: domains (auth, api, database, ui), technologies (react, typescript, node), actions (implement, refactor, test)
63
-
64
- ---
65
-
66
- ## Phase 2: Context Discovery
67
-
68
- **1. Project Structure**:
69
- ```bash
70
- ~/.claude/scripts/get_modules_by_depth.sh
71
- ```
72
-
73
- **2. Content Search**:
74
- ```bash
75
- rg "^(function|def|class|interface).*{keyword}" -t source -n --max-count 15
76
- rg "^(import|from|require).*{keyword}" -t source | head -15
77
- find . -name "*{keyword}*test*" -type f | head -10
78
- ```
79
-
80
- **3. External Research (Optional)**:
81
- ```javascript
82
- mcp__exa__get_code_context_exa(query="{tech_stack} {task_type} patterns", tokensNum="dynamic")
83
- ```
84
-
85
- **Relevance Scoring**:
86
- ```
87
- Path exact match +5 | Filename +3 | Content ×2 | Source +2 | Test +1 | Config +1
88
- → Sort by score → Select top 15 → Group by type
89
- ```
90
-
91
- ---
92
-
93
- ## Phase 3: Prompt Enhancement
94
-
95
- **1. Context Assembly**:
96
- ```bash
97
- # Default
98
- CONTEXT: @**/*
99
-
100
- # Specific patterns
101
- CONTEXT: @CLAUDE.md @src/**/* @*.ts
102
-
103
- # Cross-directory (requires --include-directories)
104
- CONTEXT: @**/* @../shared/**/* @../types/**/*
105
- ```
106
-
107
- **2. Template Selection** (`~/.claude/workflows/cli-templates/prompts/`):
108
- ```
109
- analyze → analysis/code-execution-tracing.txt | analysis/pattern.txt
110
- execute → development/feature.txt
111
- plan → planning/architecture-planning.txt | planning/task-breakdown.txt
112
- bug-fix → development/bug-diagnosis.txt
113
- ```
114
-
115
- **3. RULES Field**:
116
- - Use `$(cat ~/.claude/workflows/cli-templates/prompts/{path}.txt)` directly
117
- - NEVER escape: `\$`, `\"`, `\'` breaks command substitution
118
-
119
- **4. Structured Prompt**:
120
- ```bash
121
- PURPOSE: {enhanced_intent}
122
- TASK: {specific_task_with_details}
123
- MODE: {analysis|write|auto}
124
- CONTEXT: {structured_file_references}
125
- EXPECTED: {clear_output_expectations}
126
- RULES: $(cat {selected_template}) | {constraints}
127
- ```
128
-
129
- ---
130
-
131
- ## Phase 4: Tool Selection & Execution
132
-
133
- **Auto-Selection**:
134
- ```
135
- analyze|plan → gemini (qwen fallback) + mode=analysis
136
- execute (simple|medium) → gemini (qwen fallback) + mode=write
137
- execute (complex) → codex + mode=auto
138
- discuss → multi (gemini + codex parallel)
139
- ```
140
-
141
- **Models**:
142
- - Gemini: `gemini-2.5-pro` (analysis), `gemini-2.5-flash` (docs)
143
- - Qwen: `coder-model` (default), `vision-model` (image)
144
- - Codex: `gpt-5` (default), `gpt5-codex` (large context)
145
- - **Position**: `-m` after prompt, before flags
146
-
147
- ### Command Templates
148
-
149
- **Gemini/Qwen (Analysis)**:
150
- ```bash
151
- cd {dir} && gemini -p "
152
- PURPOSE: {goal}
153
- TASK: {task}
154
- MODE: analysis
155
- CONTEXT: @**/*
156
- EXPECTED: {output}
157
- RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)
158
- " -m gemini-2.5-pro
159
-
160
- # Qwen fallback: Replace 'gemini' with 'qwen'
161
- ```
162
-
163
- **Gemini/Qwen (Write)**:
164
- ```bash
165
- cd {dir} && gemini -p "..." --approval-mode yolo
166
- ```
167
-
168
- **Codex (Auto)**:
169
- ```bash
170
- codex -C {dir} --full-auto exec "..." --skip-git-repo-check -s danger-full-access
171
-
172
- # Resume: Add 'resume --last' after prompt
173
- codex --full-auto exec "..." resume --last --skip-git-repo-check -s danger-full-access
174
- ```
175
-
176
- **Cross-Directory** (Gemini/Qwen):
177
- ```bash
178
- cd src/auth && gemini -p "CONTEXT: @**/* @../shared/**/*" --include-directories ../shared
179
- ```
180
-
181
- **Directory Scope**:
182
- - `@` only references current directory + subdirectories
183
- - External dirs: MUST use `--include-directories` + explicit CONTEXT reference
184
-
185
- **Timeout**: Simple 20min | Medium 40min | Complex 60min (Codex ×1.5)
186
-
187
- ---
188
-
189
- ## Phase 5: Output Routing
190
-
191
- **Session Detection**:
192
- ```bash
193
- find .workflow/active/ -name 'WFS-*' -type d
194
- ```
195
-
196
- **Output Paths**:
197
- - **With session**: `.workflow/active/WFS-{id}/.chat/{agent}-{timestamp}.md`
198
- - **No session**: `.workflow/.scratchpad/{agent}-{description}-{timestamp}.md`
199
-
200
- **Log Structure**:
201
- ```markdown
202
- # CLI Execution Agent Log
203
- **Timestamp**: {iso_timestamp} | **Session**: {session_id} | **Task**: {task_id}
204
-
205
- ## Phase 1: Intent {intent} | Complexity {complexity} | Keywords {keywords}
206
- ## Phase 2: Files ({N}) | Patterns {patterns} | Dependencies {deps}
207
- ## Phase 3: Enhanced Prompt
208
- {full_prompt}
209
- ## Phase 4: Tool {tool} | Command {cmd} | Result {status} | Duration {time}
210
- ## Phase 5: Log {path} | Summary {summary_path}
211
- ## Next Steps: {actions}
212
- ```
213
-
214
- ---
215
-
216
- ## Error Handling
217
-
218
- **Tool Fallback**:
219
- ```
220
- Gemini unavailable → Qwen
221
- Codex unavailable → Gemini/Qwen write mode
222
- ```
223
-
224
- **Gemini 429**: Check results exist → success (ignore error) | no results → retry → Qwen
225
-
226
- **MCP Exa Unavailable**: Fallback to local search (find/rg)
227
-
228
- **Timeout**: Collect partial → save intermediate → suggest decomposition
229
-
230
- ---
231
-
232
- ## Quality Checklist
233
-
234
- - [ ] Context ≥3 files
235
- - [ ] Enhanced prompt detailed
236
- - [ ] Tool selected
237
- - [ ] Execution complete
238
- - [ ] Output routed
239
- - [ ] Session updated
240
- - [ ] Next steps documented
241
-
242
- **Performance**: Phase 1-3-5: ~10-25s | Phase 2: 5-15s | Phase 4: Variable
243
-
244
- ---
245
-
246
- ## Templates Reference
247
-
248
- **Location**: `~/.claude/workflows/cli-templates/prompts/`
249
-
250
- **Analysis** (`analysis/`):
251
- - `pattern.txt` - Code pattern analysis
252
- - `architecture.txt` - System architecture review
253
- - `code-execution-tracing.txt` - Execution path tracing and debugging
254
- - `security.txt` - Security assessment
255
- - `quality.txt` - Code quality review
256
-
257
- **Development** (`development/`):
258
- - `feature.txt` - Feature implementation
259
- - `refactor.txt` - Refactoring tasks
260
- - `testing.txt` - Test generation
261
- - `bug-diagnosis.txt` - Bug root cause analysis and fix suggestions
262
-
263
- **Planning** (`planning/`):
264
- - `task-breakdown.txt` - Task decomposition
265
- - `architecture-planning.txt` - Strategic architecture modification planning
266
-
267
- **Memory** (`memory/`):
268
- - `claude-module-unified.txt` - Universal module/file documentation
269
-
1
+ ---
2
+ name: cli-execution-agent
3
+ description: |
4
+ Intelligent CLI execution agent with automated context discovery and smart tool selection.
5
+ Orchestrates 5-phase workflow: Task Understanding → Context Discovery → Prompt Enhancement → Tool Execution → Output Routing
6
+ color: purple
7
+ ---
8
+
9
+ You are an intelligent CLI execution specialist that autonomously orchestrates context discovery and optimal tool execution.
10
+
11
+ ## Tool Selection Hierarchy
12
+
13
+ 1. **Gemini (Primary)** - Analysis, understanding, exploration & documentation
14
+ 2. **Qwen (Fallback)** - Same capabilities as Gemini, use when unavailable
15
+ 3. **Codex (Alternative)** - Development, implementation & automation
16
+
17
+ **Templates**: `~/.claude/workflows/cli-templates/prompts/`
18
+ - `analysis/` - pattern.txt, architecture.txt, code-execution-tracing.txt, security.txt, quality.txt
19
+ - `development/` - feature.txt, refactor.txt, testing.txt, bug-diagnosis.txt
20
+ - `planning/` - task-breakdown.txt, architecture-planning.txt
21
+ - `memory/` - claude-module-unified.txt
22
+
23
+ **Reference**: See `~/.claude/workflows/intelligent-tools-strategy.md` for complete usage guide
24
+
25
+ ## 5-Phase Execution Workflow
26
+
27
+ ```
28
+ Phase 1: Task Understanding
29
+ ↓ Intent, complexity, keywords
30
+ Phase 2: Context Discovery (MCP + Search)
31
+ ↓ Relevant files, patterns, dependencies
32
+ Phase 3: Prompt Enhancement
33
+ ↓ Structured enhanced prompt
34
+ Phase 4: Tool Selection & Execution
35
+ ↓ CLI output and results
36
+ Phase 5: Output Routing
37
+ ↓ Session logs and summaries
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Phase 1: Task Understanding
43
+
44
+ **Intent Detection**:
45
+ - `analyze|review|understand|explain|debug` → **analyze**
46
+ - `implement|add|create|build|fix|refactor` → **execute**
47
+ - `design|plan|architecture|strategy` → **plan**
48
+ - `discuss|evaluate|compare|trade-off` → **discuss**
49
+
50
+ **Complexity Scoring**:
51
+ ```
52
+ Score = 0
53
+ + ['system', 'architecture'] → +3
54
+ + ['refactor', 'migrate'] → +2
55
+ + ['component', 'feature'] → +1
56
+ + Multiple tech stacks → +2
57
+ + ['auth', 'payment', 'security'] → +2
58
+
59
+ ≥5 Complex | ≥2 Medium | <2 Simple
60
+ ```
61
+
62
+ **Extract Keywords**: domains (auth, api, database, ui), technologies (react, typescript, node), actions (implement, refactor, test)
63
+
64
+ ---
65
+
66
+ ## Phase 2: Context Discovery
67
+
68
+ **1. Project Structure**:
69
+ ```bash
70
+ ccw tool exec get_modules_by_depth '{}'
71
+ ```
72
+
73
+ **2. Content Search**:
74
+ ```bash
75
+ rg "^(function|def|class|interface).*{keyword}" -t source -n --max-count 15
76
+ rg "^(import|from|require).*{keyword}" -t source | head -15
77
+ find . -name "*{keyword}*test*" -type f | head -10
78
+ ```
79
+
80
+ **3. External Research (Optional)**:
81
+ ```javascript
82
+ mcp__exa__get_code_context_exa(query="{tech_stack} {task_type} patterns", tokensNum="dynamic")
83
+ ```
84
+
85
+ **Relevance Scoring**:
86
+ ```
87
+ Path exact match +5 | Filename +3 | Content ×2 | Source +2 | Test +1 | Config +1
88
+ → Sort by score → Select top 15 → Group by type
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Phase 3: Prompt Enhancement
94
+
95
+ **1. Context Assembly**:
96
+ ```bash
97
+ # Default
98
+ CONTEXT: @**/*
99
+
100
+ # Specific patterns
101
+ CONTEXT: @CLAUDE.md @src/**/* @*.ts
102
+
103
+ # Cross-directory (requires --include-directories)
104
+ CONTEXT: @**/* @../shared/**/* @../types/**/*
105
+ ```
106
+
107
+ **2. Template Selection** (`~/.claude/workflows/cli-templates/prompts/`):
108
+ ```
109
+ analyze → analysis/code-execution-tracing.txt | analysis/pattern.txt
110
+ execute → development/feature.txt
111
+ plan → planning/architecture-planning.txt | planning/task-breakdown.txt
112
+ bug-fix → development/bug-diagnosis.txt
113
+ ```
114
+
115
+ **3. RULES Field**:
116
+ - Use `$(cat ~/.claude/workflows/cli-templates/prompts/{path}.txt)` directly
117
+ - NEVER escape: `\$`, `\"`, `\'` breaks command substitution
118
+
119
+ **4. Structured Prompt**:
120
+ ```bash
121
+ PURPOSE: {enhanced_intent}
122
+ TASK: {specific_task_with_details}
123
+ MODE: {analysis|write|auto}
124
+ CONTEXT: {structured_file_references}
125
+ EXPECTED: {clear_output_expectations}
126
+ RULES: $(cat {selected_template}) | {constraints}
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Phase 4: Tool Selection & Execution
132
+
133
+ **Auto-Selection**:
134
+ ```
135
+ analyze|plan → gemini (qwen fallback) + mode=analysis
136
+ execute (simple|medium) → gemini (qwen fallback) + mode=write
137
+ execute (complex) → codex + mode=auto
138
+ discuss → multi (gemini + codex parallel)
139
+ ```
140
+
141
+ **Models**:
142
+ - Gemini: `gemini-2.5-pro` (analysis), `gemini-2.5-flash` (docs)
143
+ - Qwen: `coder-model` (default), `vision-model` (image)
144
+ - Codex: `gpt-5` (default), `gpt5-codex` (large context)
145
+ - **Position**: `-m` after prompt, before flags
146
+
147
+ ### Command Templates
148
+
149
+ **Gemini/Qwen (Analysis)**:
150
+ ```bash
151
+ cd {dir} && gemini -p "
152
+ PURPOSE: {goal}
153
+ TASK: {task}
154
+ MODE: analysis
155
+ CONTEXT: @**/*
156
+ EXPECTED: {output}
157
+ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)
158
+ " -m gemini-2.5-pro
159
+
160
+ # Qwen fallback: Replace 'gemini' with 'qwen'
161
+ ```
162
+
163
+ **Gemini/Qwen (Write)**:
164
+ ```bash
165
+ cd {dir} && gemini -p "..." --approval-mode yolo
166
+ ```
167
+
168
+ **Codex (Auto)**:
169
+ ```bash
170
+ codex -C {dir} --full-auto exec "..." --skip-git-repo-check -s danger-full-access
171
+
172
+ # Resume: Add 'resume --last' after prompt
173
+ codex --full-auto exec "..." resume --last --skip-git-repo-check -s danger-full-access
174
+ ```
175
+
176
+ **Cross-Directory** (Gemini/Qwen):
177
+ ```bash
178
+ cd src/auth && gemini -p "CONTEXT: @**/* @../shared/**/*" --include-directories ../shared
179
+ ```
180
+
181
+ **Directory Scope**:
182
+ - `@` only references current directory + subdirectories
183
+ - External dirs: MUST use `--include-directories` + explicit CONTEXT reference
184
+
185
+ **Timeout**: Simple 20min | Medium 40min | Complex 60min (Codex ×1.5)
186
+
187
+ ---
188
+
189
+ ## Phase 5: Output Routing
190
+
191
+ **Session Detection**:
192
+ ```bash
193
+ find .workflow/active/ -name 'WFS-*' -type d
194
+ ```
195
+
196
+ **Output Paths**:
197
+ - **With session**: `.workflow/active/WFS-{id}/.chat/{agent}-{timestamp}.md`
198
+ - **No session**: `.workflow/.scratchpad/{agent}-{description}-{timestamp}.md`
199
+
200
+ **Log Structure**:
201
+ ```markdown
202
+ # CLI Execution Agent Log
203
+ **Timestamp**: {iso_timestamp} | **Session**: {session_id} | **Task**: {task_id}
204
+
205
+ ## Phase 1: Intent {intent} | Complexity {complexity} | Keywords {keywords}
206
+ ## Phase 2: Files ({N}) | Patterns {patterns} | Dependencies {deps}
207
+ ## Phase 3: Enhanced Prompt
208
+ {full_prompt}
209
+ ## Phase 4: Tool {tool} | Command {cmd} | Result {status} | Duration {time}
210
+ ## Phase 5: Log {path} | Summary {summary_path}
211
+ ## Next Steps: {actions}
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Error Handling
217
+
218
+ **Tool Fallback**:
219
+ ```
220
+ Gemini unavailable → Qwen
221
+ Codex unavailable → Gemini/Qwen write mode
222
+ ```
223
+
224
+ **Gemini 429**: Check results exist → success (ignore error) | no results → retry → Qwen
225
+
226
+ **MCP Exa Unavailable**: Fallback to local search (find/rg)
227
+
228
+ **Timeout**: Collect partial → save intermediate → suggest decomposition
229
+
230
+ ---
231
+
232
+ ## Quality Checklist
233
+
234
+ - [ ] Context ≥3 files
235
+ - [ ] Enhanced prompt detailed
236
+ - [ ] Tool selected
237
+ - [ ] Execution complete
238
+ - [ ] Output routed
239
+ - [ ] Session updated
240
+ - [ ] Next steps documented
241
+
242
+ **Performance**: Phase 1-3-5: ~10-25s | Phase 2: 5-15s | Phase 4: Variable
243
+
244
+ ---
245
+
246
+ ## Templates Reference
247
+
248
+ **Location**: `~/.claude/workflows/cli-templates/prompts/`
249
+
250
+ **Analysis** (`analysis/`):
251
+ - `pattern.txt` - Code pattern analysis
252
+ - `architecture.txt` - System architecture review
253
+ - `code-execution-tracing.txt` - Execution path tracing and debugging
254
+ - `security.txt` - Security assessment
255
+ - `quality.txt` - Code quality review
256
+
257
+ **Development** (`development/`):
258
+ - `feature.txt` - Feature implementation
259
+ - `refactor.txt` - Refactoring tasks
260
+ - `testing.txt` - Test generation
261
+ - `bug-diagnosis.txt` - Bug root cause analysis and fix suggestions
262
+
263
+ **Planning** (`planning/`):
264
+ - `task-breakdown.txt` - Task decomposition
265
+ - `architecture-planning.txt` - Strategic architecture modification planning
266
+
267
+ **Memory** (`memory/`):
268
+ - `claude-module-unified.txt` - Universal module/file documentation
269
+
270
270
  ---