claude-code-workflow 7.2.29 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/.ccw/workflows/cli-templates/schemas/plan-overview-base-schema.json +2 -2
  2. package/.ccw/workflows/cli-templates/schemas/task-schema.json +14 -7
  3. package/.claude/agents/action-planning-agent.md +7 -4
  4. package/.claude/agents/cli-explore-agent.md +77 -63
  5. package/.claude/agents/cli-lite-planning-agent.md +11 -10
  6. package/.claude/agents/issue-plan-agent.md +421 -426
  7. package/.claude/commands/workflow/spec/setup.md +1 -1
  8. package/.claude/commands/workflow-skill.md +130 -0
  9. package/.claude/skills/ccw-chain/SKILL.md +92 -0
  10. package/.claude/skills/ccw-chain/chains/ccw-cycle.json +31 -0
  11. package/.claude/skills/ccw-chain/chains/ccw-exploration.json +58 -0
  12. package/.claude/skills/ccw-chain/chains/ccw-issue.json +44 -0
  13. package/.claude/skills/ccw-chain/chains/ccw-lightweight.json +71 -0
  14. package/.claude/skills/ccw-chain/chains/ccw-main.json +65 -0
  15. package/.claude/skills/ccw-chain/chains/ccw-standard.json +51 -0
  16. package/.claude/skills/ccw-chain/chains/ccw-team.json +15 -0
  17. package/.claude/skills/ccw-chain/chains/ccw-with-file.json +47 -0
  18. package/.claude/skills/ccw-chain/specs/auto-mode.md +47 -0
  19. package/.claude/skills/chain-loader/SKILL.md +78 -0
  20. package/.claude/skills/chain-loader/phases/01-analyze-skill.md +53 -0
  21. package/.claude/skills/chain-loader/phases/02-design-graph.md +73 -0
  22. package/.claude/skills/chain-loader/phases/03-generate-validate.md +75 -0
  23. package/.claude/skills/chain-loader/specs/chain-schema.md +126 -0
  24. package/.claude/skills/chain-loader/specs/design-patterns.md +99 -0
  25. package/.claude/skills/chain-loader/templates/chain-json.md +63 -0
  26. package/.claude/skills/review-cycle/phases/review-module.md +764 -764
  27. package/.claude/skills/review-cycle/phases/review-session.md +775 -775
  28. package/.claude/skills/workflow-multi-cli-plan/SKILL.md +2 -2
  29. package/.claude/skills/workflow-plan/SKILL.md +1 -0
  30. package/.claude/skills/workflow-plan/phases/01-session-discovery.md +19 -2
  31. package/.claude/skills/workflow-plan/phases/02-context-gathering.md +2 -2
  32. package/.claude/skills/workflow-plan/phases/03-conflict-resolution.md +422 -422
  33. package/.claude/skills/workflow-plan/phases/04-task-generation.md +9 -1
  34. package/.claude/skills/workflow-plan/phases/05-plan-verify.md +395 -395
  35. package/.claude/skills/workflow-tdd-plan/phases/02-context-gathering.md +407 -407
  36. package/.claude/skills/workflow-tdd-plan/phases/04-conflict-resolution.md +426 -426
  37. package/.claude/skills/workflow-test-fix/phases/02-test-context-gather.md +493 -493
  38. package/.codex/skills/analyze-with-file/SKILL.md +383 -134
  39. package/.codex/skills/brainstorm/SKILL.md +3 -3
  40. package/.codex/skills/brainstorm-with-file/SKILL.md +208 -88
  41. package/.codex/skills/clean/SKILL.md +1 -1
  42. package/.codex/skills/csv-wave-pipeline/SKILL.md +2 -2
  43. package/.codex/skills/investigate/orchestrator.md +24 -0
  44. package/.codex/skills/issue-discover/SKILL.md +374 -361
  45. package/.codex/skills/issue-discover/phases/01-issue-new.md +1 -1
  46. package/.codex/skills/issue-discover/phases/02-discover.md +2 -2
  47. package/.codex/skills/issue-discover/phases/03-discover-by-prompt.md +1 -1
  48. package/.codex/skills/issue-discover/phases/04-quick-execute.md +2 -2
  49. package/.codex/skills/parallel-dev-cycle/SKILL.md +44 -37
  50. package/.codex/skills/project-documentation-workflow/SKILL.md +1 -1
  51. package/.codex/skills/review-cycle/SKILL.md +31 -12
  52. package/.codex/skills/roadmap-with-file/SKILL.md +141 -133
  53. package/.codex/skills/security-audit/orchestrator.md +29 -0
  54. package/.codex/skills/session-sync/SKILL.md +1 -1
  55. package/.codex/skills/ship/orchestrator.md +24 -0
  56. package/.codex/skills/spec-add/SKILL.md +5 -5
  57. package/.codex/skills/spec-generator/SKILL.md +33 -2
  58. package/.codex/skills/spec-generator/phases/01-5-requirement-clarification.md +3 -3
  59. package/.codex/skills/spec-generator/phases/01-discovery.md +1 -1
  60. package/.codex/skills/spec-generator/phases/02-product-brief.md +1 -1
  61. package/.codex/skills/spec-generator/phases/03-requirements.md +1 -1
  62. package/.codex/skills/spec-generator/phases/04-architecture.md +1 -1
  63. package/.codex/skills/spec-generator/phases/05-epics-stories.md +1 -1
  64. package/.codex/skills/spec-generator/phases/06-readiness-check.md +1 -1
  65. package/.codex/skills/spec-generator/phases/07-issue-export.md +1 -1
  66. package/.codex/skills/spec-setup/SKILL.md +669 -669
  67. package/.codex/skills/team-arch-opt/specs/team-config.json +1 -1
  68. package/.codex/skills/team-brainstorm/SKILL.md +259 -259
  69. package/.codex/skills/team-coordinate/SKILL.md +359 -359
  70. package/.codex/skills/team-coordinate/roles/coordinator/commands/monitor.md +1 -1
  71. package/.codex/skills/team-designer/SKILL.md +27 -1
  72. package/.codex/skills/team-designer/phases/01-requirements-analysis.md +2 -2
  73. package/.codex/skills/team-designer/phases/02-scaffold-generation.md +1 -1
  74. package/.codex/skills/team-designer/phases/04-validation.md +1 -1
  75. package/.codex/skills/team-executor/SKILL.md +218 -218
  76. package/.codex/skills/team-frontend/SKILL.md +227 -227
  77. package/.codex/skills/team-frontend-debug/SKILL.md +278 -278
  78. package/.codex/skills/team-frontend-debug/roles/coordinator/commands/analyze.md +2 -2
  79. package/.codex/skills/team-interactive-craft/SKILL.md +220 -220
  80. package/.codex/skills/team-interactive-craft/roles/coordinator/role.md +209 -209
  81. package/.codex/skills/team-issue/SKILL.md +269 -269
  82. package/.codex/skills/team-issue/roles/coordinator/role.md +1 -1
  83. package/.codex/skills/team-lifecycle-v4/SKILL.md +305 -305
  84. package/.codex/skills/team-motion-design/SKILL.md +222 -222
  85. package/.codex/skills/team-motion-design/roles/coordinator/role.md +210 -210
  86. package/.codex/skills/team-perf-opt/SKILL.md +258 -258
  87. package/.codex/skills/team-perf-opt/specs/team-config.json +1 -1
  88. package/.codex/skills/team-planex/SKILL.md +216 -216
  89. package/.codex/skills/team-quality-assurance/SKILL.md +229 -229
  90. package/.codex/skills/team-review/SKILL.md +227 -227
  91. package/.codex/skills/team-roadmap-dev/SKILL.md +238 -238
  92. package/.codex/skills/team-roadmap-dev/roles/coordinator/commands/roadmap-discuss.md +5 -5
  93. package/.codex/skills/team-tech-debt/SKILL.md +206 -206
  94. package/.codex/skills/team-tech-debt/roles/coordinator/commands/monitor.md +1 -1
  95. package/.codex/skills/team-testing/SKILL.md +237 -237
  96. package/.codex/skills/team-ui-polish/SKILL.md +218 -218
  97. package/.codex/skills/team-ui-polish/roles/coordinator/role.md +213 -213
  98. package/.codex/skills/team-uidesign/SKILL.md +219 -219
  99. package/.codex/skills/team-uidesign/roles/coordinator/role.md +2 -2
  100. package/.codex/skills/team-ultra-analyze/SKILL.md +260 -260
  101. package/.codex/skills/team-ultra-analyze/roles/coordinator/commands/monitor.md +1 -1
  102. package/.codex/skills/team-ultra-analyze/roles/coordinator/role.md +1 -1
  103. package/.codex/skills/team-ux-improve/SKILL.md +227 -227
  104. package/.codex/skills/team-ux-improve/roles/coordinator/role.md +1 -1
  105. package/.codex/skills/team-ux-improve/specs/team-config.json +1 -1
  106. package/.codex/skills/team-visual-a11y/SKILL.md +319 -319
  107. package/.codex/skills/team-visual-a11y/roles/coordinator/role.md +213 -213
  108. package/.codex/skills/workflow-execute/SKILL.md +5 -5
  109. package/.codex/skills/workflow-lite-planex/SKILL.md +3 -3
  110. package/.codex/skills/workflow-plan/SKILL.md +3 -3
  111. package/.codex/skills/workflow-tdd-plan/SKILL.md +4 -4
  112. package/.codex/skills/workflow-test-fix-cycle/SKILL.md +403 -402
  113. package/README.md +14 -0
  114. package/ccw/dist/cli.d.ts.map +1 -1
  115. package/ccw/dist/cli.js +16 -0
  116. package/ccw/dist/cli.js.map +1 -1
  117. package/ccw/dist/commands/chain-loader.d.ts +2 -0
  118. package/ccw/dist/commands/chain-loader.d.ts.map +1 -0
  119. package/ccw/dist/commands/chain-loader.js +11 -0
  120. package/ccw/dist/commands/chain-loader.js.map +1 -0
  121. package/ccw/dist/commands/install.d.ts.map +1 -1
  122. package/ccw/dist/commands/install.js +52 -1
  123. package/ccw/dist/commands/install.js.map +1 -1
  124. package/ccw/dist/commands/launcher.d.ts +2 -0
  125. package/ccw/dist/commands/launcher.d.ts.map +1 -0
  126. package/ccw/dist/commands/launcher.js +434 -0
  127. package/ccw/dist/commands/launcher.js.map +1 -0
  128. package/ccw/dist/core/routes/litellm-api-routes.d.ts.map +1 -1
  129. package/ccw/dist/core/routes/litellm-api-routes.js +0 -23
  130. package/ccw/dist/core/routes/litellm-api-routes.js.map +1 -1
  131. package/ccw/dist/tools/chain-loader.d.ts +10 -0
  132. package/ccw/dist/tools/chain-loader.d.ts.map +1 -0
  133. package/ccw/dist/tools/chain-loader.js +1054 -0
  134. package/ccw/dist/tools/chain-loader.js.map +1 -0
  135. package/ccw/dist/tools/index.d.ts.map +1 -1
  136. package/ccw/dist/tools/index.js +2 -0
  137. package/ccw/dist/tools/index.js.map +1 -1
  138. package/ccw/dist/tools/json-builder.js +20 -0
  139. package/ccw/dist/tools/json-builder.js.map +1 -1
  140. package/ccw/dist/tools/skill-context-loader.d.ts.map +1 -1
  141. package/ccw/dist/tools/skill-context-loader.js +12 -26
  142. package/ccw/dist/tools/skill-context-loader.js.map +1 -1
  143. package/ccw/dist/types/chain-types.d.ts +112 -0
  144. package/ccw/dist/types/chain-types.d.ts.map +1 -0
  145. package/ccw/dist/types/chain-types.js +5 -0
  146. package/ccw/dist/types/chain-types.js.map +1 -0
  147. package/ccw/dist/utils/chain-visualizer.d.ts +13 -0
  148. package/ccw/dist/utils/chain-visualizer.d.ts.map +1 -0
  149. package/ccw/dist/utils/chain-visualizer.js +164 -0
  150. package/ccw/dist/utils/chain-visualizer.js.map +1 -0
  151. package/ccw/scripts/prepublish-clean.mjs +0 -1
  152. package/package.json +1 -3
  153. package/.claude/commands/cli/cli-init.md +0 -441
  154. package/.claude/commands/cli/codex-review.md +0 -361
  155. package/.claude/commands/flow-create.md +0 -663
  156. package/.claude/skills/team-edict.zip +0 -0
  157. package/ccw-litellm/README.md +0 -180
  158. package/ccw-litellm/pyproject.toml +0 -35
  159. package/ccw-litellm/src/ccw_litellm/__init__.py +0 -47
  160. package/ccw-litellm/src/ccw_litellm/cli.py +0 -108
  161. package/ccw-litellm/src/ccw_litellm/clients/__init__.py +0 -12
  162. package/ccw-litellm/src/ccw_litellm/clients/litellm_embedder.py +0 -270
  163. package/ccw-litellm/src/ccw_litellm/clients/litellm_llm.py +0 -198
  164. package/ccw-litellm/src/ccw_litellm/config/__init__.py +0 -22
  165. package/ccw-litellm/src/ccw_litellm/config/loader.py +0 -343
  166. package/ccw-litellm/src/ccw_litellm/config/models.py +0 -162
  167. package/ccw-litellm/src/ccw_litellm/interfaces/__init__.py +0 -14
  168. package/ccw-litellm/src/ccw_litellm/interfaces/embedder.py +0 -52
  169. package/ccw-litellm/src/ccw_litellm/interfaces/llm.py +0 -45
@@ -1,764 +1,764 @@
1
- # Workflow Review-Module-Cycle Command
2
-
3
- ## Quick Start
4
-
5
- ```bash
6
- # Review specific module (all 7 dimensions)
7
- /workflow:review-module-cycle src/auth/**
8
-
9
- # Review multiple modules
10
- /workflow:review-module-cycle src/auth/**,src/payment/**
11
-
12
- # Review with custom dimensions
13
- /workflow:review-module-cycle src/payment/** --dimensions=security,architecture,quality
14
-
15
- # Review specific files
16
- /workflow:review-module-cycle src/payment/processor.ts,src/payment/validator.ts
17
- ```
18
-
19
- **Review Scope**: Specified modules/files only (independent of git history)
20
- **Session Requirement**: Auto-creates workflow session via `/workflow:session:start`
21
- **Output Directory**: `.workflow/active/WFS-{session-id}/.review/` (session-based)
22
- **Default Dimensions**: Security, Architecture, Quality, Action-Items, Performance, Maintainability, Best-Practices
23
- **Max Iterations**: 3 (adjustable via --max-iterations)
24
- **Default Iterations**: 1 (deep-dive runs once; use --max-iterations=0 to skip)
25
- **CLI Tools**: Gemini → Qwen → Codex (fallback chain)
26
-
27
- ## What & Why
28
-
29
- ### Core Concept
30
- Independent multi-dimensional code review orchestrator with **hybrid parallel-iterative execution** for comprehensive quality assessment of **specific modules or files**.
31
-
32
- **Review Scope**:
33
- - **Module-based**: Reviews specified file patterns (e.g., `src/auth/**`, `*.ts`)
34
- - **Session-integrated**: Runs within workflow session context for unified tracking
35
- - **Output location**: `.review/` subdirectory within active session
36
-
37
- **vs Session Review**:
38
- - **Session Review** (`review-session-cycle`): Reviews git changes within a workflow session
39
- - **Module Review** (`review-module-cycle`): Reviews any specified code paths, regardless of git history
40
- - **Common output**: Both use same `.review/` directory structure within session
41
-
42
- ### Value Proposition
43
- 1. **Module-Focused Review**: Target specific code areas independent of git history
44
- 2. **Session-Integrated**: Review results tracked within workflow session for unified management
45
- 3. **Comprehensive Coverage**: Same 7 specialized dimensions as session review
46
- 4. **Intelligent Prioritization**: Automatic identification of critical issues and cross-cutting concerns
47
- 5. **Unified Archive**: Review results archived with session for historical reference
48
-
49
- ### Orchestrator Boundary (CRITICAL)
50
- - **ONLY command** for independent multi-dimensional module review
51
- - Manages: dimension coordination, aggregation, iteration control, progress tracking
52
- - Delegates: Code exploration and analysis to @cli-explore-agent, dimension-specific reviews via Deep Scan mode
53
-
54
- ## How It Works
55
-
56
- ### Execution Flow
57
-
58
- ```
59
- Phase 1: Discovery & Initialization
60
- └─ Resolve file patterns, validate paths, initialize state, create output structure
61
-
62
- Phase 2: Parallel Reviews (for each dimension)
63
- ├─ Launch 7 review agents simultaneously
64
- ├─ Each executes CLI analysis via Gemini/Qwen on specified files
65
- ├─ Generate dimension JSON + markdown reports
66
- └─ Update review-progress.json
67
-
68
- Phase 3: Aggregation
69
- ├─ Load all dimension JSON files
70
- ├─ Calculate severity distribution (critical/high/medium/low)
71
- ├─ Identify cross-cutting concerns (files in 3+ dimensions)
72
- └─ Decision:
73
- ├─ Critical findings OR high > 5 OR critical files → Phase 4 (Iterate)
74
- └─ Else → Phase 5 (Complete)
75
-
76
- Phase 4: Iterative Deep-Dive (optional)
77
- ├─ Select critical findings (max 5 per iteration)
78
- ├─ Launch deep-dive agents for root cause analysis
79
- ├─ Generate remediation plans with impact assessment
80
- ├─ Re-assess severity based on analysis
81
- └─ Loop until no critical findings OR max iterations
82
-
83
- Phase 5: Completion
84
- └─ Finalize review-progress.json
85
- ```
86
-
87
- ### Agent Roles
88
-
89
- | Agent | Responsibility |
90
- |-------|---------------|
91
- | **Orchestrator** | Phase control, path resolution, state management, aggregation logic, iteration control |
92
- | **@cli-explore-agent** (Review) | Execute dimension-specific code analysis via Deep Scan mode, generate findings JSON with dual-source strategy (Bash + Gemini), create structured analysis reports |
93
- | **@cli-explore-agent** (Deep-dive) | Focused root cause analysis using dependency mapping, remediation planning with architectural insights, impact assessment, severity re-assessment |
94
-
95
- ## Enhanced Features
96
-
97
- ### 1. Review Dimensions Configuration
98
-
99
- **7 Specialized Dimensions** with priority-based allocation:
100
-
101
- | Dimension | Template | Priority | Timeout |
102
- |-----------|----------|----------|---------|
103
- | **Security** | 03-assess-security-risks.txt | 1 (Critical) | 60min |
104
- | **Architecture** | 02-review-architecture.txt | 2 (High) | 60min |
105
- | **Quality** | 02-review-code-quality.txt | 3 (Medium) | 40min |
106
- | **Action-Items** | 02-analyze-code-patterns.txt | 2 (High) | 40min |
107
- | **Performance** | 03-analyze-performance.txt | 3 (Medium) | 60min |
108
- | **Maintainability** | 02-review-code-quality.txt* | 3 (Medium) | 40min |
109
- | **Best-Practices** | 03-review-quality-standards.txt | 3 (Medium) | 40min |
110
-
111
- *Custom focus: "Assess technical debt and maintainability"
112
-
113
- **Category Definitions by Dimension**:
114
-
115
- ```javascript
116
- const CATEGORIES = {
117
- security: ['injection', 'authentication', 'authorization', 'encryption', 'input-validation', 'access-control', 'data-exposure'],
118
- architecture: ['coupling', 'cohesion', 'layering', 'dependency', 'pattern-violation', 'scalability', 'separation-of-concerns'],
119
- quality: ['code-smell', 'duplication', 'complexity', 'naming', 'error-handling', 'testability', 'readability'],
120
- 'action-items': ['requirement-coverage', 'acceptance-criteria', 'documentation', 'deployment-readiness', 'missing-functionality'],
121
- performance: ['n-plus-one', 'inefficient-query', 'memory-leak', 'blocking-operation', 'caching', 'resource-usage'],
122
- maintainability: ['technical-debt', 'magic-number', 'long-method', 'large-class', 'dead-code', 'commented-code'],
123
- 'best-practices': ['convention-violation', 'anti-pattern', 'deprecated-api', 'missing-validation', 'inconsistent-style']
124
- };
125
- ```
126
-
127
- ### 2. Path Pattern Resolution
128
-
129
- **Syntax Rules**:
130
- - All paths are **relative** from project root (e.g., `src/auth/**` not `/src/auth/**`)
131
- - Multiple patterns: comma-separated, **no spaces** (e.g., `src/auth/**,src/payment/**`)
132
- - Glob and specific files can be mixed (e.g., `src/auth/**,src/config.ts`)
133
-
134
- **Supported Patterns**:
135
- | Pattern Type | Example | Description |
136
- |--------------|---------|-------------|
137
- | Glob directory | `src/auth/**` | All files under src/auth/ |
138
- | Glob with extension | `src/**/*.ts` | All .ts files under src/ |
139
- | Specific file | `src/payment/processor.ts` | Single file |
140
- | Multiple patterns | `src/auth/**,src/payment/**` | Comma-separated (no spaces) |
141
-
142
- **Resolution Process**:
143
- 1. Parse input pattern (split by comma, trim whitespace)
144
- 2. Expand glob patterns to file list via `find` command
145
- 3. Validate all files exist and are readable
146
- 4. Error if pattern matches 0 files
147
- 5. Store resolved file list in review-state.json
148
-
149
- ### 3. Aggregation Logic
150
-
151
- **Cross-Cutting Concern Detection**:
152
- 1. Files appearing in 3+ dimensions = **Critical Files**
153
- 2. Same issue pattern across dimensions = **Systemic Issue**
154
- 3. Severity clustering in specific files = **Hotspots**
155
-
156
- **Deep-Dive Selection Criteria**:
157
- - All critical severity findings (priority 1)
158
- - Top 3 high-severity findings in critical files (priority 2)
159
- - Max 5 findings per iteration (prevent overwhelm)
160
-
161
- ### 4. Severity Assessment
162
-
163
- **Severity Levels**:
164
- - **Critical**: Security vulnerabilities, data corruption risks, system-wide failures, authentication/authorization bypass
165
- - **High**: Feature degradation, performance bottlenecks, architecture violations, significant technical debt
166
- - **Medium**: Code smells, minor performance issues, style inconsistencies, maintainability concerns
167
- - **Low**: Documentation gaps, minor refactoring opportunities, cosmetic issues
168
-
169
- **Iteration Trigger**:
170
- - Critical findings > 0 OR
171
- - High findings > 5 OR
172
- - Critical files count > 0
173
-
174
- ## Core Responsibilities
175
-
176
- ### Orchestrator
177
-
178
- **Phase 1: Discovery & Initialization**
179
-
180
- **Step 1: Session Creation**
181
- ```javascript
182
- // Create workflow session for this review (type: review)
183
- Skill(skill="workflow:session:start", args="--type review \"Code review for [target_pattern]\"")
184
-
185
- // Parse output
186
- const sessionId = output.match(/SESSION_ID: (WFS-[^\s]+)/)[1];
187
- ```
188
-
189
- **Step 2: Path Resolution & Validation**
190
- ```bash
191
- # Expand glob pattern to file list (relative paths from project root)
192
- find . -path "./src/auth/**" -type f | sed 's|^\./||'
193
-
194
- # Validate files exist and are readable
195
- for file in ${resolvedFiles[@]}; do
196
- test -r "$file" || error "File not readable: $file"
197
- done
198
- ```
199
- - Parse and expand file patterns (glob support): `src/auth/**` → actual file list
200
- - Validation: Ensure all specified files exist and are readable
201
- - Store as **relative paths** from project root (e.g., `src/auth/service.ts`)
202
- - Agents construct absolute paths dynamically during execution
203
-
204
- **Step 3: Output Directory Setup**
205
- - Output directory: `.workflow/active/${sessionId}/.review/`
206
- - Create directory structure:
207
- ```bash
208
- mkdir -p ${sessionDir}/.review/{dimensions,iterations,reports}
209
- ```
210
-
211
- **Step 4: Initialize Review State**
212
- - State initialization: Create `review-state.json` with metadata, dimensions, max_iterations, resolved_files (merged metadata + state)
213
- - Progress tracking: Create `review-progress.json` for progress tracking
214
-
215
- **Step 5: TodoWrite Initialization**
216
- - Set up progress tracking with hierarchical structure
217
- - Mark Phase 1 completed, Phase 2 in_progress
218
-
219
- **Phase 2: Parallel Review Coordination**
220
- - Launch 7 @cli-explore-agent instances simultaneously (Deep Scan mode)
221
- - Pass dimension-specific context (template, timeout, custom focus, **target files**)
222
- - Monitor completion via review-progress.json updates
223
- - TodoWrite updates: Mark dimensions as completed
224
- - CLI tool fallback: Gemini → Qwen → Codex (on error/timeout)
225
-
226
- **Phase 3: Aggregation**
227
- - Load all dimension JSON files from dimensions/
228
- - Calculate severity distribution: Count by critical/high/medium/low
229
- - Identify cross-cutting concerns: Files in 3+ dimensions
230
- - Select deep-dive findings: Critical + high in critical files (max 5)
231
- - Decision logic: Iterate if critical > 0 OR high > 5 OR critical files exist
232
- - Update review-state.json with aggregation results
233
-
234
- **Phase 4: Iteration Control**
235
- - Check iteration count < max_iterations (default 3)
236
- - Launch deep-dive agents for selected findings
237
- - Collect remediation plans and re-assessed severities
238
- - Update severity distribution based on re-assessments
239
- - Record iteration in review-state.json
240
- - Loop back to aggregation if still have critical/high findings
241
-
242
- **Phase 5: Completion**
243
- - Finalize review-progress.json with completion statistics
244
- - Update review-state.json with completion_time and phase=complete
245
- - TodoWrite completion: Mark all tasks done
246
-
247
-
248
-
249
- ### Output File Structure
250
-
251
- ```
252
- .workflow/active/WFS-{session-id}/.review/
253
- ├── review-state.json # Orchestrator state machine (includes metadata)
254
- ├── review-progress.json # Real-time progress for dashboard
255
- ├── dimensions/ # Per-dimension results
256
- │ ├── security.json
257
- │ ├── architecture.json
258
- │ ├── quality.json
259
- │ ├── action-items.json
260
- │ ├── performance.json
261
- │ ├── maintainability.json
262
- │ └── best-practices.json
263
- ├── iterations/ # Deep-dive results
264
- │ ├── iteration-1-finding-{uuid}.json
265
- │ └── iteration-2-finding-{uuid}.json
266
- └── reports/ # Human-readable reports
267
- ├── security-analysis.md
268
- ├── security-cli-output.txt
269
- ├── deep-dive-1-{uuid}.md
270
- └── ...
271
- ```
272
-
273
- **Session Context**:
274
- ```
275
- .workflow/active/WFS-{session-id}/
276
- ├── workflow-session.json
277
- ├── IMPL_PLAN.md
278
- ├── TODO_LIST.md
279
- ├── .task/
280
- ├── .summaries/
281
- └── .review/ # Review results (this command)
282
- └── (structure above)
283
- ```
284
-
285
- ### Review State JSON
286
-
287
- **Purpose**: Unified state machine and metadata (merged from metadata + state)
288
-
289
- ```json
290
- {
291
- "review_id": "review-20250125-143022",
292
- "review_type": "module",
293
- "session_id": "WFS-auth-system",
294
- "metadata": {
295
- "created_at": "2025-01-25T14:30:22Z",
296
- "target_pattern": "src/auth/**",
297
- "resolved_files": [
298
- "src/auth/service.ts",
299
- "src/auth/validator.ts",
300
- "src/auth/middleware.ts"
301
- ],
302
- "dimensions": ["security", "architecture", "quality", "action-items", "performance", "maintainability", "best-practices"],
303
- "max_iterations": 3
304
- },
305
- "phase": "parallel|aggregate|iterate|complete",
306
- "current_iteration": 1,
307
- "dimensions_reviewed": ["security", "architecture", "quality", "action-items", "performance", "maintainability", "best-practices"],
308
- "selected_strategy": "comprehensive",
309
- "next_action": "execute_parallel_reviews|aggregate_findings|execute_deep_dive|generate_final_report|complete",
310
- "severity_distribution": {
311
- "critical": 2,
312
- "high": 5,
313
- "medium": 12,
314
- "low": 8
315
- },
316
- "critical_files": [...],
317
- "iterations": [...],
318
- "completion_criteria": {...}
319
- }
320
- ```
321
-
322
- ### Review Progress JSON
323
-
324
- **Purpose**: Real-time dashboard updates via polling
325
-
326
- ```json
327
- {
328
- "review_id": "review-20250125-143022",
329
- "last_update": "2025-01-25T14:35:10Z",
330
- "phase": "parallel|aggregate|iterate|complete",
331
- "current_iteration": 1,
332
- "progress": {
333
- "parallel_review": {
334
- "total_dimensions": 7,
335
- "completed": 5,
336
- "in_progress": 2,
337
- "percent_complete": 71
338
- },
339
- "deep_dive": {
340
- "total_findings": 6,
341
- "analyzed": 2,
342
- "in_progress": 1,
343
- "percent_complete": 33
344
- }
345
- },
346
- "agent_status": [
347
- {
348
- "agent_type": "review-agent",
349
- "dimension": "security",
350
- "status": "completed",
351
- "started_at": "2025-01-25T14:30:00Z",
352
- "completed_at": "2025-01-25T15:15:00Z",
353
- "duration_ms": 2700000
354
- },
355
- {
356
- "agent_type": "deep-dive-agent",
357
- "finding_id": "sec-001-uuid",
358
- "status": "in_progress",
359
- "started_at": "2025-01-25T14:32:00Z"
360
- }
361
- ],
362
- "estimated_completion": "2025-01-25T16:00:00Z"
363
- }
364
- ```
365
-
366
- ### Agent Output Schemas
367
-
368
- **Agent-produced JSON files follow standardized schemas**:
369
-
370
- 1. **Dimension Results** (cli-explore-agent output from parallel reviews)
371
- - Schema: `~/.ccw/workflows/cli-templates/schemas/review-dimension-results-schema.json`
372
- - Output: `{output-dir}/dimensions/{dimension}.json`
373
- - Contains: findings array, summary statistics, cross_references
374
-
375
- 2. **Deep-Dive Results** (cli-explore-agent output from iterations)
376
- - Schema: `~/.ccw/workflows/cli-templates/schemas/review-deep-dive-results-schema.json`
377
- - Output: `{output-dir}/iterations/iteration-{N}-finding-{uuid}.json`
378
- - Contains: root_cause, remediation_plan, impact_assessment, reassessed_severity
379
-
380
- ### Agent Invocation Template
381
-
382
- **Review Agent** (parallel execution, 7 instances):
383
-
384
- ```javascript
385
- Task(
386
- subagent_type="cli-explore-agent",
387
- run_in_background=false,
388
- description=`Execute ${dimension} review analysis via Deep Scan`,
389
- prompt=`
390
- ## Task Objective
391
- Conduct comprehensive ${dimension} code exploration and analysis using Deep Scan mode (Bash + Gemini dual-source strategy) for specified module files
392
-
393
- ## Analysis Mode Selection
394
- Use **Deep Scan mode** for this review:
395
- - Phase 1: Bash structural scan for standard patterns (classes, functions, imports)
396
- - Phase 2: Gemini semantic analysis for design intent, non-standard patterns, ${dimension}-specific concerns
397
- - Phase 3: Synthesis with attribution (bash-discovered vs gemini-discovered findings)
398
-
399
- ## MANDATORY FIRST STEPS (Execute by Agent)
400
- **You (cli-explore-agent) MUST execute these steps in order:**
401
- 1. Read review state: ${reviewStateJsonPath}
402
- 2. Get target files: Read resolved_files from review-state.json
403
- 3. Validate file access: bash(ls -la ${targetFiles.join(' ')})
404
- 4. Execute: ccw tool exec json_builder '{"cmd":"info","schema":"review-dim"}' (get output schema summary)
405
- 5. Read: .workflow/project-tech.json (technology stack and architecture context)
406
- 6. Read: .workflow/specs/*.md (user-defined constraints and conventions to validate against)
407
-
408
- ## Review Context
409
- - Review Type: module (independent)
410
- - Review Dimension: ${dimension}
411
- - Review ID: ${reviewId}
412
- - Target Pattern: ${targetPattern}
413
- - Resolved Files: ${resolvedFiles.length} files
414
- - Output Directory: ${outputDir}
415
-
416
- ## CLI Configuration
417
- - Tool Priority: gemini → qwen → codex (fallback chain)
418
- - Custom Focus: ${customFocus || 'Standard dimension analysis'}
419
- - Mode: analysis (READ-ONLY)
420
- - Context Pattern: ${targetFiles.map(f => `@${f}`).join(' ')}
421
-
422
- ## Expected Deliverables
423
-
424
- **Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 4, follow schema exactly
425
-
426
- 1. Dimension Results JSON: ${outputDir}/dimensions/${dimension}.json
427
-
428
- **⚠️ CRITICAL JSON STRUCTURE REQUIREMENTS**:
429
-
430
- Root structure MUST be array: \`[{ ... }]\` NOT \`{ ... }\`
431
-
432
- Required top-level fields:
433
- - dimension, review_id, analysis_timestamp (NOT timestamp/analyzed_at)
434
- - cli_tool_used (gemini|qwen|codex), model, analysis_duration_ms
435
- - summary (FLAT structure), findings, cross_references
436
-
437
- Summary MUST be FLAT (NOT nested by_severity):
438
- \`{ "total_findings": N, "critical": N, "high": N, "medium": N, "low": N, "files_analyzed": N, "lines_reviewed": N }\`
439
-
440
- Finding required fields:
441
- - id: format \`{dim}-{seq}-{uuid8}\` e.g., \`sec-001-a1b2c3d4\` (lowercase)
442
- - severity: lowercase only (critical|high|medium|low)
443
- - snippet (NOT code_snippet), impact (NOT exploit_scenario)
444
- - metadata, iteration (0), status (pending_remediation), cross_references
445
-
446
- 2. Analysis Report: ${outputDir}/reports/${dimension}-analysis.md
447
- - Human-readable summary with recommendations
448
- - Grouped by severity: critical → high → medium → low
449
- - Include file:line references for all findings
450
-
451
- 3. CLI Output Log: ${outputDir}/reports/${dimension}-cli-output.txt
452
- - Raw CLI tool output for debugging
453
- - Include full analysis text
454
-
455
- ## Dimension-Specific Guidance
456
- ${getDimensionGuidance(dimension)}
457
-
458
- ## Success Criteria
459
- - [ ] Schema obtained via json_builder info
460
- - [ ] All target files analyzed for ${dimension} concerns
461
- - [ ] All findings include file:line references with code snippets
462
- - [ ] Severity assessment follows established criteria (see reference)
463
- - [ ] Recommendations are actionable with code examples
464
- - [ ] JSON output follows schema exactly
465
- - [ ] Report is comprehensive and well-organized
466
- `
467
- )
468
- ```
469
-
470
- **Deep-Dive Agent** (iteration execution):
471
-
472
- ```javascript
473
- Task(
474
- subagent_type="cli-explore-agent",
475
- run_in_background=false,
476
- description=`Deep-dive analysis for critical finding: ${findingTitle} via Dependency Map + Deep Scan`,
477
- prompt=`
478
- ## Task Objective
479
- Perform focused root cause analysis using Dependency Map mode (for impact analysis) + Deep Scan mode (for semantic understanding) to generate comprehensive remediation plan for critical ${dimension} issue
480
-
481
- ## Analysis Mode Selection
482
- Use **Dependency Map mode** first to understand dependencies:
483
- - Build dependency graph around ${file} to identify affected components
484
- - Detect circular dependencies or tight coupling related to this finding
485
- - Calculate change risk scores for remediation impact
486
-
487
- Then apply **Deep Scan mode** for semantic analysis:
488
- - Understand design intent and architectural context
489
- - Identify non-standard patterns or implicit dependencies
490
- - Extract remediation insights from code structure
491
-
492
- ## Finding Context
493
- - Finding ID: ${findingId}
494
- - Original Dimension: ${dimension}
495
- - Title: ${findingTitle}
496
- - File: ${file}:${line}
497
- - Severity: ${severity}
498
- - Category: ${category}
499
- - Original Description: ${description}
500
- - Iteration: ${iteration}
501
-
502
- ## MANDATORY FIRST STEPS (Execute by Agent)
503
- **You (cli-explore-agent) MUST execute these steps in order:**
504
- 1. Read original finding: ${dimensionJsonPath}
505
- 2. Read affected file: ${file}
506
- 3. Identify related code: bash(grep -r "import.*${basename(file)}" ${projectDir}/src --include="*.ts")
507
- 4. Read test files: bash(find ${projectDir}/tests -name "*${basename(file, '.ts')}*" -type f)
508
- 5. Execute: ccw tool exec json_builder '{"cmd":"info","schema":"review-deep"}' (get output schema summary)
509
- 6. Read: .workflow/project-tech.json (technology stack and architecture context)
510
- 7. Read: .workflow/specs/*.md (user-defined constraints for remediation compliance)
511
-
512
- ## CLI Configuration
513
- - Tool Priority: gemini → qwen → codex
514
- - Template: ~/.ccw/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt
515
- - Mode: analysis (READ-ONLY)
516
-
517
- ## Expected Deliverables
518
-
519
- **Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 5, follow schema exactly
520
-
521
- 1. Deep-Dive Results JSON: ${outputDir}/iterations/iteration-${iteration}-finding-${findingId}.json
522
-
523
- **⚠️ CRITICAL JSON STRUCTURE REQUIREMENTS**:
524
-
525
- Root structure MUST be array: \`[{ ... }]\` NOT \`{ ... }\`
526
-
527
- Required top-level fields:
528
- - finding_id, dimension, iteration, analysis_timestamp
529
- - cli_tool_used, model, analysis_duration_ms
530
- - original_finding, root_cause, remediation_plan
531
- - impact_assessment, reassessed_severity, confidence_score, cross_references
532
-
533
- All nested objects must follow schema exactly - read schema for field names
534
-
535
- 2. Analysis Report: ${outputDir}/reports/deep-dive-${iteration}-${findingId}.md
536
- - Detailed root cause analysis
537
- - Step-by-step remediation plan
538
- - Impact assessment and rollback strategy
539
-
540
- ## Success Criteria
541
- - [ ] Schema obtained via json_builder info
542
- - [ ] Root cause clearly identified with supporting evidence
543
- - [ ] Remediation plan is step-by-step actionable with exact file:line references
544
- - [ ] Each step includes specific commands and validation tests
545
- - [ ] Impact fully assessed (files, tests, breaking changes, dependencies)
546
- - [ ] Severity re-evaluation justified with evidence
547
- - [ ] Confidence score accurately reflects certainty of analysis
548
- - [ ] JSON output follows schema exactly
549
- - [ ] References include project-specific and external documentation
550
- `
551
- )
552
- ```
553
-
554
- ### Dimension Guidance Reference
555
-
556
- ```javascript
557
- function getDimensionGuidance(dimension) {
558
- const guidance = {
559
- security: `
560
- Focus Areas:
561
- - Input validation and sanitization
562
- - Authentication and authorization mechanisms
563
- - Data encryption (at-rest and in-transit)
564
- - SQL/NoSQL injection vulnerabilities
565
- - XSS, CSRF, and other web vulnerabilities
566
- - Sensitive data exposure
567
- - Access control and privilege escalation
568
-
569
- Severity Criteria:
570
- - Critical: Authentication bypass, SQL injection, RCE, sensitive data exposure
571
- - High: Missing authorization checks, weak encryption, exposed secrets
572
- - Medium: Missing input validation, insecure defaults, weak password policies
573
- - Low: Security headers missing, verbose error messages, outdated dependencies
574
- `,
575
- architecture: `
576
- Focus Areas:
577
- - Layering and separation of concerns
578
- - Coupling and cohesion
579
- - Design pattern adherence
580
- - Dependency management
581
- - Scalability and extensibility
582
- - Module boundaries
583
- - API design consistency
584
-
585
- Severity Criteria:
586
- - Critical: Circular dependencies, god objects, tight coupling across layers
587
- - High: Violated architectural principles, scalability bottlenecks
588
- - Medium: Missing abstractions, inconsistent patterns, suboptimal design
589
- - Low: Minor coupling issues, documentation gaps, naming inconsistencies
590
- `,
591
- quality: `
592
- Focus Areas:
593
- - Code duplication
594
- - Complexity (cyclomatic, cognitive)
595
- - Naming conventions
596
- - Error handling patterns
597
- - Code readability
598
- - Comment quality
599
- - Dead code
600
-
601
- Severity Criteria:
602
- - Critical: Severe complexity (CC > 20), massive duplication (>50 lines)
603
- - High: High complexity (CC > 10), significant duplication, poor error handling
604
- - Medium: Moderate complexity (CC > 5), naming issues, code smells
605
- - Low: Minor duplication, documentation gaps, cosmetic issues
606
- `,
607
- 'action-items': `
608
- Focus Areas:
609
- - Requirements coverage verification
610
- - Acceptance criteria met
611
- - Documentation completeness
612
- - Deployment readiness
613
- - Missing functionality
614
- - Test coverage gaps
615
- - Configuration management
616
-
617
- Severity Criteria:
618
- - Critical: Core requirements not met, deployment blockers
619
- - High: Significant functionality missing, acceptance criteria not met
620
- - Medium: Minor requirements gaps, documentation incomplete
621
- - Low: Nice-to-have features missing, minor documentation gaps
622
- `,
623
- performance: `
624
- Focus Areas:
625
- - N+1 query problems
626
- - Inefficient algorithms (O(n²) where O(n log n) possible)
627
- - Memory leaks
628
- - Blocking operations on main thread
629
- - Missing caching opportunities
630
- - Resource usage (CPU, memory, network)
631
- - Database query optimization
632
-
633
- Severity Criteria:
634
- - Critical: Memory leaks, O(n²) in hot path, blocking main thread
635
- - High: N+1 queries, missing indexes, inefficient algorithms
636
- - Medium: Suboptimal caching, unnecessary computations, lazy loading issues
637
- - Low: Minor optimization opportunities, redundant operations
638
- `,
639
- maintainability: `
640
- Focus Areas:
641
- - Technical debt indicators
642
- - Magic numbers and hardcoded values
643
- - Long methods (>50 lines)
644
- - Large classes (>500 lines)
645
- - Dead code and commented code
646
- - Code documentation
647
- - Test coverage
648
-
649
- Severity Criteria:
650
- - Critical: Massive methods (>200 lines), severe technical debt blocking changes
651
- - High: Large methods (>100 lines), significant dead code, undocumented complex logic
652
- - Medium: Magic numbers, moderate technical debt, missing tests
653
- - Low: Minor refactoring opportunities, cosmetic improvements
654
- `,
655
- 'best-practices': `
656
- Focus Areas:
657
- - Framework conventions adherence
658
- - Language idioms
659
- - Anti-patterns
660
- - Deprecated API usage
661
- - Coding standards compliance
662
- - Error handling patterns
663
- - Logging and monitoring
664
-
665
- Severity Criteria:
666
- - Critical: Severe anti-patterns, deprecated APIs with security risks
667
- - High: Major convention violations, poor error handling, missing logging
668
- - Medium: Minor anti-patterns, style inconsistencies, suboptimal patterns
669
- - Low: Cosmetic style issues, minor convention deviations
670
- `
671
- };
672
-
673
- return guidance[dimension] || 'Standard code review analysis';
674
- }
675
- ```
676
-
677
- ### Completion Conditions
678
-
679
- **Full Success**:
680
- - All dimensions reviewed
681
- - Critical findings = 0
682
- - High findings ≤ 5
683
- - Action: Generate final report, mark phase=complete
684
-
685
- **Partial Success**:
686
- - All dimensions reviewed
687
- - Max iterations reached
688
- - Still have critical/high findings
689
- - Action: Generate report with warnings, recommend follow-up
690
-
691
- ### Error Handling
692
-
693
- **Phase-Level Error Matrix**:
694
-
695
- | Phase | Error | Blocking? | Action |
696
- |-------|-------|-----------|--------|
697
- | Phase 1 | Invalid path pattern | Yes | Error and exit |
698
- | Phase 1 | No files matched | Yes | Error and exit |
699
- | Phase 1 | Files not readable | Yes | Error and exit |
700
- | Phase 2 | Single dimension fails | No | Log warning, continue other dimensions |
701
- | Phase 2 | All dimensions fail | Yes | Error and exit |
702
- | Phase 3 | Missing dimension JSON | No | Skip in aggregation, log warning |
703
- | Phase 4 | Deep-dive agent fails | No | Skip finding, continue others |
704
- | Phase 4 | Max iterations reached | No | Generate partial report |
705
-
706
- **CLI Fallback Chain**: Gemini → Qwen → Codex → degraded mode
707
-
708
- **Fallback Triggers**:
709
- 1. HTTP 429, 5xx errors, connection timeout
710
- 2. Invalid JSON output (parse error, missing required fields)
711
- 3. Low confidence score < 0.4
712
- 4. Analysis too brief (< 100 words in report)
713
-
714
- **Fallback Behavior**:
715
- - On trigger: Retry with next tool in chain
716
- - After Codex fails: Enter degraded mode (skip analysis, log error)
717
- - Degraded mode: Continue workflow with available results
718
-
719
- ### TodoWrite Structure
720
-
721
- ```javascript
722
- TodoWrite({
723
- todos: [
724
- { content: "Phase 1: Discovery & Initialization", status: "completed", activeForm: "Initializing" },
725
- { content: "Phase 2: Parallel Reviews (7 dimensions)", status: "in_progress", activeForm: "Reviewing" },
726
- { content: " → Security review", status: "in_progress", activeForm: "Analyzing security" },
727
- // ... other dimensions as sub-items
728
- { content: "Phase 3: Aggregation", status: "pending", activeForm: "Aggregating" },
729
- { content: "Phase 4: Deep-dive", status: "pending", activeForm: "Deep-diving" },
730
- { content: "Phase 5: Completion", status: "pending", activeForm: "Completing" }
731
- ]
732
- });
733
- ```
734
-
735
- ## Best Practices
736
-
737
- 1. **Start Specific**: Begin with focused module patterns for faster results
738
- 2. **Expand Gradually**: Add more modules based on initial findings
739
- 3. **Use Glob Wisely**: `src/auth/**` is more efficient than `src/**` with lots of irrelevant files
740
- 4. **Trust Aggregation Logic**: Auto-selection based on proven heuristics
741
- 5. **Monitor Logs**: Check reports/ directory for CLI analysis insights
742
-
743
- ## Related Commands
744
-
745
- ### View Review Progress
746
- Use `ccw view` to open the review dashboard in browser:
747
-
748
- ```bash
749
- ccw view
750
- ```
751
-
752
- ### Automated Fix Workflow
753
- After completing a module review, use the generated findings JSON for automated fixing:
754
-
755
- ```bash
756
- # Step 1: Complete review (this command)
757
- /workflow:review-module-cycle src/auth/**
758
-
759
- # Step 2: Run automated fixes using dimension findings
760
- /workflow:review-cycle-fix .workflow/active/WFS-{session-id}/.review/
761
- ```
762
-
763
- See `review-cycle` skill (fix phase) for automated fixing with smart grouping, parallel execution, and test verification.
764
-
1
+ # Workflow Review-Module-Cycle Command
2
+
3
+ ## Quick Start
4
+
5
+ ```bash
6
+ # Review specific module (all 7 dimensions)
7
+ /workflow:review-module-cycle src/auth/**
8
+
9
+ # Review multiple modules
10
+ /workflow:review-module-cycle src/auth/**,src/payment/**
11
+
12
+ # Review with custom dimensions
13
+ /workflow:review-module-cycle src/payment/** --dimensions=security,architecture,quality
14
+
15
+ # Review specific files
16
+ /workflow:review-module-cycle src/payment/processor.ts,src/payment/validator.ts
17
+ ```
18
+
19
+ **Review Scope**: Specified modules/files only (independent of git history)
20
+ **Session Requirement**: Auto-creates workflow session via `/workflow:session:start`
21
+ **Output Directory**: `.workflow/active/WFS-{session-id}/.review/` (session-based)
22
+ **Default Dimensions**: Security, Architecture, Quality, Action-Items, Performance, Maintainability, Best-Practices
23
+ **Max Iterations**: 3 (adjustable via --max-iterations)
24
+ **Default Iterations**: 1 (deep-dive runs once; use --max-iterations=0 to skip)
25
+ **CLI Tools**: Gemini → Qwen → Codex (fallback chain)
26
+
27
+ ## What & Why
28
+
29
+ ### Core Concept
30
+ Independent multi-dimensional code review orchestrator with **hybrid parallel-iterative execution** for comprehensive quality assessment of **specific modules or files**.
31
+
32
+ **Review Scope**:
33
+ - **Module-based**: Reviews specified file patterns (e.g., `src/auth/**`, `*.ts`)
34
+ - **Session-integrated**: Runs within workflow session context for unified tracking
35
+ - **Output location**: `.review/` subdirectory within active session
36
+
37
+ **vs Session Review**:
38
+ - **Session Review** (`review-session-cycle`): Reviews git changes within a workflow session
39
+ - **Module Review** (`review-module-cycle`): Reviews any specified code paths, regardless of git history
40
+ - **Common output**: Both use same `.review/` directory structure within session
41
+
42
+ ### Value Proposition
43
+ 1. **Module-Focused Review**: Target specific code areas independent of git history
44
+ 2. **Session-Integrated**: Review results tracked within workflow session for unified management
45
+ 3. **Comprehensive Coverage**: Same 7 specialized dimensions as session review
46
+ 4. **Intelligent Prioritization**: Automatic identification of critical issues and cross-cutting concerns
47
+ 5. **Unified Archive**: Review results archived with session for historical reference
48
+
49
+ ### Orchestrator Boundary (CRITICAL)
50
+ - **ONLY command** for independent multi-dimensional module review
51
+ - Manages: dimension coordination, aggregation, iteration control, progress tracking
52
+ - Delegates: Code exploration and analysis to @cli-explore-agent, dimension-specific reviews via Deep Scan mode
53
+
54
+ ## How It Works
55
+
56
+ ### Execution Flow
57
+
58
+ ```
59
+ Phase 1: Discovery & Initialization
60
+ └─ Resolve file patterns, validate paths, initialize state, create output structure
61
+
62
+ Phase 2: Parallel Reviews (for each dimension)
63
+ ├─ Launch 7 review agents simultaneously
64
+ ├─ Each executes CLI analysis via Gemini/Qwen on specified files
65
+ ├─ Generate dimension JSON + markdown reports
66
+ └─ Update review-progress.json
67
+
68
+ Phase 3: Aggregation
69
+ ├─ Load all dimension JSON files
70
+ ├─ Calculate severity distribution (critical/high/medium/low)
71
+ ├─ Identify cross-cutting concerns (files in 3+ dimensions)
72
+ └─ Decision:
73
+ ├─ Critical findings OR high > 5 OR critical files → Phase 4 (Iterate)
74
+ └─ Else → Phase 5 (Complete)
75
+
76
+ Phase 4: Iterative Deep-Dive (optional)
77
+ ├─ Select critical findings (max 5 per iteration)
78
+ ├─ Launch deep-dive agents for root cause analysis
79
+ ├─ Generate remediation plans with impact assessment
80
+ ├─ Re-assess severity based on analysis
81
+ └─ Loop until no critical findings OR max iterations
82
+
83
+ Phase 5: Completion
84
+ └─ Finalize review-progress.json
85
+ ```
86
+
87
+ ### Agent Roles
88
+
89
+ | Agent | Responsibility |
90
+ |-------|---------------|
91
+ | **Orchestrator** | Phase control, path resolution, state management, aggregation logic, iteration control |
92
+ | **@cli-explore-agent** (Review) | Execute dimension-specific code analysis via Deep Scan mode, generate findings JSON with dual-source strategy (Bash + Gemini), create structured analysis reports |
93
+ | **@cli-explore-agent** (Deep-dive) | Focused root cause analysis using dependency mapping, remediation planning with architectural insights, impact assessment, severity re-assessment |
94
+
95
+ ## Enhanced Features
96
+
97
+ ### 1. Review Dimensions Configuration
98
+
99
+ **7 Specialized Dimensions** with priority-based allocation:
100
+
101
+ | Dimension | Template | Priority | Timeout |
102
+ |-----------|----------|----------|---------|
103
+ | **Security** | 03-assess-security-risks.txt | 1 (Critical) | 60min |
104
+ | **Architecture** | 02-review-architecture.txt | 2 (High) | 60min |
105
+ | **Quality** | 02-review-code-quality.txt | 3 (Medium) | 40min |
106
+ | **Action-Items** | 02-analyze-code-patterns.txt | 2 (High) | 40min |
107
+ | **Performance** | 03-analyze-performance.txt | 3 (Medium) | 60min |
108
+ | **Maintainability** | 02-review-code-quality.txt* | 3 (Medium) | 40min |
109
+ | **Best-Practices** | 03-review-quality-standards.txt | 3 (Medium) | 40min |
110
+
111
+ *Custom focus: "Assess technical debt and maintainability"
112
+
113
+ **Category Definitions by Dimension**:
114
+
115
+ ```javascript
116
+ const CATEGORIES = {
117
+ security: ['injection', 'authentication', 'authorization', 'encryption', 'input-validation', 'access-control', 'data-exposure'],
118
+ architecture: ['coupling', 'cohesion', 'layering', 'dependency', 'pattern-violation', 'scalability', 'separation-of-concerns'],
119
+ quality: ['code-smell', 'duplication', 'complexity', 'naming', 'error-handling', 'testability', 'readability'],
120
+ 'action-items': ['requirement-coverage', 'acceptance-criteria', 'documentation', 'deployment-readiness', 'missing-functionality'],
121
+ performance: ['n-plus-one', 'inefficient-query', 'memory-leak', 'blocking-operation', 'caching', 'resource-usage'],
122
+ maintainability: ['technical-debt', 'magic-number', 'long-method', 'large-class', 'dead-code', 'commented-code'],
123
+ 'best-practices': ['convention-violation', 'anti-pattern', 'deprecated-api', 'missing-validation', 'inconsistent-style']
124
+ };
125
+ ```
126
+
127
+ ### 2. Path Pattern Resolution
128
+
129
+ **Syntax Rules**:
130
+ - All paths are **relative** from project root (e.g., `src/auth/**` not `/src/auth/**`)
131
+ - Multiple patterns: comma-separated, **no spaces** (e.g., `src/auth/**,src/payment/**`)
132
+ - Glob and specific files can be mixed (e.g., `src/auth/**,src/config.ts`)
133
+
134
+ **Supported Patterns**:
135
+ | Pattern Type | Example | Description |
136
+ |--------------|---------|-------------|
137
+ | Glob directory | `src/auth/**` | All files under src/auth/ |
138
+ | Glob with extension | `src/**/*.ts` | All .ts files under src/ |
139
+ | Specific file | `src/payment/processor.ts` | Single file |
140
+ | Multiple patterns | `src/auth/**,src/payment/**` | Comma-separated (no spaces) |
141
+
142
+ **Resolution Process**:
143
+ 1. Parse input pattern (split by comma, trim whitespace)
144
+ 2. Expand glob patterns to file list via `find` command
145
+ 3. Validate all files exist and are readable
146
+ 4. Error if pattern matches 0 files
147
+ 5. Store resolved file list in review-state.json
148
+
149
+ ### 3. Aggregation Logic
150
+
151
+ **Cross-Cutting Concern Detection**:
152
+ 1. Files appearing in 3+ dimensions = **Critical Files**
153
+ 2. Same issue pattern across dimensions = **Systemic Issue**
154
+ 3. Severity clustering in specific files = **Hotspots**
155
+
156
+ **Deep-Dive Selection Criteria**:
157
+ - All critical severity findings (priority 1)
158
+ - Top 3 high-severity findings in critical files (priority 2)
159
+ - Max 5 findings per iteration (prevent overwhelm)
160
+
161
+ ### 4. Severity Assessment
162
+
163
+ **Severity Levels**:
164
+ - **Critical**: Security vulnerabilities, data corruption risks, system-wide failures, authentication/authorization bypass
165
+ - **High**: Feature degradation, performance bottlenecks, architecture violations, significant technical debt
166
+ - **Medium**: Code smells, minor performance issues, style inconsistencies, maintainability concerns
167
+ - **Low**: Documentation gaps, minor refactoring opportunities, cosmetic issues
168
+
169
+ **Iteration Trigger**:
170
+ - Critical findings > 0 OR
171
+ - High findings > 5 OR
172
+ - Critical files count > 0
173
+
174
+ ## Core Responsibilities
175
+
176
+ ### Orchestrator
177
+
178
+ **Phase 1: Discovery & Initialization**
179
+
180
+ **Step 1: Session Creation**
181
+ ```javascript
182
+ // Create workflow session for this review (type: review)
183
+ Skill(skill="workflow:session:start", args="--type review \"Code review for [target_pattern]\"")
184
+
185
+ // Parse output
186
+ const sessionId = output.match(/SESSION_ID: (WFS-[^\s]+)/)[1];
187
+ ```
188
+
189
+ **Step 2: Path Resolution & Validation**
190
+ ```bash
191
+ # Expand glob pattern to file list (relative paths from project root)
192
+ find . -path "./src/auth/**" -type f | sed 's|^\./||'
193
+
194
+ # Validate files exist and are readable
195
+ for file in ${resolvedFiles[@]}; do
196
+ test -r "$file" || error "File not readable: $file"
197
+ done
198
+ ```
199
+ - Parse and expand file patterns (glob support): `src/auth/**` → actual file list
200
+ - Validation: Ensure all specified files exist and are readable
201
+ - Store as **relative paths** from project root (e.g., `src/auth/service.ts`)
202
+ - Agents construct absolute paths dynamically during execution
203
+
204
+ **Step 3: Output Directory Setup**
205
+ - Output directory: `.workflow/active/${sessionId}/.review/`
206
+ - Create directory structure:
207
+ ```bash
208
+ mkdir -p ${sessionDir}/.review/{dimensions,iterations,reports}
209
+ ```
210
+
211
+ **Step 4: Initialize Review State**
212
+ - State initialization: Create `review-state.json` with metadata, dimensions, max_iterations, resolved_files (merged metadata + state)
213
+ - Progress tracking: Create `review-progress.json` for progress tracking
214
+
215
+ **Step 5: TodoWrite Initialization**
216
+ - Set up progress tracking with hierarchical structure
217
+ - Mark Phase 1 completed, Phase 2 in_progress
218
+
219
+ **Phase 2: Parallel Review Coordination**
220
+ - Launch 7 @cli-explore-agent instances simultaneously (Deep Scan mode)
221
+ - Pass dimension-specific context (template, timeout, custom focus, **target files**)
222
+ - Monitor completion via review-progress.json updates
223
+ - TodoWrite updates: Mark dimensions as completed
224
+ - CLI tool fallback: Gemini → Qwen → Codex (on error/timeout)
225
+
226
+ **Phase 3: Aggregation**
227
+ - Load all dimension JSON files from dimensions/
228
+ - Calculate severity distribution: Count by critical/high/medium/low
229
+ - Identify cross-cutting concerns: Files in 3+ dimensions
230
+ - Select deep-dive findings: Critical + high in critical files (max 5)
231
+ - Decision logic: Iterate if critical > 0 OR high > 5 OR critical files exist
232
+ - Update review-state.json with aggregation results
233
+
234
+ **Phase 4: Iteration Control**
235
+ - Check iteration count < max_iterations (default 3)
236
+ - Launch deep-dive agents for selected findings
237
+ - Collect remediation plans and re-assessed severities
238
+ - Update severity distribution based on re-assessments
239
+ - Record iteration in review-state.json
240
+ - Loop back to aggregation if still have critical/high findings
241
+
242
+ **Phase 5: Completion**
243
+ - Finalize review-progress.json with completion statistics
244
+ - Update review-state.json with completion_time and phase=complete
245
+ - TodoWrite completion: Mark all tasks done
246
+
247
+
248
+
249
+ ### Output File Structure
250
+
251
+ ```
252
+ .workflow/active/WFS-{session-id}/.review/
253
+ ├── review-state.json # Orchestrator state machine (includes metadata)
254
+ ├── review-progress.json # Real-time progress for dashboard
255
+ ├── dimensions/ # Per-dimension results
256
+ │ ├── security.json
257
+ │ ├── architecture.json
258
+ │ ├── quality.json
259
+ │ ├── action-items.json
260
+ │ ├── performance.json
261
+ │ ├── maintainability.json
262
+ │ └── best-practices.json
263
+ ├── iterations/ # Deep-dive results
264
+ │ ├── iteration-1-finding-{uuid}.json
265
+ │ └── iteration-2-finding-{uuid}.json
266
+ └── reports/ # Human-readable reports
267
+ ├── security-analysis.md
268
+ ├── security-cli-output.txt
269
+ ├── deep-dive-1-{uuid}.md
270
+ └── ...
271
+ ```
272
+
273
+ **Session Context**:
274
+ ```
275
+ .workflow/active/WFS-{session-id}/
276
+ ├── workflow-session.json
277
+ ├── IMPL_PLAN.md
278
+ ├── TODO_LIST.md
279
+ ├── .task/
280
+ ├── .summaries/
281
+ └── .review/ # Review results (this command)
282
+ └── (structure above)
283
+ ```
284
+
285
+ ### Review State JSON
286
+
287
+ **Purpose**: Unified state machine and metadata (merged from metadata + state)
288
+
289
+ ```json
290
+ {
291
+ "review_id": "review-20250125-143022",
292
+ "review_type": "module",
293
+ "session_id": "WFS-auth-system",
294
+ "metadata": {
295
+ "created_at": "2025-01-25T14:30:22Z",
296
+ "target_pattern": "src/auth/**",
297
+ "resolved_files": [
298
+ "src/auth/service.ts",
299
+ "src/auth/validator.ts",
300
+ "src/auth/middleware.ts"
301
+ ],
302
+ "dimensions": ["security", "architecture", "quality", "action-items", "performance", "maintainability", "best-practices"],
303
+ "max_iterations": 3
304
+ },
305
+ "phase": "parallel|aggregate|iterate|complete",
306
+ "current_iteration": 1,
307
+ "dimensions_reviewed": ["security", "architecture", "quality", "action-items", "performance", "maintainability", "best-practices"],
308
+ "selected_strategy": "comprehensive",
309
+ "next_action": "execute_parallel_reviews|aggregate_findings|execute_deep_dive|generate_final_report|complete",
310
+ "severity_distribution": {
311
+ "critical": 2,
312
+ "high": 5,
313
+ "medium": 12,
314
+ "low": 8
315
+ },
316
+ "critical_files": [...],
317
+ "iterations": [...],
318
+ "completion_criteria": {...}
319
+ }
320
+ ```
321
+
322
+ ### Review Progress JSON
323
+
324
+ **Purpose**: Real-time dashboard updates via polling
325
+
326
+ ```json
327
+ {
328
+ "review_id": "review-20250125-143022",
329
+ "last_update": "2025-01-25T14:35:10Z",
330
+ "phase": "parallel|aggregate|iterate|complete",
331
+ "current_iteration": 1,
332
+ "progress": {
333
+ "parallel_review": {
334
+ "total_dimensions": 7,
335
+ "completed": 5,
336
+ "in_progress": 2,
337
+ "percent_complete": 71
338
+ },
339
+ "deep_dive": {
340
+ "total_findings": 6,
341
+ "analyzed": 2,
342
+ "in_progress": 1,
343
+ "percent_complete": 33
344
+ }
345
+ },
346
+ "agent_status": [
347
+ {
348
+ "agent_type": "review-agent",
349
+ "dimension": "security",
350
+ "status": "completed",
351
+ "started_at": "2025-01-25T14:30:00Z",
352
+ "completed_at": "2025-01-25T15:15:00Z",
353
+ "duration_ms": 2700000
354
+ },
355
+ {
356
+ "agent_type": "deep-dive-agent",
357
+ "finding_id": "sec-001-uuid",
358
+ "status": "in_progress",
359
+ "started_at": "2025-01-25T14:32:00Z"
360
+ }
361
+ ],
362
+ "estimated_completion": "2025-01-25T16:00:00Z"
363
+ }
364
+ ```
365
+
366
+ ### Agent Output Schemas
367
+
368
+ **Agent-produced JSON files follow standardized schemas**:
369
+
370
+ 1. **Dimension Results** (cli-explore-agent output from parallel reviews)
371
+ - Schema: `~/.ccw/workflows/cli-templates/schemas/review-dimension-results-schema.json`
372
+ - Output: `{output-dir}/dimensions/{dimension}.json`
373
+ - Contains: findings array, summary statistics, cross_references
374
+
375
+ 2. **Deep-Dive Results** (cli-explore-agent output from iterations)
376
+ - Schema: `~/.ccw/workflows/cli-templates/schemas/review-deep-dive-results-schema.json`
377
+ - Output: `{output-dir}/iterations/iteration-{N}-finding-{uuid}.json`
378
+ - Contains: root_cause, remediation_plan, impact_assessment, reassessed_severity
379
+
380
+ ### Agent Invocation Template
381
+
382
+ **Review Agent** (parallel execution, 7 instances):
383
+
384
+ ```javascript
385
+ Task(
386
+ subagent_type="cli-explore-agent",
387
+ run_in_background=false,
388
+ description=`Execute ${dimension} review analysis via Deep Scan`,
389
+ prompt=`
390
+ ## Task Objective
391
+ Conduct comprehensive ${dimension} code exploration and analysis using Deep Scan mode (Bash + Gemini dual-source strategy) for specified module files
392
+
393
+ ## Analysis Mode Selection
394
+ Use **Deep Scan mode** for this review:
395
+ - Phase 1: Bash structural scan for standard patterns (classes, functions, imports)
396
+ - Phase 2: Gemini semantic analysis for design intent, non-standard patterns, ${dimension}-specific concerns
397
+ - Phase 3: Synthesis with attribution (bash-discovered vs gemini-discovered findings)
398
+
399
+ ## MANDATORY FIRST STEPS (Execute by Agent)
400
+ **You (cli-explore-agent) MUST execute these steps in order:**
401
+ 1. Read review state: ${reviewStateJsonPath}
402
+ 2. Get target files: Read resolved_files from review-state.json
403
+ 3. Validate file access: bash(ls -la ${targetFiles.join(' ')})
404
+ 4. Execute: cat ~/.ccw/workflows/cli-templates/schemas/review-dimension-results-schema.json (get output schema reference)
405
+ 5. Read: .workflow/project-tech.json (technology stack and architecture context)
406
+ 6. Read: .workflow/specs/*.md (user-defined constraints and conventions to validate against)
407
+
408
+ ## Review Context
409
+ - Review Type: module (independent)
410
+ - Review Dimension: ${dimension}
411
+ - Review ID: ${reviewId}
412
+ - Target Pattern: ${targetPattern}
413
+ - Resolved Files: ${resolvedFiles.length} files
414
+ - Output Directory: ${outputDir}
415
+
416
+ ## CLI Configuration
417
+ - Tool Priority: gemini → qwen → codex (fallback chain)
418
+ - Custom Focus: ${customFocus || 'Standard dimension analysis'}
419
+ - Mode: analysis (READ-ONLY)
420
+ - Context Pattern: ${targetFiles.map(f => `@${f}`).join(' ')}
421
+
422
+ ## Expected Deliverables
423
+
424
+ **Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 4, follow schema exactly
425
+
426
+ 1. Dimension Results JSON: ${outputDir}/dimensions/${dimension}.json
427
+
428
+ **⚠️ CRITICAL JSON STRUCTURE REQUIREMENTS**:
429
+
430
+ Root structure MUST be array: \`[{ ... }]\` NOT \`{ ... }\`
431
+
432
+ Required top-level fields:
433
+ - dimension, review_id, analysis_timestamp (NOT timestamp/analyzed_at)
434
+ - cli_tool_used (gemini|qwen|codex), model, analysis_duration_ms
435
+ - summary (FLAT structure), findings, cross_references
436
+
437
+ Summary MUST be FLAT (NOT nested by_severity):
438
+ \`{ "total_findings": N, "critical": N, "high": N, "medium": N, "low": N, "files_analyzed": N, "lines_reviewed": N }\`
439
+
440
+ Finding required fields:
441
+ - id: format \`{dim}-{seq}-{uuid8}\` e.g., \`sec-001-a1b2c3d4\` (lowercase)
442
+ - severity: lowercase only (critical|high|medium|low)
443
+ - snippet (NOT code_snippet), impact (NOT exploit_scenario)
444
+ - metadata, iteration (0), status (pending_remediation), cross_references
445
+
446
+ 2. Analysis Report: ${outputDir}/reports/${dimension}-analysis.md
447
+ - Human-readable summary with recommendations
448
+ - Grouped by severity: critical → high → medium → low
449
+ - Include file:line references for all findings
450
+
451
+ 3. CLI Output Log: ${outputDir}/reports/${dimension}-cli-output.txt
452
+ - Raw CLI tool output for debugging
453
+ - Include full analysis text
454
+
455
+ ## Dimension-Specific Guidance
456
+ ${getDimensionGuidance(dimension)}
457
+
458
+ ## Success Criteria
459
+ - [ ] Schema obtained via cat review-dimension-results-schema.json
460
+ - [ ] All target files analyzed for ${dimension} concerns
461
+ - [ ] All findings include file:line references with code snippets
462
+ - [ ] Severity assessment follows established criteria (see reference)
463
+ - [ ] Recommendations are actionable with code examples
464
+ - [ ] JSON output follows schema exactly
465
+ - [ ] Report is comprehensive and well-organized
466
+ `
467
+ )
468
+ ```
469
+
470
+ **Deep-Dive Agent** (iteration execution):
471
+
472
+ ```javascript
473
+ Task(
474
+ subagent_type="cli-explore-agent",
475
+ run_in_background=false,
476
+ description=`Deep-dive analysis for critical finding: ${findingTitle} via Dependency Map + Deep Scan`,
477
+ prompt=`
478
+ ## Task Objective
479
+ Perform focused root cause analysis using Dependency Map mode (for impact analysis) + Deep Scan mode (for semantic understanding) to generate comprehensive remediation plan for critical ${dimension} issue
480
+
481
+ ## Analysis Mode Selection
482
+ Use **Dependency Map mode** first to understand dependencies:
483
+ - Build dependency graph around ${file} to identify affected components
484
+ - Detect circular dependencies or tight coupling related to this finding
485
+ - Calculate change risk scores for remediation impact
486
+
487
+ Then apply **Deep Scan mode** for semantic analysis:
488
+ - Understand design intent and architectural context
489
+ - Identify non-standard patterns or implicit dependencies
490
+ - Extract remediation insights from code structure
491
+
492
+ ## Finding Context
493
+ - Finding ID: ${findingId}
494
+ - Original Dimension: ${dimension}
495
+ - Title: ${findingTitle}
496
+ - File: ${file}:${line}
497
+ - Severity: ${severity}
498
+ - Category: ${category}
499
+ - Original Description: ${description}
500
+ - Iteration: ${iteration}
501
+
502
+ ## MANDATORY FIRST STEPS (Execute by Agent)
503
+ **You (cli-explore-agent) MUST execute these steps in order:**
504
+ 1. Read original finding: ${dimensionJsonPath}
505
+ 2. Read affected file: ${file}
506
+ 3. Identify related code: bash(grep -r "import.*${basename(file)}" ${projectDir}/src --include="*.ts")
507
+ 4. Read test files: bash(find ${projectDir}/tests -name "*${basename(file, '.ts')}*" -type f)
508
+ 5. Execute: cat ~/.ccw/workflows/cli-templates/schemas/review-deep-dive-results-schema.json (get output schema reference)
509
+ 6. Read: .workflow/project-tech.json (technology stack and architecture context)
510
+ 7. Read: .workflow/specs/*.md (user-defined constraints for remediation compliance)
511
+
512
+ ## CLI Configuration
513
+ - Tool Priority: gemini → qwen → codex
514
+ - Template: ~/.ccw/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt
515
+ - Mode: analysis (READ-ONLY)
516
+
517
+ ## Expected Deliverables
518
+
519
+ **Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 5, follow schema exactly
520
+
521
+ 1. Deep-Dive Results JSON: ${outputDir}/iterations/iteration-${iteration}-finding-${findingId}.json
522
+
523
+ **⚠️ CRITICAL JSON STRUCTURE REQUIREMENTS**:
524
+
525
+ Root structure MUST be array: \`[{ ... }]\` NOT \`{ ... }\`
526
+
527
+ Required top-level fields:
528
+ - finding_id, dimension, iteration, analysis_timestamp
529
+ - cli_tool_used, model, analysis_duration_ms
530
+ - original_finding, root_cause, remediation_plan
531
+ - impact_assessment, reassessed_severity, confidence_score, cross_references
532
+
533
+ All nested objects must follow schema exactly - read schema for field names
534
+
535
+ 2. Analysis Report: ${outputDir}/reports/deep-dive-${iteration}-${findingId}.md
536
+ - Detailed root cause analysis
537
+ - Step-by-step remediation plan
538
+ - Impact assessment and rollback strategy
539
+
540
+ ## Success Criteria
541
+ - [ ] Schema obtained via cat review-deep-dive-results-schema.json
542
+ - [ ] Root cause clearly identified with supporting evidence
543
+ - [ ] Remediation plan is step-by-step actionable with exact file:line references
544
+ - [ ] Each step includes specific commands and validation tests
545
+ - [ ] Impact fully assessed (files, tests, breaking changes, dependencies)
546
+ - [ ] Severity re-evaluation justified with evidence
547
+ - [ ] Confidence score accurately reflects certainty of analysis
548
+ - [ ] JSON output follows schema exactly
549
+ - [ ] References include project-specific and external documentation
550
+ `
551
+ )
552
+ ```
553
+
554
+ ### Dimension Guidance Reference
555
+
556
+ ```javascript
557
+ function getDimensionGuidance(dimension) {
558
+ const guidance = {
559
+ security: `
560
+ Focus Areas:
561
+ - Input validation and sanitization
562
+ - Authentication and authorization mechanisms
563
+ - Data encryption (at-rest and in-transit)
564
+ - SQL/NoSQL injection vulnerabilities
565
+ - XSS, CSRF, and other web vulnerabilities
566
+ - Sensitive data exposure
567
+ - Access control and privilege escalation
568
+
569
+ Severity Criteria:
570
+ - Critical: Authentication bypass, SQL injection, RCE, sensitive data exposure
571
+ - High: Missing authorization checks, weak encryption, exposed secrets
572
+ - Medium: Missing input validation, insecure defaults, weak password policies
573
+ - Low: Security headers missing, verbose error messages, outdated dependencies
574
+ `,
575
+ architecture: `
576
+ Focus Areas:
577
+ - Layering and separation of concerns
578
+ - Coupling and cohesion
579
+ - Design pattern adherence
580
+ - Dependency management
581
+ - Scalability and extensibility
582
+ - Module boundaries
583
+ - API design consistency
584
+
585
+ Severity Criteria:
586
+ - Critical: Circular dependencies, god objects, tight coupling across layers
587
+ - High: Violated architectural principles, scalability bottlenecks
588
+ - Medium: Missing abstractions, inconsistent patterns, suboptimal design
589
+ - Low: Minor coupling issues, documentation gaps, naming inconsistencies
590
+ `,
591
+ quality: `
592
+ Focus Areas:
593
+ - Code duplication
594
+ - Complexity (cyclomatic, cognitive)
595
+ - Naming conventions
596
+ - Error handling patterns
597
+ - Code readability
598
+ - Comment quality
599
+ - Dead code
600
+
601
+ Severity Criteria:
602
+ - Critical: Severe complexity (CC > 20), massive duplication (>50 lines)
603
+ - High: High complexity (CC > 10), significant duplication, poor error handling
604
+ - Medium: Moderate complexity (CC > 5), naming issues, code smells
605
+ - Low: Minor duplication, documentation gaps, cosmetic issues
606
+ `,
607
+ 'action-items': `
608
+ Focus Areas:
609
+ - Requirements coverage verification
610
+ - Acceptance criteria met
611
+ - Documentation completeness
612
+ - Deployment readiness
613
+ - Missing functionality
614
+ - Test coverage gaps
615
+ - Configuration management
616
+
617
+ Severity Criteria:
618
+ - Critical: Core requirements not met, deployment blockers
619
+ - High: Significant functionality missing, acceptance criteria not met
620
+ - Medium: Minor requirements gaps, documentation incomplete
621
+ - Low: Nice-to-have features missing, minor documentation gaps
622
+ `,
623
+ performance: `
624
+ Focus Areas:
625
+ - N+1 query problems
626
+ - Inefficient algorithms (O(n²) where O(n log n) possible)
627
+ - Memory leaks
628
+ - Blocking operations on main thread
629
+ - Missing caching opportunities
630
+ - Resource usage (CPU, memory, network)
631
+ - Database query optimization
632
+
633
+ Severity Criteria:
634
+ - Critical: Memory leaks, O(n²) in hot path, blocking main thread
635
+ - High: N+1 queries, missing indexes, inefficient algorithms
636
+ - Medium: Suboptimal caching, unnecessary computations, lazy loading issues
637
+ - Low: Minor optimization opportunities, redundant operations
638
+ `,
639
+ maintainability: `
640
+ Focus Areas:
641
+ - Technical debt indicators
642
+ - Magic numbers and hardcoded values
643
+ - Long methods (>50 lines)
644
+ - Large classes (>500 lines)
645
+ - Dead code and commented code
646
+ - Code documentation
647
+ - Test coverage
648
+
649
+ Severity Criteria:
650
+ - Critical: Massive methods (>200 lines), severe technical debt blocking changes
651
+ - High: Large methods (>100 lines), significant dead code, undocumented complex logic
652
+ - Medium: Magic numbers, moderate technical debt, missing tests
653
+ - Low: Minor refactoring opportunities, cosmetic improvements
654
+ `,
655
+ 'best-practices': `
656
+ Focus Areas:
657
+ - Framework conventions adherence
658
+ - Language idioms
659
+ - Anti-patterns
660
+ - Deprecated API usage
661
+ - Coding standards compliance
662
+ - Error handling patterns
663
+ - Logging and monitoring
664
+
665
+ Severity Criteria:
666
+ - Critical: Severe anti-patterns, deprecated APIs with security risks
667
+ - High: Major convention violations, poor error handling, missing logging
668
+ - Medium: Minor anti-patterns, style inconsistencies, suboptimal patterns
669
+ - Low: Cosmetic style issues, minor convention deviations
670
+ `
671
+ };
672
+
673
+ return guidance[dimension] || 'Standard code review analysis';
674
+ }
675
+ ```
676
+
677
+ ### Completion Conditions
678
+
679
+ **Full Success**:
680
+ - All dimensions reviewed
681
+ - Critical findings = 0
682
+ - High findings ≤ 5
683
+ - Action: Generate final report, mark phase=complete
684
+
685
+ **Partial Success**:
686
+ - All dimensions reviewed
687
+ - Max iterations reached
688
+ - Still have critical/high findings
689
+ - Action: Generate report with warnings, recommend follow-up
690
+
691
+ ### Error Handling
692
+
693
+ **Phase-Level Error Matrix**:
694
+
695
+ | Phase | Error | Blocking? | Action |
696
+ |-------|-------|-----------|--------|
697
+ | Phase 1 | Invalid path pattern | Yes | Error and exit |
698
+ | Phase 1 | No files matched | Yes | Error and exit |
699
+ | Phase 1 | Files not readable | Yes | Error and exit |
700
+ | Phase 2 | Single dimension fails | No | Log warning, continue other dimensions |
701
+ | Phase 2 | All dimensions fail | Yes | Error and exit |
702
+ | Phase 3 | Missing dimension JSON | No | Skip in aggregation, log warning |
703
+ | Phase 4 | Deep-dive agent fails | No | Skip finding, continue others |
704
+ | Phase 4 | Max iterations reached | No | Generate partial report |
705
+
706
+ **CLI Fallback Chain**: Gemini → Qwen → Codex → degraded mode
707
+
708
+ **Fallback Triggers**:
709
+ 1. HTTP 429, 5xx errors, connection timeout
710
+ 2. Invalid JSON output (parse error, missing required fields)
711
+ 3. Low confidence score < 0.4
712
+ 4. Analysis too brief (< 100 words in report)
713
+
714
+ **Fallback Behavior**:
715
+ - On trigger: Retry with next tool in chain
716
+ - After Codex fails: Enter degraded mode (skip analysis, log error)
717
+ - Degraded mode: Continue workflow with available results
718
+
719
+ ### TodoWrite Structure
720
+
721
+ ```javascript
722
+ TodoWrite({
723
+ todos: [
724
+ { content: "Phase 1: Discovery & Initialization", status: "completed", activeForm: "Initializing" },
725
+ { content: "Phase 2: Parallel Reviews (7 dimensions)", status: "in_progress", activeForm: "Reviewing" },
726
+ { content: " → Security review", status: "in_progress", activeForm: "Analyzing security" },
727
+ // ... other dimensions as sub-items
728
+ { content: "Phase 3: Aggregation", status: "pending", activeForm: "Aggregating" },
729
+ { content: "Phase 4: Deep-dive", status: "pending", activeForm: "Deep-diving" },
730
+ { content: "Phase 5: Completion", status: "pending", activeForm: "Completing" }
731
+ ]
732
+ });
733
+ ```
734
+
735
+ ## Best Practices
736
+
737
+ 1. **Start Specific**: Begin with focused module patterns for faster results
738
+ 2. **Expand Gradually**: Add more modules based on initial findings
739
+ 3. **Use Glob Wisely**: `src/auth/**` is more efficient than `src/**` with lots of irrelevant files
740
+ 4. **Trust Aggregation Logic**: Auto-selection based on proven heuristics
741
+ 5. **Monitor Logs**: Check reports/ directory for CLI analysis insights
742
+
743
+ ## Related Commands
744
+
745
+ ### View Review Progress
746
+ Use `ccw view` to open the review dashboard in browser:
747
+
748
+ ```bash
749
+ ccw view
750
+ ```
751
+
752
+ ### Automated Fix Workflow
753
+ After completing a module review, use the generated findings JSON for automated fixing:
754
+
755
+ ```bash
756
+ # Step 1: Complete review (this command)
757
+ /workflow:review-module-cycle src/auth/**
758
+
759
+ # Step 2: Run automated fixes using dimension findings
760
+ /workflow:review-cycle-fix .workflow/active/WFS-{session-id}/.review/
761
+ ```
762
+
763
+ See `review-cycle` skill (fix phase) for automated fixing with smart grouping, parallel execution, and test verification.
764
+