claude-code-workflow 6.3.48 → 6.3.49

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 (211) hide show
  1. package/.claude/CLAUDE.md +6 -8
  2. package/.claude/agents/action-planning-agent.md +28 -45
  3. package/.claude/agents/cli-lite-planning-agent.md +93 -1
  4. package/.claude/agents/code-developer.md +144 -27
  5. package/.claude/commands/ccw-coordinator.md +175 -21
  6. package/.claude/commands/ccw-debug.md +832 -0
  7. package/.claude/commands/ccw.md +90 -9
  8. package/.claude/commands/cli/cli-init.md +1 -0
  9. package/.claude/commands/issue/convert-to-plan.md +718 -0
  10. package/.claude/commands/issue/from-brainstorm.md +382 -0
  11. package/.claude/commands/memory/tips.md +332 -0
  12. package/.claude/commands/workflow/analyze-with-file.md +804 -0
  13. package/.claude/commands/workflow/brainstorm/auto-parallel.md +18 -43
  14. package/.claude/commands/workflow/brainstorm/role-analysis.md +705 -0
  15. package/.claude/commands/workflow/brainstorm-with-file.md +1153 -0
  16. package/.claude/commands/workflow/debug-with-file.md +7 -5
  17. package/.claude/commands/workflow/execute.md +6 -4
  18. package/.claude/commands/workflow/lite-plan.md +2 -2
  19. package/.claude/commands/workflow/plan-verify.md +162 -327
  20. package/.claude/commands/workflow/plan.md +162 -26
  21. package/.claude/commands/workflow/replan.md +78 -2
  22. package/.claude/commands/workflow/{review-fix.md → review-cycle-fix.md} +6 -6
  23. package/.claude/commands/workflow/review-module-cycle.md +2 -2
  24. package/.claude/commands/workflow/review-session-cycle.md +2 -2
  25. package/.claude/commands/workflow/tools/conflict-resolution.md +16 -26
  26. package/.claude/commands/workflow/tools/context-gather.md +81 -118
  27. package/.claude/commands/workflow/tools/task-generate-agent.md +94 -10
  28. package/.claude/skills/ccw-help/command.json +4 -4
  29. package/.claude/skills/lite-skill-generator/SKILL.md +650 -0
  30. package/.claude/skills/lite-skill-generator/templates/simple-skill.md +68 -0
  31. package/.claude/skills/lite-skill-generator/templates/style-guide.md +64 -0
  32. package/.claude/skills/skill-generator/SKILL.md +277 -85
  33. package/.claude/skills/skill-generator/phases/01-requirements-discovery.md +4 -15
  34. package/.claude/skills/skill-generator/phases/02-structure-generation.md +72 -17
  35. package/.claude/skills/skill-generator/phases/03-phase-generation.md +218 -51
  36. package/.claude/skills/skill-generator/phases/04-specs-templates.md +111 -41
  37. package/.claude/skills/skill-generator/phases/05-validation.md +139 -56
  38. package/.claude/skills/skill-generator/templates/autonomous-action.md +78 -268
  39. package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +14 -0
  40. package/.claude/skills/skill-generator/templates/code-analysis-action.md +12 -0
  41. package/.claude/skills/skill-generator/templates/llm-action.md +12 -0
  42. package/.claude/skills/skill-generator/templates/script-template.md +368 -0
  43. package/.claude/skills/skill-generator/templates/sequential-phase.md +14 -0
  44. package/.claude/skills/skill-generator/templates/skill-md.md +14 -0
  45. package/.claude/skills/skill-tuning/SKILL.md +130 -266
  46. package/.claude/skills/skill-tuning/phases/orchestrator.md +95 -283
  47. package/.claude/skills/skill-tuning/specs/problem-taxonomy.md +90 -198
  48. package/.claude/skills/skill-tuning/specs/tuning-strategies.md +193 -1345
  49. package/.claude/workflows/cli-templates/schemas/plan-verify-agent-schema.json +47 -0
  50. package/.claude/workflows/cli-templates/schemas/verify-json-schema.json +158 -0
  51. package/.claude/workflows/cli-tools-usage.md +1 -1
  52. package/.codex/AGENTS.md +1 -3
  53. package/.codex/prompts/analyze-with-file.md +607 -0
  54. package/.codex/prompts/brainstorm-to-cycle.md +455 -0
  55. package/.codex/prompts/brainstorm-with-file.md +933 -0
  56. package/.codex/prompts/debug-with-file.md +15 -20
  57. package/.codex/skills/ccw-cli-tools/SKILL.md +559 -0
  58. package/ccw/dist/commands/cli.d.ts.map +1 -1
  59. package/ccw/dist/commands/cli.js +29 -5
  60. package/ccw/dist/commands/cli.js.map +1 -1
  61. package/ccw/dist/commands/issue.d.ts +2 -0
  62. package/ccw/dist/commands/issue.d.ts.map +1 -1
  63. package/ccw/dist/commands/issue.js +62 -20
  64. package/ccw/dist/commands/issue.js.map +1 -1
  65. package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -1
  66. package/ccw/dist/config/litellm-api-config-manager.js +5 -3
  67. package/ccw/dist/config/litellm-api-config-manager.js.map +1 -1
  68. package/ccw/dist/config/litellm-provider-models.d.ts +73 -0
  69. package/ccw/dist/config/litellm-provider-models.d.ts.map +1 -0
  70. package/ccw/dist/config/litellm-provider-models.js +172 -0
  71. package/ccw/dist/config/litellm-provider-models.js.map +1 -0
  72. package/ccw/dist/config/provider-models.d.ts +25 -51
  73. package/ccw/dist/config/provider-models.d.ts.map +1 -1
  74. package/ccw/dist/config/provider-models.js +84 -149
  75. package/ccw/dist/config/provider-models.js.map +1 -1
  76. package/ccw/dist/config/storage-paths.d.ts.map +1 -1
  77. package/ccw/dist/config/storage-paths.js +23 -5
  78. package/ccw/dist/config/storage-paths.js.map +1 -1
  79. package/ccw/dist/core/auth/csrf-middleware.js +3 -3
  80. package/ccw/dist/core/auth/csrf-middleware.js.map +1 -1
  81. package/ccw/dist/core/dashboard-generator.d.ts.map +1 -1
  82. package/ccw/dist/core/dashboard-generator.js +3 -1
  83. package/ccw/dist/core/dashboard-generator.js.map +1 -1
  84. package/ccw/dist/core/routes/claude-routes.d.ts.map +1 -1
  85. package/ccw/dist/core/routes/claude-routes.js +206 -14
  86. package/ccw/dist/core/routes/claude-routes.js.map +1 -1
  87. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  88. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  89. package/ccw/dist/core/routes/commands-routes.d.ts +7 -0
  90. package/ccw/dist/core/routes/commands-routes.d.ts.map +1 -0
  91. package/ccw/dist/core/routes/commands-routes.js +480 -0
  92. package/ccw/dist/core/routes/commands-routes.js.map +1 -0
  93. package/ccw/dist/core/routes/model-routes.d.ts +11 -0
  94. package/ccw/dist/core/routes/model-routes.d.ts.map +1 -0
  95. package/ccw/dist/core/routes/model-routes.js +112 -0
  96. package/ccw/dist/core/routes/model-routes.js.map +1 -0
  97. package/ccw/dist/core/routes/nav-status-routes.d.ts.map +1 -1
  98. package/ccw/dist/core/routes/nav-status-routes.js +84 -1
  99. package/ccw/dist/core/routes/nav-status-routes.js.map +1 -1
  100. package/ccw/dist/core/routes/provider-routes.d.ts +11 -0
  101. package/ccw/dist/core/routes/provider-routes.d.ts.map +1 -0
  102. package/ccw/dist/core/routes/provider-routes.js +67 -0
  103. package/ccw/dist/core/routes/provider-routes.js.map +1 -0
  104. package/ccw/dist/core/routes/skills-routes.d.ts.map +1 -1
  105. package/ccw/dist/core/routes/skills-routes.js +219 -7
  106. package/ccw/dist/core/routes/skills-routes.js.map +1 -1
  107. package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
  108. package/ccw/dist/core/routes/system-routes.js +58 -6
  109. package/ccw/dist/core/routes/system-routes.js.map +1 -1
  110. package/ccw/dist/core/server.d.ts.map +1 -1
  111. package/ccw/dist/core/server.js +13 -0
  112. package/ccw/dist/core/server.js.map +1 -1
  113. package/ccw/dist/mcp-server/index.js +2 -2
  114. package/ccw/dist/mcp-server/index.js.map +1 -1
  115. package/ccw/dist/tools/claude-cli-tools.d.ts +48 -11
  116. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  117. package/ccw/dist/tools/claude-cli-tools.js +146 -50
  118. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  119. package/ccw/dist/tools/cli-config-manager.d.ts +1 -13
  120. package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -1
  121. package/ccw/dist/tools/cli-config-manager.js +3 -27
  122. package/ccw/dist/tools/cli-config-manager.js.map +1 -1
  123. package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
  124. package/ccw/dist/tools/cli-executor-core.js +7 -2
  125. package/ccw/dist/tools/cli-executor-core.js.map +1 -1
  126. package/ccw/dist/tools/cli-executor-state.d.ts.map +1 -1
  127. package/ccw/dist/tools/cli-history-store.d.ts +11 -0
  128. package/ccw/dist/tools/cli-history-store.d.ts.map +1 -1
  129. package/ccw/dist/tools/cli-history-store.js +82 -2
  130. package/ccw/dist/tools/cli-history-store.js.map +1 -1
  131. package/ccw/dist/tools/command-registry.d.ts +7 -0
  132. package/ccw/dist/tools/command-registry.d.ts.map +1 -1
  133. package/ccw/dist/tools/command-registry.js +14 -1
  134. package/ccw/dist/tools/command-registry.js.map +1 -1
  135. package/ccw/dist/tools/generate-module-docs.d.ts.map +1 -1
  136. package/ccw/dist/tools/generate-module-docs.js +11 -7
  137. package/ccw/dist/tools/generate-module-docs.js.map +1 -1
  138. package/ccw/dist/tools/litellm-executor.d.ts +1 -0
  139. package/ccw/dist/tools/litellm-executor.d.ts.map +1 -1
  140. package/ccw/dist/tools/litellm-executor.js +11 -9
  141. package/ccw/dist/tools/litellm-executor.js.map +1 -1
  142. package/ccw/dist/types/skill-types.d.ts +97 -0
  143. package/ccw/dist/types/skill-types.d.ts.map +1 -0
  144. package/ccw/dist/types/skill-types.js +6 -0
  145. package/ccw/dist/types/skill-types.js.map +1 -0
  146. package/ccw/src/commands/cli.ts +36 -5
  147. package/ccw/src/commands/issue.ts +81 -26
  148. package/ccw/src/config/litellm-api-config-manager.ts +5 -3
  149. package/ccw/src/config/litellm-provider-models.ts +222 -0
  150. package/ccw/src/config/provider-models.ts +91 -190
  151. package/ccw/src/config/storage-paths.ts +20 -5
  152. package/ccw/src/core/auth/csrf-middleware.ts +3 -3
  153. package/ccw/src/core/dashboard-generator.ts +3 -1
  154. package/ccw/src/core/routes/claude-routes.ts +233 -15
  155. package/ccw/src/core/routes/cli-routes.ts +2 -3
  156. package/ccw/src/core/routes/commands-routes.ts +620 -0
  157. package/ccw/src/core/routes/nav-status-routes.ts +95 -1
  158. package/ccw/src/core/routes/provider-routes.ts +78 -0
  159. package/ccw/src/core/routes/skills-routes.ts +266 -45
  160. package/ccw/src/core/routes/system-routes.ts +102 -50
  161. package/ccw/src/core/server.ts +13 -0
  162. package/ccw/src/mcp-server/index.ts +2 -2
  163. package/ccw/src/templates/dashboard-css/18-cli-settings.css +35 -0
  164. package/ccw/src/templates/dashboard-css/37-commands.css +193 -0
  165. package/ccw/src/templates/dashboard-js/components/navigation.js +4 -0
  166. package/ccw/src/templates/dashboard-js/i18n.js +116 -0
  167. package/ccw/src/templates/dashboard-js/views/cli-manager.js +249 -4
  168. package/ccw/src/templates/dashboard-js/views/commands-manager.js +503 -0
  169. package/ccw/src/templates/dashboard-js/views/issue-manager.js +7 -7
  170. package/ccw/src/templates/dashboard-js/views/mcp-manager.js +2 -7
  171. package/ccw/src/templates/dashboard-js/views/skills-manager.js +164 -23
  172. package/ccw/src/templates/dashboard.html +7 -0
  173. package/ccw/src/tools/claude-cli-tools.ts +170 -56
  174. package/ccw/src/tools/cli-config-manager.ts +2 -33
  175. package/ccw/src/tools/cli-executor-core.ts +8 -2
  176. package/ccw/src/tools/cli-history-store.ts +92 -2
  177. package/ccw/src/tools/command-registry.ts +16 -1
  178. package/ccw/src/tools/generate-module-docs.ts +11 -7
  179. package/ccw/src/tools/litellm-executor.ts +13 -9
  180. package/ccw/src/types/skill-types.ts +99 -0
  181. package/package.json +1 -1
  182. package/.claude/commands/enhance-prompt.md +0 -93
  183. package/.claude/commands/memory/code-map-memory.md +0 -687
  184. package/.claude/commands/memory/docs.md +0 -615
  185. package/.claude/commands/memory/load-skill-memory.md +0 -182
  186. package/.claude/commands/memory/skill-memory.md +0 -525
  187. package/.claude/commands/memory/swagger-docs.md +0 -773
  188. package/.claude/commands/memory/tech-research-rules.md +0 -310
  189. package/.claude/commands/memory/workflow-skill-memory.md +0 -517
  190. package/.claude/commands/task/breakdown.md +0 -208
  191. package/.claude/commands/task/create.md +0 -152
  192. package/.claude/commands/task/execute.md +0 -270
  193. package/.claude/commands/task/replan.md +0 -441
  194. package/.claude/commands/version.md +0 -254
  195. package/.claude/commands/workflow/action-plan-verify.md +0 -485
  196. package/.claude/commands/workflow/brainstorm/api-designer.md +0 -587
  197. package/.claude/commands/workflow/brainstorm/data-architect.md +0 -220
  198. package/.claude/commands/workflow/brainstorm/product-manager.md +0 -200
  199. package/.claude/commands/workflow/brainstorm/product-owner.md +0 -200
  200. package/.claude/commands/workflow/brainstorm/scrum-master.md +0 -200
  201. package/.claude/commands/workflow/brainstorm/subject-matter-expert.md +0 -200
  202. package/.claude/commands/workflow/brainstorm/system-architect.md +0 -389
  203. package/.claude/commands/workflow/brainstorm/ui-designer.md +0 -221
  204. package/.claude/commands/workflow/brainstorm/ux-expert.md +0 -221
  205. package/.claude/commands/workflow/debug.md +0 -331
  206. package/.claude/commands/workflow/develop-with-file.md +0 -1044
  207. package/.claude/skills/ccw-loop/README.md +0 -303
  208. package/.claude/skills/skill-generator/templates/script-bash.md +0 -277
  209. package/.claude/skills/skill-generator/templates/script-python.md +0 -198
  210. package/.codex/prompts/debug.md +0 -318
  211. package/ccw/src/core/routes/mcp-routes.ts.backup +0 -549
@@ -506,7 +506,7 @@ Each line is a JSON object:
506
506
  ## Iteration Flow
507
507
 
508
508
  ```
509
- First Call (/prompts:debug-with-file BUG="error"):
509
+ First Call (BUG="error"):
510
510
  ├─ No session exists → Explore mode
511
511
  ├─ Extract error keywords, search codebase
512
512
  ├─ Document initial understanding in understanding.md
@@ -514,7 +514,7 @@ First Call (/prompts:debug-with-file BUG="error"):
514
514
  ├─ Add logging instrumentation
515
515
  └─ Await user reproduction
516
516
 
517
- After Reproduction (/prompts:debug-with-file BUG="error"):
517
+ After Reproduction (BUG="error"):
518
518
  ├─ Session exists + debug.log has content → Analyze mode
519
519
  ├─ Parse log, evaluate hypotheses
520
520
  ├─ Update understanding.md with:
@@ -578,32 +578,27 @@ Also we checked A and found B, and then we checked C...
578
578
  Why is config value None during update?
579
579
  ```
580
580
 
581
- ## Comparison with /prompts:debug
581
+ ## Key Features
582
582
 
583
- | Feature | /prompts:debug | /prompts:debug-with-file |
584
- |---------|-----------------|---------------------------|
585
- | NDJSON logging | | |
586
- | Hypothesis generation | Manual | Analysis-assisted |
587
- | Exploration documentation | ❌ | ✅ understanding.md |
588
- | Understanding evolution | ❌ | ✅ Timeline + corrections |
589
- | Error correction | ❌ | ✅ Strikethrough + reasoning |
590
- | Consolidated learning | ❌ | ✅ Current understanding section |
591
- | Hypothesis history | ❌ | ✅ hypotheses.json |
592
- | Analysis validation | ❌ | ✅ At key decision points |
583
+ | Feature | Description |
584
+ |---------|-------------|
585
+ | NDJSON logging | Structured debug log with hypothesis tracking |
586
+ | Hypothesis generation | Analysis-assisted hypothesis creation |
587
+ | Exploration documentation | understanding.md with timeline |
588
+ | Understanding evolution | Timeline + corrections tracking |
589
+ | Error correction | Strikethrough + reasoning for wrong assumptions |
590
+ | Consolidated learning | Current understanding section |
591
+ | Hypothesis history | hypotheses.json with verdicts |
592
+ | Analysis validation | At key decision points |
593
593
 
594
- ## Usage Recommendations
594
+ ## When to Use
595
595
 
596
- Use `/prompts:debug-with-file` when:
596
+ Best suited for:
597
597
  - Complex bugs requiring multiple investigation rounds
598
598
  - Learning from debugging process is valuable
599
599
  - Team needs to understand debugging rationale
600
600
  - Bug might recur, documentation helps prevention
601
601
 
602
- Use `/prompts:debug` when:
603
- - Simple, quick bugs
604
- - One-off issues
605
- - Documentation overhead not needed
606
-
607
602
  ---
608
603
 
609
604
  **Now execute the debug-with-file workflow for bug**: $BUG
@@ -0,0 +1,559 @@
1
+ ---
2
+ name: ccw-cli-tools
3
+ description: CLI tools execution specification (gemini/claude/codex/qwen/opencode) with unified prompt template, mode options, and auto-invoke triggers for code analysis and implementation tasks. Supports configurable CLI endpoints for analysis, write, and review modes.
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # CLI Tools - Unified Execution Framework
8
+
9
+ **Purpose**: Structured CLI tool usage with configuration-driven tool selection, unified prompt templates, and quality-gated execution.
10
+
11
+ **Configuration**: `~/.claude/cli-tools.json` (Global, always read at initialization)
12
+
13
+ ## Initialization (Required First Step)
14
+
15
+ **Before any tool selection or recommendation**:
16
+
17
+ 1. Check if configuration exists in memory:
18
+ - If configuration is already in conversation memory → Use it directly
19
+ - If NOT in memory → Read the configuration file:
20
+ ```bash
21
+ Read(file_path="~/.claude/cli-tools.json")
22
+ ```
23
+
24
+ 2. Parse the JSON to understand:
25
+ - Available tools and their `enabled` status
26
+ - Each tool's `primaryModel` and `secondaryModel`
27
+ - Tags defined for tag-based routing
28
+ - Tool types (builtin, cli-wrapper, api-endpoint)
29
+
30
+ 3. Use configuration throughout the selection process
31
+
32
+ **Why**: Tools, models, and tags may change. Configuration file is the single source of truth.
33
+ **Optimization**: Reuse in-memory configuration to avoid redundant file reads.
34
+
35
+ ## Process Flow
36
+
37
+ ```
38
+ ┌─ USER REQUEST
39
+
40
+ ├─ STEP 1: Load Configuration
41
+ │ ├─ Check if configuration exists in conversation memory
42
+ │ └─ If NOT in memory → Read(file_path="~/.claude/cli-tools.json")
43
+
44
+ ├─ STEP 2: Understand User Intent
45
+ │ ├─ Parse task type (analysis, implementation, security, etc.)
46
+ │ ├─ Extract required capabilities (tags)
47
+ │ └─ Identify scope (files, modules)
48
+
49
+ ├─ STEP 3: Select Tool (based on config)
50
+ │ ├─ Explicit --tool specified?
51
+ │ │ YES → Validate in config → Use it
52
+ │ │ NO → Match tags with enabled tools → Select best match
53
+ │ │ → No match → Use first enabled tool (default)
54
+ │ └─ Get primaryModel from config
55
+
56
+ ├─ STEP 4: Build Prompt
57
+ │ └─ Use 6-field template: PURPOSE, TASK, MODE, CONTEXT, EXPECTED, CONSTRAINTS
58
+
59
+ ├─ STEP 5: Select Rule Template
60
+ │ ├─ Determine rule from task type
61
+ │ └─ Pass via --rule parameter
62
+
63
+ ├─ STEP 6: Execute CLI Command
64
+ │ └─ ccw cli -p "<PROMPT>" --tool <tool> --mode <mode> --rule <rule>
65
+
66
+ └─ STEP 7: Handle Results
67
+ ├─ On success → Deliver output to user
68
+ └─ On failure → Check secondaryModel or fallback tool
69
+ ```
70
+
71
+ ## Configuration Reference
72
+
73
+ ### Configuration File Location
74
+
75
+ **Path**: `~/.claude/cli-tools.json` (Global configuration)
76
+
77
+ **IMPORTANT**: Check conversation memory first. Only read file if configuration is not in memory.
78
+
79
+ ### Reading Configuration
80
+
81
+ **Priority**: Check conversation memory first
82
+
83
+ **Loading Options**:
84
+ - **Option 1** (Preferred): Use in-memory configuration if already loaded in conversation
85
+ - **Option 2** (Fallback): Read from file when not in memory
86
+
87
+ ```bash
88
+ # Read configuration file
89
+ cat ~/.claude/cli-tools.json
90
+ ```
91
+
92
+ The configuration defines all available tools with their enabled status, models, and tags.
93
+
94
+ ### Configuration Structure
95
+
96
+ The JSON file contains a `tools` object where each tool has these fields:
97
+
98
+ | Field | Type | Description | Example |
99
+ |-------|------|-------------|---------|
100
+ | `enabled` | boolean | Tool availability status | `true` or `false` |
101
+ | `primaryModel` | string | Default model for execution | `"gemini-2.5-pro"` |
102
+ | `secondaryModel` | string | Fallback model on primary failure | `"gemini-2.5-flash"` |
103
+ | `tags` | array | Capability tags for routing | `["分析", "Debug"]` |
104
+ | `type` | string | Tool type | `"builtin"`, `"cli-wrapper"`, `"api-endpoint"` |
105
+
106
+ ### Expected Tools (Reference Only)
107
+
108
+ Typical tools found in configuration (actual availability determined by reading the file):
109
+
110
+ | Tool | Typical Type | Common Use |
111
+ |------|--------------|------------|
112
+ | `gemini` | builtin | Analysis, Debug (分析, Debug tags) |
113
+ | `qwen` | builtin | General coding |
114
+ | `codex` | builtin | Code review, implementation |
115
+ | `claude` | builtin | General tasks |
116
+ | `opencode` | builtin | Open-source model fallback |
117
+
118
+ **Note**: Tool availability, models, and tags may differ. Use in-memory configuration or read `~/.claude/cli-tools.json` if not cached.
119
+
120
+ ### Configuration Fields
121
+
122
+ - **`enabled`**: Tool availability (boolean)
123
+ - **`primaryModel`**: Default model for execution
124
+ - **`secondaryModel`**: Fallback model on primary failure
125
+ - **`tags`**: Capability tags for routing (分析, Debug, implementation, etc.)
126
+ - **`type`**: Tool type (builtin, cli-wrapper, api-endpoint)
127
+
128
+ ## Universal Prompt Template
129
+
130
+ **Structure**: Every CLI command follows this 6-field template
131
+
132
+ ```bash
133
+ ccw cli -p "PURPOSE: [goal] + [why] + [success criteria] + [scope]
134
+ TASK: • [step 1: specific action] • [step 2: specific action] • [step 3: specific action]
135
+ MODE: [analysis|write|review]
136
+ CONTEXT: @[file patterns] | Memory: [session/tech/module context]
137
+ EXPECTED: [deliverable format] + [quality criteria] + [structure requirements]
138
+ CONSTRAINTS: [domain constraints]" --tool <tool-id> --mode <mode> --rule <template>
139
+ ```
140
+
141
+ ### Field Specifications
142
+
143
+ #### PURPOSE (Goal Definition)
144
+
145
+ **What**: Clear objective + motivation + success criteria + scope boundary
146
+
147
+ **Components**:
148
+ - What: Specific task goal
149
+ - Why: Business/technical motivation
150
+ - Success: Measurable success criteria
151
+ - Scope: Bounded context/files
152
+
153
+ **Example - Good**:
154
+ ```
155
+ PURPOSE: Identify OWASP Top 10 vulnerabilities in auth module to pass security audit;
156
+ success = all critical/high issues documented with remediation;
157
+ scope = src/auth/** only
158
+ ```
159
+
160
+ **Example - Bad**:
161
+ ```
162
+ PURPOSE: Analyze code
163
+ ```
164
+
165
+ #### TASK (Action Steps)
166
+
167
+ **What**: Specific, actionable steps with clear verbs and targets
168
+
169
+ **Format**: Bullet list with concrete actions
170
+
171
+ **Example - Good**:
172
+ ```
173
+ TASK:
174
+ • Scan for SQL injection in query builders
175
+ • Check XSS in template rendering
176
+ • Verify CSRF token validation
177
+ ```
178
+
179
+ **Example - Bad**:
180
+ ```
181
+ TASK: Review code and find issues
182
+ ```
183
+
184
+ #### MODE (Permission Level)
185
+
186
+ **Options**:
187
+ - **`analysis`** - Read-only, safe for auto-execution
188
+ - **`write`** - Create/Modify/Delete files, full operations
189
+ - **`review`** - Git-aware code review (codex only)
190
+
191
+ **Rules**:
192
+ - Always specify explicitly
193
+ - Default to `analysis` for read-only tasks
194
+ - Require explicit `--mode write` for file modifications
195
+ - Use `--mode review` with `--tool codex` for git-aware review
196
+
197
+ #### CONTEXT (File Scope + Memory)
198
+
199
+ **Format**: `CONTEXT: @[file patterns] | Memory: [memory context]`
200
+
201
+ **File Patterns**:
202
+ - `@**/*` - All files (default)
203
+ - `@src/**/*.ts` - Specific pattern
204
+ - `@../shared/**/*` - Parent/sibling (requires `--includeDirs`)
205
+
206
+ **Memory Context** (when building on previous work):
207
+ ```
208
+ Memory: Building on auth refactoring (commit abc123), using JWT for sessions
209
+ Memory: Integration with auth module, shared error patterns from @shared/utils/errors.ts
210
+ ```
211
+
212
+ #### EXPECTED (Output Specification)
213
+
214
+ **What**: Output format + quality criteria + structure requirements
215
+
216
+ **Example - Good**:
217
+ ```
218
+ EXPECTED: Markdown report with:
219
+ severity levels (Critical/High/Medium/Low),
220
+ file:line references,
221
+ remediation code snippets,
222
+ priority ranking
223
+ ```
224
+
225
+ **Example - Bad**:
226
+ ```
227
+ EXPECTED: Report
228
+ ```
229
+
230
+ #### CONSTRAINTS (Domain Boundaries)
231
+
232
+ **What**: Scope limits, special requirements, focus areas
233
+
234
+ **Example - Good**:
235
+ ```
236
+ CONSTRAINTS: Focus on authentication | Ignore test files | No breaking changes
237
+ ```
238
+
239
+ **Example - Bad**:
240
+ ```
241
+ CONSTRAINTS: (missing or too vague)
242
+ ```
243
+
244
+ ## CLI Execution Modes
245
+
246
+ ### MODE: analysis
247
+ - **Permission**: Read-only
248
+ - **Use For**: Code review, architecture analysis, pattern discovery, exploration
249
+ - **Safe**: Yes - can auto-execute
250
+ - **Default**: When not specified
251
+
252
+ ### MODE: write
253
+ - **Permission**: Create/Modify/Delete files
254
+ - **Use For**: Feature implementation, bug fixes, documentation, code creation
255
+ - **Safe**: No - requires explicit `--mode write`
256
+ - **Requirements**: Must be explicitly requested by user
257
+
258
+ ### MODE: review
259
+ - **Permission**: Read-only (git-aware review output)
260
+ - **Use For**: Code review of uncommitted changes, branch diffs, specific commits
261
+ - **Tool Support**: `codex` only (others treat as analysis)
262
+ - **Constraint**: Target flags (`--uncommitted`, `--base`, `--commit`) and prompt are mutually exclusive
263
+
264
+ ## Command Structure
265
+
266
+ ### Basic Command
267
+
268
+ ```bash
269
+ ccw cli -p "<PROMPT>" --tool <tool-id> --mode <analysis|write|review>
270
+ ```
271
+
272
+ ### Command Options
273
+
274
+ | Option | Description | Example |
275
+ |--------|-------------|---------|
276
+ | `--tool <tool>` | Tool from config | `--tool gemini` |
277
+ | `--mode <mode>` | **REQUIRED**: analysis/write/review | `--mode analysis` |
278
+ | `--model <model>` | Model override | `--model gemini-2.5-flash` |
279
+ | `--cd <path>` | Working directory | `--cd src/auth` |
280
+ | `--includeDirs <dirs>` | Additional directories | `--includeDirs ../shared,../types` |
281
+ | `--rule <template>` | Auto-load template | `--rule analysis-review-architecture` |
282
+ | `--resume [id]` | Resume session | `--resume` or `--resume <id>` |
283
+
284
+ ### Advanced Directory Configuration
285
+
286
+ #### Working Directory (`--cd`)
287
+
288
+ When using `--cd`:
289
+ - `@**/*` = Files within working directory tree only
290
+ - Cannot reference parent/sibling without `--includeDirs`
291
+ - Reduces token usage by scoping context
292
+
293
+ #### Include Directories (`--includeDirs`)
294
+
295
+ **Two-step requirement for external files**:
296
+
297
+ 1. Add `--includeDirs` parameter
298
+ 2. Reference in CONTEXT with @ patterns
299
+
300
+ ```bash
301
+ # Single directory
302
+ ccw cli -p "CONTEXT: @**/* @../shared/**/*" \
303
+ --tool gemini --mode analysis \
304
+ --cd src/auth --includeDirs ../shared
305
+
306
+ # Multiple directories
307
+ ccw cli -p "..." \
308
+ --tool gemini --mode analysis \
309
+ --cd src/auth --includeDirs ../shared,../types,../utils
310
+ ```
311
+
312
+ ### Session Resume
313
+
314
+ **When to Use**:
315
+ - Multi-round planning (analysis → planning → implementation)
316
+ - Multi-model collaboration (tool A → tool B on same topic)
317
+ - Topic continuity (building on previous findings)
318
+
319
+ **Usage**:
320
+
321
+ ```bash
322
+ ccw cli -p "Continue analyzing" --tool <tool-id> --mode analysis --resume # Resume last
323
+ ccw cli -p "Fix issues found" --tool <tool-id> --mode write --resume <id> # Resume specific
324
+ ccw cli -p "Merge findings" --tool <tool-id> --mode analysis --resume <id1>,<id2> # Merge sessions
325
+ ```
326
+
327
+ ## Available Rule Templates
328
+
329
+ ### Template System
330
+
331
+ Use `--rule <template-name>` to auto-load protocol + template appended to prompt
332
+
333
+ ### Universal Templates
334
+ - `universal-rigorous-style` - Precise tasks (default)
335
+ - `universal-creative-style` - Exploratory tasks
336
+
337
+ ### Analysis Templates
338
+ - `analysis-trace-code-execution` - Execution tracing
339
+ - `analysis-diagnose-bug-root-cause` - Bug diagnosis
340
+ - `analysis-analyze-code-patterns` - Code patterns
341
+ - `analysis-analyze-technical-document` - Document analysis
342
+ - `analysis-review-architecture` - Architecture review
343
+ - `analysis-review-code-quality` - Code review
344
+ - `analysis-analyze-performance` - Performance analysis
345
+ - `analysis-assess-security-risks` - Security assessment
346
+
347
+ ### Planning Templates
348
+ - `planning-plan-architecture-design` - Architecture design
349
+ - `planning-breakdown-task-steps` - Task breakdown
350
+ - `planning-design-component-spec` - Component design
351
+ - `planning-plan-migration-strategy` - Migration strategy
352
+
353
+ ### Development Templates
354
+ - `development-implement-feature` - Feature implementation
355
+ - `development-refactor-codebase` - Code refactoring
356
+ - `development-generate-tests` - Test generation
357
+ - `development-implement-component-ui` - UI component
358
+ - `development-debug-runtime-issues` - Runtime debugging
359
+
360
+ ## Task-Type Specific Examples
361
+
362
+ ### Example 1: Security Analysis (Read-Only)
363
+
364
+ ```bash
365
+ ccw cli -p "PURPOSE: Identify OWASP Top 10 vulnerabilities in authentication module to pass security audit; success = all critical/high issues documented with remediation
366
+ TASK: • Scan for injection flaws (SQL, command, LDAP) • Check authentication bypass vectors • Evaluate session management • Assess sensitive data exposure
367
+ MODE: analysis
368
+ CONTEXT: @src/auth/**/* @src/middleware/auth.ts | Memory: Using bcrypt for passwords, JWT for sessions
369
+ EXPECTED: Security report with: severity matrix, file:line references, CVE mappings where applicable, remediation code snippets prioritized by risk
370
+ CONSTRAINTS: Focus on authentication | Ignore test files
371
+ " --tool gemini --mode analysis --rule analysis-assess-security-risks --cd src/auth
372
+ ```
373
+
374
+ ### Example 2: Feature Implementation (Write Mode)
375
+
376
+ ```bash
377
+ ccw cli -p "PURPOSE: Implement rate limiting for API endpoints to prevent abuse; must be configurable per-endpoint; backward compatible with existing clients
378
+ TASK: • Create rate limiter middleware with sliding window • Implement per-route configuration • Add Redis backend for distributed state • Include bypass for internal services
379
+ MODE: write
380
+ CONTEXT: @src/middleware/**/* @src/config/**/* | Memory: Using Express.js, Redis already configured, existing middleware pattern in auth.ts
381
+ EXPECTED: Production-ready code with: TypeScript types, unit tests, integration test, configuration example, migration guide
382
+ CONSTRAINTS: Follow existing middleware patterns | No breaking changes
383
+ " --tool gemini --mode write --rule development-implement-feature
384
+ ```
385
+
386
+ ### Example 3: Bug Root Cause Analysis
387
+
388
+ ```bash
389
+ ccw cli -p "PURPOSE: Fix memory leak in WebSocket connection handler causing server OOM after 24h; root cause must be identified before any fix
390
+ TASK: • Trace connection lifecycle from open to close • Identify event listener accumulation • Check cleanup on disconnect • Verify garbage collection eligibility
391
+ MODE: analysis
392
+ CONTEXT: @src/websocket/**/* @src/services/connection-manager.ts | Memory: Using ws library, ~5000 concurrent connections in production
393
+ EXPECTED: Root cause analysis with: memory profile, leak source (file:line), fix recommendation with code, verification steps
394
+ CONSTRAINTS: Focus on resource cleanup
395
+ " --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause --cd src
396
+ ```
397
+
398
+ ### Example 4: Code Review (Codex Review Mode)
399
+
400
+ ```bash
401
+ # Option 1: Custom focus (reviews uncommitted by default)
402
+ ccw cli -p "Focus on security vulnerabilities and error handling" --tool codex --mode review
403
+
404
+ # Option 2: Target flag only (no prompt with target flags)
405
+ ccw cli --tool codex --mode review --uncommitted
406
+ ccw cli --tool codex --mode review --base main
407
+ ccw cli --tool codex --mode review --commit abc123
408
+ ```
409
+
410
+ ## Tool Selection Strategy
411
+
412
+ ### Selection Algorithm
413
+
414
+ **STEP 0 (REQUIRED)**: Load configuration (memory-first strategy)
415
+
416
+ ```bash
417
+ # Check if configuration exists in conversation memory
418
+ # If YES → Use in-memory configuration
419
+ # If NO → Read(file_path="~/.claude/cli-tools.json")
420
+ ```
421
+
422
+ Then proceed with selection:
423
+
424
+ 1. **Parse task intent** → Extract required capabilities
425
+ 2. **Load configuration** → Parse enabled tools with tags from JSON
426
+ 3. **Match tags** → Filter tools supporting required capabilities
427
+ 4. **Select tool** → Choose by priority (explicit > tag-match > default)
428
+ 5. **Select model** → Use primaryModel, fallback to secondaryModel
429
+
430
+ ### Selection Decision Tree
431
+
432
+ ```
433
+ 0. LOAD CONFIGURATION (memory-first)
434
+ ├─ In memory? → Use it
435
+ └─ Not in memory? → Read ~/.claude/cli-tools.json
436
+
437
+ 1. Explicit --tool specified?
438
+ YES → Validate tool is enabled in config → Use it
439
+ NO → Proceed to tag-based selection
440
+ ├─ Extract task tags (security, analysis, implementation, etc.)
441
+ │ ├─ Find tools with matching tags
442
+ │ │ ├─ Multiple matches? Use first enabled
443
+ │ │ └─ Single match? Use it
444
+ │ └─ No tag match? Use default tool
445
+
446
+ └─ Default: Use first enabled tool in config
447
+ ```
448
+
449
+ ### Common Tag Routing
450
+
451
+ **Note**: Match task type to tags defined in `~/.claude/cli-tools.json`
452
+
453
+ | Task Type | Common Tags to Match |
454
+ |-----------|---------------------|
455
+ | Security audit | `分析`, `analysis`, `security` |
456
+ | Bug diagnosis | `Debug`, `分析`, `analysis` |
457
+ | Implementation | `implementation`, (any enabled tool) |
458
+ | Testing | `testing`, (any enabled tool) |
459
+ | Refactoring | `refactoring`, (any enabled tool) |
460
+ | Documentation | `documentation`, (any enabled tool) |
461
+
462
+ **Selection Logic**: Find tools where `tags` array contains matching keywords, otherwise use first enabled tool.
463
+
464
+ ### Fallback Chain
465
+
466
+ When primary tool fails (based on `~/.claude/cli-tools.json` configuration):
467
+
468
+ 1. Check `secondaryModel` for same tool (use `secondaryModel` from config)
469
+ 2. Try next enabled tool with matching tags (scan config for enabled tools)
470
+ 3. Fall back to default enabled tool (first enabled tool in config)
471
+
472
+ **Example Fallback**:
473
+ ```
474
+ Tool1: primaryModel fails
475
+
476
+ Try Tool1: secondaryModel
477
+ ↓ (if fails)
478
+ Try Tool2: primaryModel (next enabled with matching tags)
479
+ ↓ (if fails)
480
+ Try default: first enabled tool
481
+ ```
482
+
483
+ ## Permission Framework
484
+
485
+ **Single-Use Authorization**: Each execution requires explicit user instruction. Previous authorization does NOT carry over.
486
+
487
+ **Mode Hierarchy**:
488
+ - `analysis`: Read-only, safe for auto-execution
489
+ - `write`: Create/Modify/Delete files - requires explicit `--mode write`
490
+ - `review`: Git-aware code review (codex only) - requires explicit `--mode review`
491
+ - **Exception**: User provides clear instructions like "modify", "create", "implement"
492
+
493
+ ## Auto-Invoke Triggers
494
+
495
+ **Proactive CLI invocation** - Auto-invoke `ccw cli` when encountering these scenarios:
496
+
497
+ | Trigger | Suggested Rule | When |
498
+ |---------|----------------|------|
499
+ | **Self-repair fails** | `analysis-diagnose-bug-root-cause` | After 1+ failed fix attempts |
500
+ | **Ambiguous requirements** | `planning-breakdown-task-steps` | Task description lacks clarity |
501
+ | **Architecture decisions** | `planning-plan-architecture-design` | Complex feature needs design |
502
+ | **Pattern uncertainty** | `analysis-analyze-code-patterns` | Unsure of existing conventions |
503
+ | **Critical code paths** | `analysis-assess-security-risks` | Security/performance sensitive |
504
+
505
+ ### Execution Principles for Auto-Invoke
506
+
507
+ - **Default mode**: `--mode analysis` (read-only, safe)
508
+ - **No confirmation needed**: Invoke proactively when triggers match
509
+ - **Wait for results**: Complete analysis before next action
510
+ - **Tool selection**: Use context-appropriate tool or fallback chain
511
+ - **Rule flexibility**: Suggested rules are guidelines, adapt as needed
512
+
513
+ ## Best Practices
514
+
515
+ ### Core Principles
516
+
517
+ - **Configuration-driven** - All tool selection from `cli-tools.json`
518
+ - **Tag-based routing** - Match task requirements to tool capabilities
519
+ - **Use tools early and often** - Tools are faster and more thorough than manual analysis
520
+ - **Unified CLI** - Always use `ccw cli -p` for consistent parameter handling
521
+ - **Default to analysis** - Omit `--mode` for read-only, explicitly use `--mode write` for modifications
522
+ - **Use `--rule` for templates** - Auto-loads protocol + template appended to prompt
523
+ - **Write protection** - Require EXPLICIT `--mode write` for file operations
524
+
525
+ ### Workflow Principles
526
+
527
+ - **Use unified interface** - Always `ccw cli -p` format
528
+ - **Always include template** - Use `--rule <template-name>` to load templates
529
+ - **Be specific** - Clear PURPOSE, TASK, EXPECTED fields
530
+ - **Include constraints** - File patterns, scope in CONSTRAINTS
531
+ - **Leverage memory context** - When building on previous work
532
+ - **Discover patterns first** - Use rg/MCP before CLI execution
533
+ - **Default to full context** - Use `@**/*` unless specific files needed
534
+
535
+ ### Planning Checklist
536
+
537
+ - [ ] **Purpose defined** - Clear goal and intent
538
+ - [ ] **Mode selected** - `--mode analysis|write|review`
539
+ - [ ] **Context gathered** - File references + memory (default `@**/*`)
540
+ - [ ] **Directory navigation** - `--cd` and/or `--includeDirs` if needed
541
+ - [ ] **Tool selected** - Explicit `--tool` or tag-based auto-selection
542
+ - [ ] **Rule template** - `--rule <template-name>` loads template
543
+ - [ ] **Constraints** - Domain constraints in CONSTRAINTS field
544
+
545
+ ## Integration with CLAUDE.md Instructions
546
+
547
+ **From global CLAUDE.md**:
548
+ - Always use `run_in_background: false` for Task tool agent calls
549
+ - Default: Use Bash `run_in_background: true` for CLI calls
550
+ - After CLI call: Stop output immediately, wait for hook callback
551
+ - Wait for results: MUST wait for CLI analysis before taking write actions
552
+ - Value every call: Never waste analysis results, aggregate before proposing solutions
553
+
554
+ **From cli-tools-usage.md**:
555
+ - Strict cli-tools.json configuration adherence
556
+ - Configuration-driven tool selection
557
+ - Template system with --rule auto-loading
558
+ - Permission framework with single-use authorization
559
+ - Auto-invoke triggers for common failure scenarios
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/commands/cli.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4GH,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAQD,UAAU,cAAc;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAmlCD;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,OAAO,EAAE,cAAc,GAAG,cAAc,GACvC,OAAO,CAAC,IAAI,CAAC,CA8Hf"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/commands/cli.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4GH,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAQD,UAAU,cAAc;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAknCD;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,OAAO,EAAE,cAAc,GAAG,cAAc,GACvC,OAAO,CAAC,IAAI,CAAC,CA8Hf"}