claude-code-workflow 7.2.24 → 7.2.26

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 (69) hide show
  1. package/.ccw/workflows/cli-tools-usage.md +123 -521
  2. package/.claude/CLAUDE.md +20 -0
  3. package/.claude/agents/action-planning-agent.md +6 -0
  4. package/.claude/agents/cli-explore-agent.md +63 -77
  5. package/.claude/agents/cli-lite-planning-agent.md +10 -11
  6. package/.claude/agents/issue-plan-agent.md +7 -2
  7. package/.claude/commands/workflow/spec/setup.md +1 -1
  8. package/.claude/skills/brainstorm/SKILL.md +408 -408
  9. package/.claude/skills/review-cycle/SKILL.md +132 -132
  10. package/.claude/skills/review-cycle/phases/review-module.md +4 -4
  11. package/.claude/skills/review-cycle/phases/review-session.md +4 -4
  12. package/.claude/skills/spec-generator/SKILL.md +1 -1
  13. package/.claude/skills/team-designer/phases/02-scaffold-generation.md +1 -1
  14. package/.claude/skills/team-lifecycle-v4/SKILL.md +1 -1
  15. package/.claude/skills/team-review/SKILL.md +1 -1
  16. package/.claude/skills/team-ultra-analyze/SKILL.md +1 -1
  17. package/.claude/skills/workflow-multi-cli-plan/SKILL.md +3 -3
  18. package/.claude/skills/workflow-plan/SKILL.md +1 -1
  19. package/.claude/skills/workflow-plan/phases/03-conflict-resolution.md +2 -2
  20. package/.claude/skills/workflow-plan/phases/05-plan-verify.md +2 -2
  21. package/.claude/skills/workflow-tdd-plan/phases/02-context-gathering.md +3 -3
  22. package/.claude/skills/workflow-tdd-plan/phases/04-conflict-resolution.md +2 -2
  23. package/.claude/skills/workflow-test-fix/SKILL.md +1 -1
  24. package/.claude/skills/workflow-test-fix/phases/02-test-context-gather.md +2 -2
  25. package/.codex/AGENTS.md +16 -0
  26. package/.codex/skills/analyze-with-file/SKILL.md +966 -966
  27. package/.codex/skills/issue-discover/SKILL.md +361 -361
  28. package/.codex/skills/review-cycle/SKILL.md +1 -1
  29. package/.codex/skills/roadmap-with-file/SKILL.md +901 -901
  30. package/.codex/skills/spec-generator/SKILL.md +425 -425
  31. package/.codex/skills/spec-setup/SKILL.md +669 -669
  32. package/.codex/skills/team-designer/phases/02-scaffold-generation.md +1 -1
  33. package/.codex/skills/workflow-test-fix-cycle/SKILL.md +402 -402
  34. package/ccw/dist/tools/index.d.ts.map +1 -1
  35. package/ccw/dist/tools/index.js +2 -0
  36. package/ccw/dist/tools/index.js.map +1 -1
  37. package/ccw/dist/tools/json-builder.d.ts +17 -0
  38. package/ccw/dist/tools/json-builder.d.ts.map +1 -0
  39. package/ccw/dist/tools/json-builder.js +746 -0
  40. package/ccw/dist/tools/json-builder.js.map +1 -0
  41. package/ccw/dist/tools/schema-registry.d.ts +71 -0
  42. package/ccw/dist/tools/schema-registry.d.ts.map +1 -0
  43. package/ccw/dist/tools/schema-registry.js +136 -0
  44. package/ccw/dist/tools/schema-registry.js.map +1 -0
  45. package/package.json +1 -1
  46. package/.claude/skills/team-iterdev/SKILL.md +0 -127
  47. package/.claude/skills/team-iterdev/roles/architect/role.md +0 -65
  48. package/.claude/skills/team-iterdev/roles/coordinator/commands/analyze.md +0 -62
  49. package/.claude/skills/team-iterdev/roles/coordinator/commands/dispatch.md +0 -234
  50. package/.claude/skills/team-iterdev/roles/coordinator/commands/monitor.md +0 -182
  51. package/.claude/skills/team-iterdev/roles/coordinator/role.md +0 -153
  52. package/.claude/skills/team-iterdev/roles/developer/role.md +0 -74
  53. package/.claude/skills/team-iterdev/roles/reviewer/role.md +0 -66
  54. package/.claude/skills/team-iterdev/roles/tester/role.md +0 -88
  55. package/.claude/skills/team-iterdev/specs/pipelines.md +0 -94
  56. package/.claude/skills/team-iterdev/specs/team-config.json +0 -172
  57. package/.codex/prompts/prep-cycle.md +0 -416
  58. package/.codex/prompts/prep-plan.md +0 -371
  59. package/.codex/skills/team-iterdev/SKILL.md +0 -219
  60. package/.codex/skills/team-iterdev/roles/architect/role.md +0 -65
  61. package/.codex/skills/team-iterdev/roles/coordinator/commands/analyze.md +0 -62
  62. package/.codex/skills/team-iterdev/roles/coordinator/commands/dispatch.md +0 -187
  63. package/.codex/skills/team-iterdev/roles/coordinator/commands/monitor.md +0 -227
  64. package/.codex/skills/team-iterdev/roles/coordinator/role.md +0 -193
  65. package/.codex/skills/team-iterdev/roles/developer/role.md +0 -74
  66. package/.codex/skills/team-iterdev/roles/reviewer/role.md +0 -66
  67. package/.codex/skills/team-iterdev/roles/tester/role.md +0 -88
  68. package/.codex/skills/team-iterdev/specs/pipelines.md +0 -94
  69. package/.codex/skills/team-iterdev/specs/team-config.json +0 -172
@@ -1,601 +1,203 @@
1
1
  # CLI Tools Execution Specification
2
2
 
3
- ## Table of Contents
4
- 1. [Configuration Reference](#configuration-reference)
5
- 2. [Tool Selection](#tool-selection)
6
- 3. [Prompt Template](#prompt-template)
7
- 4. [CLI Execution](#cli-execution)
8
- 5. [Auto-Invoke Triggers](#auto-invoke-triggers)
9
- 6. [Best Practices](#best-practices)
3
+ Unified reference for `ccw cli` — runs agent tools (gemini, qwen, codex, claude, opencode) with a shared interface for prompt, mode, model, directory, templates, and session resume.
4
+
5
+ **References**: `~/.claude/cli-tools.json` (tool config), `~/.ccw/templates/cli/` (protocol + prompt templates)
10
6
 
11
7
  ---
12
8
 
13
- ## Configuration Reference
9
+ ## 1. Quick Reference
10
+
11
+ ### Command Syntax
12
+
13
+ ```bash
14
+ ccw cli -p "<PROMPT>" [options]
15
+ ```
16
+
17
+ ### Options
18
+
19
+ | Option | Description | Default |
20
+ |--------|-------------|---------|
21
+ | `-p, --prompt` | **Required**. Prompt text | — |
22
+ | `--tool <name>` | Tool: gemini, qwen, codex, claude, opencode | First enabled in config |
23
+ | `--mode <mode>` | `analysis` (read-only), `write` (create/modify/delete), `review` (codex-only) | `analysis` |
24
+ | `--model <model>` | Model override | Tool's `primaryModel` |
25
+ | `--cd <dir>` | Working directory | Current directory |
26
+ | `--includeDirs <dirs>` | Additional directories (comma-separated) | — |
27
+ | `--rule <template>` | Load protocol + prompt template | — (optional) |
28
+ | `--id <id>` | Execution ID | Auto: `{prefix}-{HHmmss}-{rand4}` |
29
+ | `--resume [id]` | Resume session (last if no id, comma-separated for merge) | — |
30
+
31
+ ### Mode Definition (Authoritative)
32
+
33
+ | Mode | Permission | Auto-Invoke Safe | Use For |
34
+ |------|-----------|------------------|---------|
35
+ | `analysis` | Read-only | Yes | Review, exploration, diagnosis, architecture analysis |
36
+ | `write` | Create/Modify/Delete | No — requires explicit intent | Implementation, bug fixes, refactoring |
37
+ | `review` | Read-only (git-aware) | Yes | **Codex only**. Uncommitted changes, branch diffs, specific commits |
14
38
 
15
- ### Configuration File
39
+ > `--mode` is the **authoritative** permission control for ccw cli. The `MODE:` field inside prompt text is a hint for the agent — both should be consistent, but `--mode` governs actual behavior.
16
40
 
17
- **Path**: `~/.claude/cli-tools.json`
41
+ **Codex review mode**: Target flags (`--uncommitted`, `--base`, `--commit`) are codex-only and mutually exclusive with `-p`.
18
42
 
19
- All tool availability, model selection, and routing are defined in this configuration file.
43
+ ---
44
+
45
+ ## 2. Configuration
20
46
 
21
- ### Configuration Fields
47
+ ### Config File: `~/.claude/cli-tools.json`
22
48
 
23
49
  | Field | Description |
24
50
  |-------|-------------|
25
- | `enabled` | Tool availability status |
26
- | `primaryModel` | Default model for the tool |
51
+ | `enabled` | Tool availability |
52
+ | `primaryModel` | Default model |
27
53
  | `secondaryModel` | Fallback model |
28
- | `tags` | Capability tags for routing |
54
+ | `tags` | Capability tags (for caller-side routing) |
29
55
 
30
56
  ### Tool Types
31
57
 
32
58
  | Type | Usage | Capabilities |
33
59
  |------|-------|--------------|
34
- | `builtin` | `--tool gemini` | Full (analysis + write tools) |
35
- | `cli-wrapper` | `--tool doubao` | Full (analysis + write tools) |
36
- | `api-endpoint` | `--tool g25` | **Analysis only** (no file write tools) |
60
+ | `builtin` | `--tool gemini` | Full (analysis + write) |
61
+ | `cli-wrapper` | `--tool doubao` | Full (analysis + write) |
62
+ | `api-endpoint` | `--tool g25` | **Analysis only** (no file write) |
37
63
 
38
- > **Note**: `api-endpoint` tools only support analysis and code generation responses. They cannot create, modify, or delete files.
64
+ ### Tool Selection
39
65
 
40
- ---
66
+ 1. Explicit `--tool` specified → use it (validate enabled)
67
+ 2. No `--tool` → first enabled tool in config order
41
68
 
42
- ## Tool Selection
69
+ ### Fallback Chain
43
70
 
44
- ### Tag-Based Routing
71
+ Primary model fails → `secondaryModel` → next enabled tool → first enabled (default).
45
72
 
46
- Tools are selected based on **tags** defined in the configuration. Use tags to match task requirements to tool capabilities.
73
+ ---
47
74
 
48
- #### Common Tags
75
+ ## 3. Prompt Construction
49
76
 
50
- | Tag | Use Case |
51
- |-----|----------|
52
- | `analysis` | Code review, architecture analysis, exploration |
53
- | `implementation` | Feature development, bug fixes |
54
- | `documentation` | Doc generation, comments |
55
- | `testing` | Test creation, coverage analysis |
56
- | `refactoring` | Code restructuring |
57
- | `security` | Security audits, vulnerability scanning |
77
+ ### Assembly Order
58
78
 
59
- ### Selection Algorithm
79
+ `ccw cli` builds the final prompt as:
60
80
 
61
- ```
62
- 1. Parse task intent extract required capabilities
63
- 2. Load cli-tools.json get enabled tools with tags
64
- 3. Match tags → filter tools supporting required capabilities
65
- 4. Select tool → choose by priority (explicit > tag-match > default)
66
- 5. Select model → use primaryModel, fallback to secondaryModel
67
- ```
81
+ 1. **Mode protocol** — loaded based on `--mode` (analysis-protocol.md / write-protocol.md)
82
+ 2. **User prompt** the `-p` value
83
+ 3. **Rule template** loaded from `--rule` template name (if specified)
68
84
 
69
- ### Selection Decision Tree
85
+ ### Prompt Template (6 Fields)
70
86
 
71
87
  ```
72
- ┌─ Explicit --tool specified?
73
- │ └─→ YES: Use specified tool (validate enabled)
74
-
75
- └─ NO: Tag-based selection
76
- ├─ Task requires tags?
77
- │ └─→ Match tools with matching tags
78
- │ └─→ Multiple matches? Use first enabled
79
-
80
- └─ No tag match?
81
- └─→ Use default tool (first enabled in config)
82
- ```
83
-
84
- ### Command Structure
85
-
86
- ```bash
87
- # Explicit tool selection
88
- ccw cli -p "<PROMPT>" --tool <tool-id> --mode <analysis|write>
89
-
90
- # Model override
91
- ccw cli -p "<PROMPT>" --tool <tool-id> --model <model-id> --mode <analysis|write>
92
-
93
- # Code review (codex only - review mode and target flags are invalid for other tools)
94
- ccw cli -p "<PROMPT>" --tool codex --mode review
95
- ccw cli --tool codex --mode review --commit <hash>
96
-
97
- # Tag-based auto-selection (future)
98
- ccw cli -p "<PROMPT>" --tags <tag1,tag2> --mode <analysis|write>
88
+ PURPOSE: [goal] + [why] + [success criteria]
89
+ TASK: [step 1] | [step 2] | [step 3]
90
+ MODE: analysis|write
91
+ CONTEXT: @[file patterns] | Memory: [prior work context]
92
+ EXPECTED: [output format] + [quality criteria]
93
+ CONSTRAINTS: [scope limits] | [special requirements]
99
94
  ```
100
95
 
101
- ### Tool Fallback Chain
96
+ - **PURPOSE**: What + Why + Success. Not "Analyze code" but "Identify auth vulnerabilities; success = OWASP Top 10 covered"
97
+ - **TASK**: Specific verbs. Not "Review code" but "Scan for SQL injection | Check XSS | Verify CSRF"
98
+ - **MODE**: Must match `--mode` flag
99
+ - **CONTEXT**: File scope + memory from prior work
100
+ - **EXPECTED**: Deliverable format, not just "Report"
101
+ - **CONSTRAINTS**: Task-specific limits (vs `--rule` which loads generic templates)
102
102
 
103
- When primary tool fails or is unavailable:
104
- 1. Check `secondaryModel` for same tool
105
- 2. Try next enabled tool with matching tags
106
- 3. Fall back to default enabled tool
103
+ ### CONTEXT: File Patterns + Directory
107
104
 
108
- ---
105
+ - `@**/*` — all files in working directory (default)
106
+ - `@src/**/*.ts` — scoped pattern
107
+ - `@../shared/**/*` — sibling directory (**requires `--includeDirs`**)
109
108
 
110
- ## Prompt Template
111
-
112
- ### Universal Prompt Template
109
+ **Rule**: If CONTEXT uses `@../dir/**/*`, must add `--includeDirs ../dir`.
113
110
 
114
111
  ```bash
115
- ccw cli -p "PURPOSE: [what] + [why] + [success criteria] + [constraints/scope]
116
- TASK: [step 1: specific action] [step 2: specific action] • [step 3: specific action]
117
- MODE: [analysis|write]
118
- CONTEXT: @[file patterns] | Memory: [session/tech/module context]
119
- EXPECTED: [deliverable format] + [quality criteria] + [structure requirements]
120
- CONSTRAINTS: [domain constraints]" --tool <tool-id> --mode <analysis|write> --rule <category-template>
112
+ # Cross-directory example
113
+ ccw cli -p "<PROMPT>" --tool gemini --mode analysis \
114
+ --cd "src/auth" --includeDirs "../shared"
121
115
  ```
122
116
 
123
- ### Intent Capture Checklist (Before CLI Execution)
124
-
125
- **⚠️ CRITICAL**: Before executing any CLI command, verify these intent dimensions:
126
-
127
- **Intent Validation Questions**:
128
- - [ ] Is the objective specific and measurable?
129
- - [ ] Are success criteria defined?
130
- - [ ] Is the scope clearly bounded?
131
- - [ ] Are constraints and limitations stated?
132
- - [ ] Is the expected output format clear?
133
- - [ ] Is the action level (read/write) explicit?
134
-
135
- ### Template Structure
136
-
137
- Every command MUST include these fields:
138
-
139
- - **PURPOSE**
140
- - Purpose: Goal + motivation + success
141
- - Components: What + Why + Success Criteria + Constraints
142
- - Bad Example: "Analyze code"
143
- - Good Example: "Identify security vulnerabilities in auth module to pass compliance audit; success = all OWASP Top 10 addressed; scope = src/auth/** only"
144
-
145
- - **TASK**
146
- - Purpose: Actionable steps
147
- - Components: Specific verbs + targets
148
- - Bad Example: "• Review code • Find issues"
149
- - Good Example: "• Scan for SQL injection in query builders • Check XSS in template rendering • Verify CSRF token validation"
150
-
151
- - **MODE**
152
- - Purpose: Permission level
153
- - Components: analysis / write / auto
154
- - Bad Example: (missing)
155
- - Good Example: "analysis" or "write"
156
-
157
- - **CONTEXT**
158
- - Purpose: File scope + history
159
- - Components: File patterns + Memory
160
- - Bad Example: "@**/*"
161
- - Good Example: "@src/auth/**/*.ts @shared/utils/security.ts \| Memory: Previous auth refactoring (WFS-001)"
162
-
163
- - **EXPECTED**
164
- - Purpose: Output specification
165
- - Components: Format + Quality + Structure
166
- - Bad Example: "Report"
167
- - Good Example: "Markdown report with: severity levels (Critical/High/Medium/Low), file:line references, remediation code snippets, priority ranking"
168
-
169
- - **CONSTRAINTS**
170
- - Purpose: Domain-specific constraints
171
- - Components: Scope limits, special requirements, focus areas
172
- - Bad Example: (missing or too vague)
173
- - Good Example: "Focus on authentication | Ignore test files | No breaking changes"
174
-
175
- ### CONTEXT Configuration
176
-
177
- **Format**: `CONTEXT: [file patterns] | Memory: [memory context]`
178
-
179
- #### File Patterns
180
-
181
- - **`@**/*`**: All files (default)
182
- - **`@src/**/*.ts`**: TypeScript in src
183
- - **`@../shared/**/*`**: Sibling directory (requires `--includeDirs`)
184
- - **`@CLAUDE.md`**: Specific file
185
-
186
- #### Memory Context
117
+ ### CONTEXT: Memory
187
118
 
188
119
  Include when building on previous work:
189
120
 
190
- ```bash
191
- # Cross-task reference
121
+ ```
192
122
  Memory: Building on auth refactoring (commit abc123), implementing refresh tokens
193
-
194
- # Cross-module integration
195
- Memory: Integration with auth module, using shared error patterns from @shared/utils/errors.ts
123
+ Memory: Integration with auth module, using shared error patterns
196
124
  ```
197
125
 
198
- **Memory Sources**:
199
- - **Related Tasks**: Previous refactoring, extensions, conflict resolution
200
- - **Tech Stack Patterns**: Framework conventions, security guidelines
201
- - **Cross-Module References**: Integration points, shared utilities, type dependencies
202
-
203
- #### Pattern Discovery Workflow
204
-
205
- For complex requirements, discover files BEFORE CLI execution:
206
-
207
- ```bash
208
- # Step 1: Discover files (choose one method)
209
- # Method A: ACE semantic search (recommended)
210
- mcp__ace-tool__search_context(project_root_path="/path", query="React components with export")
126
+ ### --rule Templates
211
127
 
212
- # Method B: Ripgrep pattern search
213
- rg "export.*Component" --files-with-matches --type ts
128
+ **Universal**: `universal-rigorous-style`, `universal-creative-style`
214
129
 
215
- # Step 2: Build CONTEXT
216
- CONTEXT: @components/Auth.tsx @types/auth.d.ts | Memory: Previous type refactoring
130
+ **Analysis**: `analysis-trace-code-execution`, `analysis-diagnose-bug-root-cause`, `analysis-analyze-code-patterns`, `analysis-analyze-technical-document`, `analysis-review-architecture`, `analysis-review-code-quality`, `analysis-analyze-performance`, `analysis-assess-security-risks`
217
131
 
218
- # Step 3: Execute CLI
219
- ccw cli -p "..." --tool <tool-id> --mode analysis --cd "src"
220
- ```
132
+ **Planning**: `planning-plan-architecture-design`, `planning-breakdown-task-steps`, `planning-design-component-spec`, `planning-plan-migration-strategy`
221
133
 
222
- ### --rule Configuration
134
+ **Development**: `development-implement-feature`, `development-refactor-codebase`, `development-generate-tests`, `development-implement-component-ui`, `development-debug-runtime-issues`
223
135
 
224
- **Use `--rule` option to auto-load templates**:
136
+ ### Complete Example
225
137
 
226
138
  ```bash
227
- ccw cli -p "..." --tool gemini --mode analysis --rule analysis-review-architecture
139
+ ccw cli -p "PURPOSE: Identify OWASP Top 10 vulnerabilities in auth module; success = all critical/high documented with remediation
140
+ TASK: Scan for injection flaws | Check auth bypass vectors | Evaluate session management | Assess data exposure
141
+ MODE: analysis
142
+ CONTEXT: @src/auth/**/* @src/middleware/auth.ts | Memory: Using bcrypt + JWT
143
+ EXPECTED: Severity matrix, file:line references, remediation snippets, priority ranking
144
+ CONSTRAINTS: Focus on authentication | Ignore test files
145
+ " --tool gemini --mode analysis --rule analysis-assess-security-risks --cd "src/auth"
228
146
  ```
229
147
 
230
- ### Mode Protocol References
231
-
232
- **`--rule` auto-loads Protocol based on mode**:
233
- - `--mode analysis` → analysis-protocol.md
234
- - `--mode write` → write-protocol.md
235
-
236
- **Protocol Mapping**:
237
-
238
- - **`analysis`** mode
239
- - Permission: Read-only
240
- - Constraint: No file create/modify/delete
241
-
242
- - **`write`** mode
243
- - Permission: Create/Modify/Delete files
244
- - Constraint: Full workflow execution
245
-
246
- ### Template System
247
-
248
- **Available `--rule` template names**:
249
-
250
- **Universal**:
251
- - `universal-rigorous-style` - Precise tasks
252
- - `universal-creative-style` - Exploratory tasks
253
-
254
- **Analysis**:
255
- - `analysis-trace-code-execution` - Execution tracing
256
- - `analysis-diagnose-bug-root-cause` - Bug diagnosis
257
- - `analysis-analyze-code-patterns` - Code patterns
258
- - `analysis-analyze-technical-document` - Document analysis
259
- - `analysis-review-architecture` - Architecture review
260
- - `analysis-review-code-quality` - Code review
261
- - `analysis-analyze-performance` - Performance analysis
262
- - `analysis-assess-security-risks` - Security assessment
263
-
264
- **Planning**:
265
- - `planning-plan-architecture-design` - Architecture design
266
- - `planning-breakdown-task-steps` - Task breakdown
267
- - `planning-design-component-spec` - Component design
268
- - `planning-plan-migration-strategy` - Migration strategy
269
-
270
- **Development**:
271
- - `development-implement-feature` - Feature implementation
272
- - `development-refactor-codebase` - Code refactoring
273
- - `development-generate-tests` - Test generation
274
- - `development-implement-component-ui` - UI component
275
- - `development-debug-runtime-issues` - Runtime debugging
276
-
277
148
  ---
278
149
 
279
- ## CLI Execution
280
-
281
- ### MODE Options
282
-
283
- - **`analysis`**
284
- - Permission: Read-only
285
- - Use For: Code review, architecture analysis, pattern discovery, exploration
286
- - Specification: Safe for all tools
287
-
288
- - **`write`**
289
- - Permission: Create/Modify/Delete
290
- - Use For: Feature implementation, bug fixes, documentation, code creation, file modifications
291
- - Specification: Requires explicit `--mode write`
292
-
293
- - **`review`**
294
- - Permission: Read-only (code review output)
295
- - Use For: Git-aware code review of uncommitted changes, branch diffs, specific commits
296
- - Specification: **codex only** - uses `codex review` subcommand. Other tools MUST NOT use this mode
297
- - **Constraint**: Target flags (`--uncommitted`, `--base`, `--commit`) are **codex-only** and mutually exclusive with prompt
298
- - With prompt only: `ccw cli -p "Focus on security" --tool codex --mode review` (reviews uncommitted by default)
299
- - With target flag only: `ccw cli --tool codex --mode review --commit abc123` (no prompt allowed)
300
-
301
- ### Command Options
302
-
303
- - **`--tool <tool>`**
304
- - Description: Tool from config (e.g., gemini, qwen, codex)
305
- - Default: First enabled tool in config
306
-
307
- - **`--mode <mode>`**
308
- - Description: **REQUIRED**: analysis, write, review
309
- - Default: **NONE** (must specify)
310
- - Note: `review` mode is **codex-only**. Using `--mode review` with other tools (gemini/qwen/claude) is invalid and should be rejected
311
-
312
- - **`--model <model>`**
313
- - Description: Model override
314
- - Default: Tool's primaryModel from config
315
-
316
- - **`--cd "<path>"`**
317
- - Description: Working directory (quote if path contains spaces)
318
- - Default: current
319
-
320
- - **`--includeDirs "<dirs>"`**
321
- - Description: Additional directories (comma-separated, quote if paths contain spaces)
322
- - Default: none
150
+ ## 4. Execution
323
151
 
324
- - **`--id <id>`**
325
- - Description: Execution ID (recommended, auto-generated if omitted)
326
- - Default: Auto-generated in format `{prefix}-{HHmmss}-{rand4}` (e.g., `gem-143022-x7k2`)
327
- - Prefix mapping: gemini→gem, qwen→qwn, codex→cdx, claude→cld, opencode→opc
328
- - Note: ID is always output to stderr as `[CCW_EXEC_ID=<id>]` for programmatic capture
152
+ ### Execution ID
329
153
 
330
- - **`--resume [id]`**
331
- - Description: Resume previous session
332
- - Default: -
154
+ ID prefix: gemini→`gem`, qwen→`qwn`, codex→`cdx`, claude→`cld`, opencode→`opc`
333
155
 
334
- - **`--rule <template>`**
335
- - Description: Template name, auto-loads protocol + template appended to prompt
336
- - Default: universal-rigorous-style
337
- - Auto-selects protocol based on --mode
338
-
339
- ### Directory Configuration
340
-
341
- #### Working Directory (`--cd`)
342
-
343
- When using `--cd`:
344
- - `@**/*` = Files within working directory tree only
345
- - CANNOT reference parent/sibling via @ alone
346
- - Must use `--includeDirs` for external directories
347
-
348
- #### Include Directories (`--includeDirs`)
349
-
350
- **TWO-STEP requirement for external files**:
351
- 1. Add `--includeDirs` parameter
352
- 2. Reference in CONTEXT with @ patterns
156
+ Output to stderr: `[CCW_EXEC_ID=<id>]`
353
157
 
354
158
  ```bash
355
- # Single directory
356
- ccw cli -p "CONTEXT: @**/* @../shared/**/*" --tool <tool-id> --mode analysis --cd "src/auth" --includeDirs "../shared"
357
-
358
- # Multiple directories
359
- ccw cli -p "..." --tool <tool-id> --mode analysis --cd "src/auth" --includeDirs "../shared,../types,../utils"
159
+ ccw cli -p "<PROMPT>" --tool gemini --mode analysis # auto-ID: gem-143022-a7f2
160
+ ccw cli -p "<PROMPT>" --tool gemini --mode write --id my-task-1 # custom ID
360
161
  ```
361
162
 
362
- **Rule**: If CONTEXT contains `@../dir/**/*`, MUST include `--includeDirs ../dir`
363
-
364
- **Benefits**: Excludes unrelated directories, reduces token usage
365
-
366
163
  ### Session Resume
367
164
 
368
- **When to Use**:
369
- - Multi-round planning (analysis → planning → implementation)
370
- - Multi-model collaboration (tool A → tool B on same topic)
371
- - Topic continuity (building on previous findings)
372
-
373
- **Usage**:
374
-
375
165
  ```bash
376
- ccw cli -p "Continue analyzing" --tool <tool-id> --mode analysis --resume # Resume last
377
- ccw cli -p "Fix issues found" --tool <tool-id> --mode write --resume <id> # Resume specific
378
- ccw cli -p "Merge findings" --tool <tool-id> --mode analysis --resume <id1>,<id2> # Merge multiple
166
+ ccw cli -p "<PROMPT>" --tool gemini --resume # last session
167
+ ccw cli -p "<PROMPT>" --tool gemini --mode write --resume <id> # specific
168
+ ccw cli -p "<PROMPT>" --tool gemini --resume <id1>,<id2> # merge multiple
379
169
  ```
380
170
 
381
- - **`--resume`**: Last session
382
- - **`--resume <id>`**: Specific session
383
- - **`--resume <id1>,<id2>`**: Merge sessions (comma-separated)
384
-
385
- **Context Assembly** (automatic):
386
- ```
387
- === PREVIOUS CONVERSATION ===
388
- USER PROMPT: [Previous prompt]
389
- ASSISTANT RESPONSE: [Previous output]
390
- === CONTINUATION ===
391
- [Your new prompt]
392
- ```
171
+ Resume auto-assembles previous conversation context. Warning emitted when context exceeds 32KB.
393
172
 
394
173
  ### Subcommands
395
174
 
396
- #### `show` — List All Executions
397
-
398
- ```bash
399
- ccw cli show # Active + recent completed executions
400
- ccw cli show --all # Include full history
401
- ```
402
-
403
- Displays a unified table of running and recent executions with: ID, Tool, Mode, Status, Duration, Prompt Preview.
404
-
405
- #### `watch <id>` — Stream Execution Output
406
-
407
- ```bash
408
- ccw cli watch <id> # Stream until completion (output to stderr)
409
- ccw cli watch <id> --timeout 120 # Auto-exit after 120 seconds
410
- ```
411
-
412
- Behavior:
413
- - Output written to **stderr** (does not pollute stdout)
414
- - Exit code: 0 = success, 1 = error, 2 = timeout
415
- - Callers can `ccw cli watch <id> 2>/dev/null` to silently wait
416
-
417
- #### `output <id>` — Get Execution Output
418
-
419
- ```bash
420
- ccw cli output <id> # Final result only (default)
421
- ccw cli output <id> --verbose # Full metadata + raw output
422
- ccw cli output <id> --raw # Raw stdout (for piping)
423
- ```
424
-
425
- Default returns `finalOutput > parsedOutput > stdout` — agent's final response text only.
426
- `--verbose` shows full metadata (ID, turn, status, project) plus raw stdout/stderr.
427
-
428
- #### ID Workflow Example
429
-
430
- ```bash
431
- # Execute with auto-generated ID
432
- ccw cli -p "analyze code" --tool gemini --mode analysis
433
- # stderr outputs: [CCW_EXEC_ID=gem-143022-x7k2]
434
-
435
- # Execute with custom ID
436
- ccw cli -p "implement feature" --tool gemini --mode write --id my-task-1
437
- # stderr outputs: [CCW_EXEC_ID=my-task-1]
438
-
439
- # Check status
440
- ccw cli show
441
-
442
- # Watch running execution
443
- ccw cli watch gem-143022-x7k2
444
-
445
- # Get final result
446
- ccw cli output gem-143022-x7k2
447
-
448
- # Capture ID programmatically
449
- EXEC_ID=$(ccw cli -p "test" --tool gemini --mode analysis 2>&1 | grep -oP 'CCW_EXEC_ID=\K[^\]]+')
450
- ccw cli output $EXEC_ID
451
- ```
452
-
453
- ### Command Examples
454
-
455
- #### Task-Type Specific Templates
456
-
457
- **Analysis Task** (Security Audit):
458
- ```bash
459
- ccw cli -p "PURPOSE: Identify OWASP Top 10 vulnerabilities in authentication module to pass security audit; success = all critical/high issues documented with remediation
460
- TASK: • Scan for injection flaws (SQL, command, LDAP) • Check authentication bypass vectors • Evaluate session management • Assess sensitive data exposure
461
- MODE: analysis
462
- CONTEXT: @src/auth/**/* @src/middleware/auth.ts | Memory: Using bcrypt for passwords, JWT for sessions
463
- EXPECTED: Security report with: severity matrix, file:line references, CVE mappings where applicable, remediation code snippets prioritized by risk
464
- CONSTRAINTS: Focus on authentication | Ignore test files
465
- " --tool gemini --mode analysis --rule analysis-assess-security-risks --cd "src/auth"
466
- ```
467
-
468
- **Implementation Task** (New Feature):
469
175
  ```bash
470
- ccw cli -p "PURPOSE: Implement rate limiting for API endpoints to prevent abuse; must be configurable per-endpoint; backward compatible with existing clients
471
- TASK: Create rate limiter middleware with sliding window • Implement per-route configuration • Add Redis backend for distributed state • Include bypass for internal services
472
- MODE: write
473
- CONTEXT: @src/middleware/**/* @src/config/**/* | Memory: Using Express.js, Redis already configured, existing middleware pattern in auth.ts
474
- EXPECTED: Production-ready code with: TypeScript types, unit tests, integration test, configuration example, migration guide
475
- CONSTRAINTS: Follow existing middleware patterns | No breaking changes
476
- " --tool gemini --mode write --rule development-implement-feature
477
- ```
478
-
479
- **Bug Fix Task**:
480
- ```bash
481
- ccw cli -p "PURPOSE: Fix memory leak in WebSocket connection handler causing server OOM after 24h; root cause must be identified before any fix
482
- TASK: • Trace connection lifecycle from open to close • Identify event listener accumulation • Check cleanup on disconnect • Verify garbage collection eligibility
483
- MODE: analysis
484
- CONTEXT: @src/websocket/**/* @src/services/connection-manager.ts | Memory: Using ws library, ~5000 concurrent connections in production
485
- EXPECTED: Root cause analysis with: memory profile, leak source (file:line), fix recommendation with code, verification steps
486
- CONSTRAINTS: Focus on resource cleanup
487
- " --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause --cd "src"
176
+ ccw cli show # active + recent executions
177
+ ccw cli show --all # full history
178
+ ccw cli watch <id> # stream until completion (stderr)
179
+ ccw cli output <id> # final assistant output
180
+ ccw cli output <id> --verbose # full metadata + output
181
+ ccw cli output <id> --raw # raw stdout (for piping)
488
182
  ```
489
183
 
490
- **Refactoring Task**:
491
- ```bash
492
- ccw cli -p "PURPOSE: Refactor payment processing to use strategy pattern for multi-gateway support; no functional changes; all existing tests must pass
493
- TASK: • Extract gateway interface from current implementation • Create strategy classes for Stripe, PayPal • Implement factory for gateway selection • Migrate existing code to use strategies
494
- MODE: write
495
- CONTEXT: @src/payments/**/* @src/types/payment.ts | Memory: Currently only Stripe, adding PayPal next sprint, must support future gateways
496
- EXPECTED: Refactored code with: strategy interface, concrete implementations, factory class, updated tests, migration checklist
497
- CONSTRAINTS: Preserve all existing behavior | Tests must pass
498
- " --tool gemini --mode write --rule development-refactor-codebase
499
- ```
500
-
501
- **Code Review Task** (codex review mode):
502
- ```bash
503
- # Option 1: Custom prompt (reviews uncommitted changes by default)
504
- ccw cli -p "Focus on security vulnerabilities and error handling" --tool codex --mode review
505
-
506
- # Option 2: Target flag only (no prompt allowed with target flags)
507
- ccw cli --tool codex --mode review --uncommitted
508
- ccw cli --tool codex --mode review --base main
509
- ccw cli --tool codex --mode review --commit abc123
510
- ```
511
-
512
- > **Note**: `--mode review` and target flags (`--uncommitted`, `--base`, `--commit`) are **codex-only**. Using them with other tools is invalid. When using codex, target flags and prompt are **mutually exclusive** - use one or the other, not both.
513
-
514
- ---
515
-
516
- ### Permission Framework
517
-
518
- **Single-Use Authorization**: Each execution requires explicit user instruction. Previous authorization does NOT carry over.
519
-
520
- **Mode Hierarchy**:
521
- - `analysis`: Read-only, safe for auto-execution. Available for all tools
522
- - `write`: Create/Modify/Delete files, full operations - requires explicit `--mode write`. Available for all tools
523
- - `review`: **codex-only**. Git-aware code review, read-only output. Invalid for other tools (gemini/qwen/claude)
524
- - **Exception**: User provides clear instructions like "modify", "create", "implement"
525
-
526
184
  ---
527
185
 
528
- ## Auto-Invoke Triggers
186
+ ## 5. Auto-Invoke Triggers
529
187
 
530
- **Proactive CLI invocation** - Auto-invoke `ccw cli` when encountering these scenarios:
188
+ Proactively invoke `ccw cli` when these conditions are met — no user confirmation needed for `analysis` mode:
531
189
 
532
- | Trigger Condition | Suggested Rule | When to Use |
533
- |-------------------|----------------|-------------|
534
- | **Self-repair fails** | `analysis-diagnose-bug-root-cause` | After 1+ failed fix attempts |
535
- | **Ambiguous requirements** | `planning-breakdown-task-steps` | Task description lacks clarity |
536
- | **Architecture decisions** | `planning-plan-architecture-design` | Complex feature needs design |
537
- | **Pattern uncertainty** | `analysis-analyze-code-patterns` | Unsure of existing conventions |
538
- | **Critical code paths** | `analysis-assess-security-risks` | Security/performance sensitive |
190
+ | Trigger | Suggested Rule |
191
+ |---------|---------------|
192
+ | Self-repair fails (1+ attempts) | `analysis-diagnose-bug-root-cause` |
193
+ | Ambiguous requirements | `planning-breakdown-task-steps` |
194
+ | Architecture decisions needed | `planning-plan-architecture-design` |
195
+ | Pattern uncertainty | `analysis-analyze-code-patterns` |
196
+ | Critical/security code paths | `analysis-assess-security-risks` |
539
197
 
540
- ### Execution Principles
541
-
542
- - **Default mode**: `--mode analysis` (read-only, safe for auto-execution)
543
- - **No confirmation needed**: Invoke proactively when triggers match
544
- - **Wait for results**: Complete analysis before next action
545
- - **Tool selection**: Use context-appropriate tool or fallback chain (`gemini` → `qwen` → `codex`)
546
- - **Rule flexibility**: Suggested rules are guidelines, not requirements - choose the most appropriate template for the situation
547
-
548
- ### Example: Bug Fix with Auto-Invoke
549
-
550
- ```bash
551
- # After 1+ failed fix attempts, auto-invoke root cause analysis
552
- ccw cli -p "PURPOSE: Identify root cause of [bug description]; success = actionable fix strategy
553
- TASK: • Trace execution flow • Identify failure point • Analyze state at failure • Determine fix approach
554
- MODE: analysis
555
- CONTEXT: @src/module/**/* | Memory: Previous fix attempts failed at [location]
556
- EXPECTED: Root cause analysis with: failure mechanism, stack trace interpretation, fix recommendation with code
557
- CONSTRAINTS: Focus on [specific area]
558
- " --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause
559
- ```
560
-
561
- ---
198
+ ### Principles
562
199
 
563
- ## Best Practices
564
-
565
- ### Core Principles
566
-
567
- - **Configuration-driven** - All tool selection from `cli-tools.json`
568
- - **Tag-based routing** - Match task requirements to tool capabilities
569
- - **Use tools early and often** - Tools are faster and more thorough
570
- - **Unified CLI** - Always use `ccw cli -p` for consistent parameter handling
571
- - **Default mode is analysis** - Omit `--mode` for read-only operations, explicitly use `--mode write` for file modifications
572
- - **Use `--rule` for templates** - Auto-loads protocol + template appended to prompt
573
- - **Write protection** - Require EXPLICIT `--mode write` for file operations
574
-
575
- ### Workflow Principles
576
-
577
- - **Use CCW unified interface** for all executions
578
- - **Always include template** - Use `--rule <template-name>` to load templates
579
- - **Be specific** - Clear PURPOSE, TASK, EXPECTED fields
580
- - **Include constraints** - File patterns, scope in CONSTRAINTS
581
- - **Leverage memory context** when building on previous work
582
- - **Discover patterns first** - Use rg/MCP before CLI execution
583
- - **Default to full context** - Use `@**/*` unless specific files needed
584
-
585
- ### Planning Checklist
586
-
587
- - [ ] **Purpose defined** - Clear goal and intent
588
- - [ ] **Mode selected** - `--mode analysis|write|review`
589
- - [ ] **Context gathered** - File references + memory (default `@**/*`)
590
- - [ ] **Directory navigation** - `--cd` and/or `--includeDirs`
591
- - [ ] **Tool selected** - Explicit `--tool` or tag-based auto-selection
592
- - [ ] **Rule template** - `--rule <template-name>` loads template
593
- - [ ] **Constraints** - Domain constraints in CONSTRAINTS field
594
-
595
- ### Execution Workflow
596
-
597
- 1. **Load configuration** - Read `cli-tools.json` for available tools
598
- 2. **Match by tags** - Select tool based on task requirements
599
- 3. **Validate enabled** - Ensure selected tool is enabled
600
- 4. **Execute with mode** - Always specify `--mode analysis|write|review`
601
- 5. **Fallback gracefully** - Use secondary model or next matching tool on failure
200
+ - Default `--mode analysis` (safe, read-only)
201
+ - Wait for results before next action
202
+ - Tool fallback: `gemini` → `qwen` → `codex`
203
+ - Rule suggestions are guidelines — choose the best fit