11---
22name : review-cycle-fix
33description : Automated fixing of code review findings with AI-powered planning and coordinated execution. Uses intelligent grouping, multi-stage timeline coordination, and test-driven verification.
4- argument-hint : " <export-file|review-dir> [--resume] [--max-iterations=N]"
4+ argument-hint : " <export-file|review-dir> [--resume] [--max-iterations=N] [--batch-size=N] "
55allowed-tools : Skill(*), TodoWrite(*), Read(*), Bash(*), Task(*), Edit(*), Write(*)
66---
77
@@ -21,37 +21,45 @@ allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*), Task(*), Edit(*), Write
2121
2222# Custom max retry attempts per finding
2323/workflow:review-cycle-fix .workflow/active/WFS-123/.review/ --max-iterations=5
24+
25+ # Custom batch size for parallel planning (default: 5 findings per batch)
26+ /workflow:review-cycle-fix .workflow/active/WFS-123/.review/ --batch-size=3
2427```
2528
2629** Fix Source** : Exported findings from review cycle dashboard
2730** Output Directory** : ` {review-dir}/fixes/{fix-session-id}/ ` (within session .review/)
2831** Default Max Iterations** : 3 (per finding, adjustable)
32+ ** Default Batch Size** : 5 (findings per planning batch, adjustable)
33+ ** Max Parallel Agents** : 10 (concurrent planning agents)
2934** CLI Tools** : @cli-planning-agent (planning), @cli-execute-agent (fixing)
3035
3136## What & Why
3237
3338### Core Concept
34- Automated fix orchestrator with ** two-phase architecture** : AI-powered planning followed by coordinated parallel/serial execution. Generates fix timeline with intelligent grouping and dependency analysis, then executes fixes with conservative test verification.
39+ Automated fix orchestrator with ** parallel planning architecture** : Multiple AI agents analyze findings concurrently in batches, then coordinate parallel/serial execution. Generates fix timeline with intelligent grouping and dependency analysis, executes fixes with conservative test verification.
3540
3641** Fix Process** :
37- - ** Planning Phase** : AI analyzes findings, generates fix plan with grouping and execution strategy
38- - ** Execution Phase** : Main orchestrator coordinates agents per timeline stages
42+ - ** Batching Phase (1.5)** : Orchestrator groups findings by file+dimension similarity, creates batches
43+ - ** Planning Phase (2)** : Up to 10 agents plan batches in parallel, generate partial plans, orchestrator aggregates
44+ - ** Execution Phase (3)** : Main orchestrator coordinates agents per aggregated timeline stages
45+ - ** Parallel Efficiency** : Customizable batch size (default: 5), MAX_PARALLEL=10 agents
3946- ** No rigid structure** : Adapts to task requirements, not bound to fixed JSON format
4047
4148** vs Manual Fixing** :
4249- ** Manual** : Developer reviews findings one-by-one, fixes sequentially
43- - ** Automated** : AI groups related issues, executes in optimal parallel/serial order with automatic test verification
50+ - ** Automated** : AI groups related issues, multiple agents plan in parallel, executes in optimal parallel/serial order with automatic test verification
4451
4552### Value Proposition
46- 1 . ** Intelligent Planning** : AI-powered analysis identifies optimal grouping and execution strategy
47- 2 . ** Multi-stage Coordination** : Supports complex parallel + serial execution with dependency management
48- 3 . ** Conservative Safety** : Mandatory test verification with automatic rollback on failure
49- 4 . ** Resume Support** : Checkpoint-based recovery for interrupted sessions
53+ 1 . ** Parallel Planning** : Multiple agents analyze findings concurrently, reducing planning time for large batches (10+ findings)
54+ 2 . ** Intelligent Batching** : Semantic similarity grouping ensures related findings are analyzed together
55+ 3 . ** Multi-stage Coordination** : Supports complex parallel + serial execution with cross-batch dependency management
56+ 4 . ** Conservative Safety** : Mandatory test verification with automatic rollback on failure
57+ 5 . ** Resume Support** : Checkpoint-based recovery for interrupted sessions
5058
5159### Orchestrator Boundary (CRITICAL)
5260- ** ONLY command** for automated review finding fixes
53- - Manages: Planning phase coordination, stage-based execution, agent scheduling, progress tracking
54- - Delegates: Fix planning to @cli-planning-agent , fix execution to @cli-execute-agent
61+ - Manages: Intelligent batching (Phase 1.5), parallel planning coordination (launch N agents), plan aggregation , stage-based execution, agent scheduling, progress tracking
62+ - Delegates: Batch planning to @cli-planning-agent , fix execution to @cli-execute-agent
5563
5664
5765### Execution Flow
@@ -60,12 +68,22 @@ Automated fix orchestrator with **two-phase architecture**: AI-powered planning
6068Phase 1: Discovery & Initialization
6169 └─ Validate export file, create fix session structure, initialize state files
6270
63- Phase 2: Planning Coordination (@cli-planning-agent)
64- ├─ Analyze findings for patterns and dependencies
65- ├─ Group by file + dimension + root cause similarity
66- ├─ Determine execution strategy (parallel/serial/hybrid)
67- ├─ Generate fix timeline with stages
68- └─ Output: fix-plan.json
71+ Phase 1.5: Intelligent Grouping & Batching
72+ ├─ Analyze findings metadata (file, dimension, severity)
73+ ├─ Group by semantic similarity (file proximity + dimension affinity)
74+ ├─ Create batches respecting --batch-size (default: 5)
75+ └─ Output: Finding batches for parallel planning
76+
77+ Phase 2: Parallel Planning Coordination (@cli-planning-agent × N)
78+ ├─ Launch MAX_PARALLEL planning agents concurrently (default: 10)
79+ ├─ Each agent processes one batch:
80+ │ ├─ Analyze findings for patterns and dependencies
81+ │ ├─ Group by file + dimension + root cause similarity
82+ │ ├─ Determine execution strategy (parallel/serial/hybrid)
83+ │ ├─ Generate fix timeline with stages
84+ │ └─ Output: partial-plan-{batch-id}.json
85+ ├─ Collect results from all agents
86+ └─ Aggregate: Merge partial plans → fix-plan.json (resolve cross-batch dependencies)
6987
7088Phase 3: Execution Orchestration (Stage-based)
7189 For each timeline stage:
@@ -91,25 +109,29 @@ Phase 5: Session Completion (Optional)
91109
92110| Agent | Responsibility |
93111| -------| ---------------|
94- | ** Orchestrator** | Input validation, session management, planning coordination, stage-based execution scheduling, progress tracking, aggregation |
95- | ** @cli-planning-agent ** | Findings analysis, intelligent grouping (file+dimension+root cause), execution strategy determination (parallel/serial/hybrid), timeline generation with dependency mapping |
112+ | ** Orchestrator** | Input validation, session management, intelligent batching (Phase 1.5), parallel planning coordination (launch N agents), plan aggregation (merge partial plans, resolve cross-batch dependencies), stage-based execution scheduling, progress tracking, result aggregation |
113+ | ** @cli-planning-agent ** | Batch findings analysis, intelligent grouping (file+dimension+root cause), execution strategy determination (parallel/serial/hybrid), timeline generation with dependency mapping, partial plan output |
96114| ** @cli-execute-agent ** | Fix execution per group, code context analysis, Edit tool operations, test verification, git rollback on failure, completion JSON generation |
97115
98116## Enhanced Features
99117
100- ### 1. Two-Phase Architecture
118+ ### 1. Parallel Planning Architecture
101119
102- ** Phase Separation ** :
120+ ** Batch Processing Strategy ** :
103121
104- | Phase | Agent | Output | Purpose |
105- | -------| -------| --------| ---------|
106- | ** Planning** | @cli-planning-agent | fix-plan.json | Analyze findings, group intelligently, determine optimal execution strategy |
107- | ** Execution** | @cli-execute-agent | completions/* .json | Execute fixes per plan with test verification and rollback |
122+ | Phase | Agent Count | Input | Output | Purpose |
123+ | -------| -------------| -------| --------| ---------|
124+ | ** Batching (1.5)** | Orchestrator | All findings | Finding batches | Semantic grouping by file+dimension, respecting --batch-size |
125+ | ** Planning (2)** | N agents (≤10) | 1 batch each | partial-plan-{batch-id}.json | Analyze batch in parallel, generate execution groups and timeline |
126+ | ** Aggregation (2)** | Orchestrator | All partial plans | fix-plan.json | Merge timelines, resolve cross-batch dependencies |
127+ | ** Execution (3)** | M agents (dynamic) | 1 group each | fix-progress-{N}.json | Execute fixes per aggregated plan with test verification |
108128
109129** Benefits** :
110- - Clear separation of concerns (analysis vs execution)
111- - Reusable plans (can re-execute without re-planning)
112- - Better error isolation (planning failures vs execution failures)
130+ - ** Speed** : N agents plan concurrently, reducing planning time for large batches
131+ - ** Scalability** : MAX_PARALLEL=10 prevents resource exhaustion
132+ - ** Flexibility** : Batch size customizable via --batch-size (default: 5)
133+ - ** Isolation** : Each planning agent focuses on related findings (semantic grouping)
134+ - ** Reusable** : Aggregated plan can be re-executed without re-planning
113135
114136### 2. Intelligent Grouping Strategy
115137
@@ -197,12 +219,30 @@ if (result.passRate < 100%) {
197219- Session creation: Generate fix-session-id (` fix-{timestamp} ` )
198220- Directory structure: Create ` {review-dir}/fixes/{fix-session-id}/ ` with subdirectories
199221- State files: Initialize active-fix-session.json (session marker)
200- - TodoWrite initialization: Set up 4-phase tracking
201-
202- ** Phase 2: Planning Coordination**
203- - Launch @cli-planning-agent with findings data and project context
204- - Validate fix-plan.json output (schema conformance, includes metadata with session status)
205- - Load plan into memory for execution phase
222+ - TodoWrite initialization: Set up 5-phase tracking (including Phase 1.5)
223+
224+ ** Phase 1.5: Intelligent Grouping & Batching**
225+ - Load all findings metadata (id, file, dimension, severity, title)
226+ - Semantic similarity analysis:
227+ - Primary: Group by file proximity (same file or related modules)
228+ - Secondary: Group by dimension affinity (same review dimension)
229+ - Tertiary: Analyze title/description similarity (root cause clustering)
230+ - Create batches respecting --batch-size (default: 5 findings per batch)
231+ - Balance workload: Distribute high-severity findings across batches
232+ - Output: Array of finding batches for parallel planning
233+
234+ ** Phase 2: Parallel Planning Coordination**
235+ - Determine concurrency: MIN(batch_count, MAX_PARALLEL=10)
236+ - For each batch chunk (≤10 batches):
237+ - Launch all agents in parallel with run_in_background=true
238+ - Pass batch findings + project context + batch_id to each agent
239+ - Each agent outputs: partial-plan-{batch-id}.json
240+ - Collect results via TaskOutput (blocking until all complete)
241+ - Aggregate partial plans:
242+ - Merge execution groups (renumber group_ids sequentially: G1, G2, ...)
243+ - Merge timelines (detect cross-batch dependencies, adjust stages)
244+ - Resolve conflicts (same file in multiple batches → serialize)
245+ - Generate final fix-plan.json with aggregated metadata
206246- TodoWrite update: Mark planning complete, start execution
207247
208248** Phase 3: Execution Orchestration**
@@ -236,7 +276,10 @@ if (result.passRate < 100%) {
236276.workflow/active/WFS-{session-id}/.review/
237277├── fix-export-{timestamp}.json # Exported findings (input)
238278└── fixes/{fix-session-id}/
239- ├── fix-plan.json # Planning agent output (execution plan with metadata)
279+ ├── partial-plan-1.json # Batch 1 partial plan (planning agent 1 output)
280+ ├── partial-plan-2.json # Batch 2 partial plan (planning agent 2 output)
281+ ├── partial-plan-N.json # Batch N partial plan (planning agent N output)
282+ ├── fix-plan.json # Aggregated execution plan (orchestrator merges partials)
240283 ├── fix-progress-1.json # Group 1 progress (planning agent init → agent updates)
241284 ├── fix-progress-2.json # Group 2 progress (planning agent init → agent updates)
242285 ├── fix-progress-3.json # Group 3 progress (planning agent init → agent updates)
@@ -246,28 +289,126 @@ if (result.passRate < 100%) {
246289```
247290
248291** File Producers** :
249- - ** Planning Agent** : ` fix-plan.json ` (with metadata), all ` fix-progress-*.json ` (initial state)
250- - ** Execution Agents** : Update assigned ` fix-progress-{N}.json ` in real-time
292+ - ** Orchestrator** : Batches findings (Phase 1.5), aggregates partial plans → ` fix-plan.json ` (Phase 2), launches parallel planning agents
293+ - ** Planning Agents (N)** : Each outputs ` partial-plan-{batch-id}.json ` + initializes ` fix-progress-*.json ` for assigned groups
294+ - ** Execution Agents (M)** : Update assigned ` fix-progress-{N}.json ` in real-time
251295
252296
253297### Agent Invocation Template
254298
255- ** Planning Agent** :
299+ ** Phase 1.5: Intelligent Batching** (Orchestrator):
300+ ``` javascript
301+ // Load findings
302+ const findings = JSON .parse (Read (exportFile));
303+ const batchSize = flags .batchSize || 5 ;
304+
305+ // Semantic similarity analysis: group by file+dimension
306+ const batches = [];
307+ const grouped = new Map (); // key: "${file}:${dimension}"
308+
309+ for (const finding of findings) {
310+ const key = ` ${ finding .file || ' unknown' } :${ finding .dimension || ' general' } ` ;
311+ if (! grouped .has (key)) grouped .set (key, []);
312+ grouped .get (key).push (finding);
313+ }
314+
315+ // Create batches respecting batchSize
316+ for (const [key , group ] of grouped) {
317+ while (group .length > 0 ) {
318+ const batch = group .splice (0 , batchSize);
319+ batches .push ({
320+ batch_id: batches .length + 1 ,
321+ findings: batch,
322+ metadata: { primary_file: batch[0 ].file , primary_dimension: batch[0 ].dimension }
323+ });
324+ }
325+ }
326+
327+ console .log (` Created ${ batches .length } batches (${ batchSize} findings per batch)` );
328+ ```
329+
330+ ** Phase 2: Parallel Planning** (Orchestrator launches N agents):
331+ ``` javascript
332+ const MAX_PARALLEL = 10 ;
333+ const partialPlans = [];
334+
335+ // Process batches in chunks of MAX_PARALLEL
336+ for (let i = 0 ; i < batches .length ; i += MAX_PARALLEL ) {
337+ const chunk = batches .slice (i, i + MAX_PARALLEL );
338+ const taskIds = [];
339+
340+ // Launch agents in parallel (run_in_background=true)
341+ for (const batch of chunk) {
342+ const taskId = Task ({
343+ subagent_type: " cli-planning-agent" ,
344+ run_in_background: true ,
345+ description: ` Plan batch ${ batch .batch_id } : ${ batch .findings .length } findings` ,
346+ prompt: planningPrompt (batch) // See Planning Agent template below
347+ });
348+ taskIds .push ({ taskId, batch });
349+ }
350+
351+ console .log (` Launched ${ taskIds .length } planning agents...` );
352+
353+ // Collect results from this chunk (blocking)
354+ for (const { taskId , batch } of taskIds) {
355+ const result = TaskOutput ({ task_id: taskId, block: true });
356+ const partialPlan = JSON .parse (Read (` ${ sessionDir} /partial-plan-${ batch .batch_id } .json` ));
357+ partialPlans .push (partialPlan);
358+ updateTodo (` Batch ${ batch .batch_id } ` , ' completed' );
359+ }
360+ }
361+
362+ // Aggregate partial plans → fix-plan.json
363+ let groupCounter = 1 ;
364+ const groupIdMap = new Map ();
365+
366+ for (const partial of partialPlans) {
367+ for (const group of partial .groups ) {
368+ const newGroupId = ` G${ groupCounter} ` ;
369+ groupIdMap .set (` ${ partial .batch_id } :${ group .group_id } ` , newGroupId);
370+ aggregatedPlan .groups .push ({ ... group, group_id: newGroupId, progress_file: ` fix-progress-${ groupCounter} .json` });
371+ groupCounter++ ;
372+ }
373+ }
374+
375+ // Merge timelines, resolve cross-batch conflicts (shared files → serialize)
376+ let stageCounter = 1 ;
377+ for (const partial of partialPlans) {
378+ for (const stage of partial .timeline ) {
379+ aggregatedPlan .timeline .push ({
380+ ... stage, stage_id: stageCounter,
381+ groups: stage .groups .map (gid => groupIdMap .get (` ${ partial .batch_id } :${ gid} ` ))
382+ });
383+ stageCounter++ ;
384+ }
385+ }
386+
387+ // Write aggregated plan + initialize progress files
388+ Write (` ${ sessionDir} /fix-plan.json` , JSON .stringify (aggregatedPlan, null , 2 ));
389+ for (let i = 1 ; i <= aggregatedPlan .groups .length ; i++ ) {
390+ Write (` ${ sessionDir} /fix-progress-${ i} .json` , JSON .stringify (initProgressFile (aggregatedPlan .groups [i- 1 ]), null , 2 ));
391+ }
392+ ```
393+
394+ ** Planning Agent (Batch Mode - Partial Plan Only)** :
256395``` javascript
257396Task ({
258397 subagent_type: " cli-planning-agent" ,
259- description: ` Generate fix plan and initialize progress files for ${ findings .length } findings` ,
398+ run_in_background: true ,
399+ description: ` Plan batch ${ batch .batch_id } : ${ batch .findings .length } findings` ,
260400 prompt: `
261401## Task Objective
262- Analyze ${ findings . length } code review findings and generate execution plan with intelligent grouping and timeline coordination .
402+ Analyze code review findings in batch ${ batch . batch_id } and generate **partial** execution plan .
263403
264404## Input Data
265405Review Session: ${ reviewId}
266406Fix Session ID: ${ fixSessionId}
267- Total Findings: ${ findings .length }
407+ Batch ID: ${ batch .batch_id }
408+ Batch Findings: ${ batch .findings .length }
268409
269410Findings:
270- ${ JSON .stringify (findings, null , 2 )}
411+ ${ JSON .stringify (batch . findings , null , 2 )}
271412
272413Project Context:
273414- Structure: ${ projectStructure}
@@ -276,31 +417,23 @@ Project Context:
276417
277418## Output Requirements
278419
279- ### 1. fix-plan.json
280- Execute: cat ~/.claude/workflows/cli-templates/fix-plan-template.json
281-
282- Generate execution plan following template structure:
420+ ### 1. partial-plan-${ batch .batch_id } .json
421+ Generate partial execution plan with structure:
422+ {
423+ "batch_id": ${ batch .batch_id } ,
424+ "groups": [...], // Groups created from batch findings (use local IDs: G1, G2, ...)
425+ "timeline": [...], // Local timeline for this batch only
426+ "metadata": {
427+ "findings_count": ${ batch .findings .length } ,
428+ "groups_count": N,
429+ "created_at": "ISO-8601-timestamp"
430+ }
431+ }
283432
284433**Key Generation Rules**:
285- - **Metadata**: Populate fix_session_id, review_session_id, status ("planning"), created_at, started_at timestamps
286- - **Execution Strategy**: Choose approach (parallel/serial/hybrid) based on dependency analysis, set parallel_limit and stages count
287- - **Groups**: Create groups (G1, G2, ...) with intelligent grouping (see Analysis Requirements below), assign progress files (fix-progress-1.json, ...), populate fix_strategy with approach/complexity/test_pattern, assess risks, identify dependencies
288- - **Timeline**: Define stages respecting dependencies, set execution_mode per stage, map groups to stages, calculate critical path
289-
290- ### 2. fix-progress-{N}.json (one per group)
291- Execute: cat ~/.claude/workflows/cli-templates/fix-progress-template.json
292-
293- For each group (G1, G2, G3, ...), generate fix-progress-{N}.json following template structure:
294-
295- **Initial State Requirements**:
296- - Status: "pending", phase: "waiting"
297- - Timestamps: Set last_update to now, others null
298- - Findings: Populate from review findings with status "pending", all operation fields null
299- - Summary: Initialize all counters to zero
300- - Flow control: Empty implementation_approach array
301- - Errors: Empty array
302-
303- **CRITICAL**: Ensure complete template structure - all fields must be present.
434+ - **Groups**: Create groups with local IDs (G1, G2, ...) using intelligent grouping (file+dimension+root cause)
435+ - **Timeline**: Define stages for this batch only (local dependencies within batch)
436+ - **Progress Files**: DO NOT generate fix-progress-*.json here (orchestrator handles after aggregation)
304437
305438## Analysis Requirements
306439
@@ -318,7 +451,7 @@ Group findings using these criteria (in priority order):
318451- Consider test isolation (different test suites → different groups)
319452- Balance workload across groups for parallel execution
320453
321- ### Execution Strategy Determination
454+ ### Execution Strategy Determination (Local Only)
322455
323456**Parallel Mode**: Use when groups are independent, no shared files
324457**Serial Mode**: Use when groups have dependencies or shared resources
@@ -346,21 +479,16 @@ For each group, determine:
346479## Output Files
347480
348481Write to ${ sessionDir} :
349- - ./fix-plan.json
350- - ./fix-progress-1.json
351- - ./fix-progress-2.json
352- - ./fix-progress-{N}.json (as many as groups created)
482+ - ./partial-plan-${ batch .batch_id } .json
353483
354484## Quality Checklist
355485
356486Before finalizing outputs:
357- - ✅ All findings assigned to exactly one group
358- - ✅ Group dependencies correctly identified
359- - ✅ Timeline stages respect dependencies
360- - ✅ All progress files have complete initial structure
487+ - ✅ All batch findings assigned to exactly one group
488+ - ✅ Group dependencies (within batch) correctly identified
489+ - ✅ Timeline stages respect local dependencies
361490- ✅ Test patterns are valid and specific
362491- ✅ Risk assessments are realistic
363- - ✅ Estimated times are reasonable
364492 `
365493})
366494```
0 commit comments