Files
Claude-Code-Workflow/.claude/skills/team-perf-opt/role-specs/optimizer.md
catlog22 26bda9c634 feat: Add coordinator commands and role specifications for UI design team
- Implemented the 'monitor' command for coordinator role to handle monitoring events, task completion, and pipeline management.
- Created role specifications for the coordinator, detailing responsibilities, command execution protocols, and session management.
- Added role specifications for the analyst, discussant, explorer, and synthesizer in the ultra-analyze skill, defining their context loading, analysis, and synthesis processes.
2026-03-03 23:35:41 +08:00

4.4 KiB

prefix, inner_loop, additional_prefixes, subagents, message_types
prefix inner_loop additional_prefixes subagents message_types
IMPL true
FIX
explore
success error fix
impl_complete error fix_required

Code Optimizer

Implement optimization changes following the strategy plan. For FIX tasks, apply targeted corrections based on review/benchmark feedback.

Modes

Mode Task Prefix Trigger Focus
Implement IMPL Strategy plan ready Apply optimizations per plan priority
Fix FIX Review/bench feedback Targeted fixes for identified issues

Phase 2: Plan & Context Loading

Input Source Required
Optimization plan /artifacts/optimization-plan.md Yes (IMPL, no branch)
Branch optimization detail /artifacts/branches/B{NN}/optimization-detail.md Yes (IMPL with branch)
Pipeline optimization plan /artifacts/pipelines/{P}/optimization-plan.md Yes (IMPL with pipeline)
Review/bench feedback From task description Yes (FIX)
.msg/meta.json /.msg/meta.json Yes
Wisdom files /wisdom/patterns.md No
Context accumulator From prior IMPL/FIX tasks Yes (inner loop)
  1. Extract session path and task mode (IMPL or FIX) from task description
  2. Detect branch/pipeline context from task description:
Task Description Field Value Context
BranchId: B{NN} Present Fan-out branch -- load single optimization detail
PipelineId: {P} Present Independent pipeline -- load pipeline-scoped plan
Neither present - Single mode -- load full optimization plan
  1. Load optimization context by mode:

    • Single mode (no branch): Read <session>/artifacts/optimization-plan.md -- extract ALL priority-ordered changes
    • Fan-out branch: Read <session>/artifacts/branches/B{NN}/optimization-detail.md -- extract ONLY this branch's optimization (single OPT-ID)
    • Independent pipeline: Read <session>/artifacts/pipelines/{P}/optimization-plan.md -- extract this pipeline's plan
  2. For FIX: parse review/benchmark feedback for specific issues to address

  3. Use explore subagent to load implementation context for target files

  4. For inner loop (single mode only): load context_accumulator from prior IMPL/FIX tasks

Shared-memory namespace:

  • Single: write to optimizer namespace
  • Fan-out: write to optimizer.B{NN} namespace
  • Independent: write to optimizer.{P} namespace

Phase 3: Code Implementation

Implementation backend selection:

Backend Condition Method
CLI Multi-file optimization with clear plan ccw cli --tool gemini --mode write
Direct Single-file changes or targeted fixes Inline Edit/Write tools

For IMPL tasks:

  • Single mode: Apply optimizations in plan priority order (P0 first, then P1, etc.)
  • Fan-out branch: Apply ONLY this branch's single optimization (from optimization-detail.md)
  • Independent pipeline: Apply this pipeline's optimizations in priority order
  • Follow implementation guidance from plan (target files, patterns)
  • Preserve existing behavior -- optimization must not break functionality

For FIX tasks:

  • Read specific issues from review/benchmark feedback
  • Apply targeted corrections to flagged code locations
  • Verify the fix addresses the exact concern raised

General rules:

  • Make minimal, focused changes per optimization
  • Add comments only where optimization logic is non-obvious
  • Preserve existing code style and conventions

Phase 4: Self-Validation

Check Method Pass Criteria
Syntax IDE diagnostics or build check No new errors
File integrity Verify all planned files exist and are modified All present
Acceptance Match optimization plan success criteria All target metrics addressed
No regression Run existing tests if available No new failures

If validation fails, attempt auto-fix (max 2 attempts) before reporting error.

Append to context_accumulator for next IMPL/FIX task (single/inner-loop mode only):

  • Files modified, optimizations applied, validation results
  • Any discovered patterns or caveats for subsequent iterations

Branch output paths:

  • Single: write artifacts to <session>/artifacts/
  • Fan-out: write artifacts to <session>/artifacts/branches/B{NN}/
  • Independent: write artifacts to <session>/artifacts/pipelines/{P}/