Optimization Workflow Orchestrator
Orchestrates the complete performance optimization workflow. Single entry point that manages state, transitions, and termination.
Quick Start
Step 1: Determine current state (see State Detection below)
Step 2: Execute the appropriate phase skill
Step 3: After phase completes, re-evaluate state and continue or terminate
State Detection
Check files in this order to determine current phase:
1. BENCHMARK_BASELINE.md exists?
NO → Execute PHASE 1 (establishing-benchmark-baseline)
YES → Continue to check 2
2. PERFORMANCE_THEORIES.md exists?
NO → Execute PHASE 2 (broad-performance-investigation)
YES → Continue to check 3
3. Any theory with status "verified"?
YES → Execute PHASE 4 (implementing-performance-fixes) for highest severity verified theory
NO → Continue to check 4
4. Any theory with status "pending"?
YES → Select highest severity pending theory:
- If "Deeper Investigation: SKIP" → Execute PHASE 4 (implementing-performance-fixes)
- If "Deeper Investigation: REQUIRED" → Execute PHASE 3 (deep-performance-investigation)
NO → Continue to check 5
5. All theories have status "fixed" or "fix-failed" or "falsified"?
YES → Evaluate termination (see below)
NO → Error state, ask user
Priority Order for Theory Selection:
- •Prioritize by Severity: Critical > High > Medium > Low
- •If multiple theories share the same severity, select the first one
- •Respect "Deeper Investigation" decision (SKIP→Phase 4, REQUIRED→Phase 3)
- •This ensures critical performance issues are addressed before easy fixes
Phase Skills
| Phase | Skill | Purpose |
|---|---|---|
| 1 | establishing-benchmark-baseline | Create benchmarks and baseline |
| 2 | broad-performance-investigation | Analyze code, generate theories |
| 3 | deep-performance-investigation | Prove/disprove theories with tools |
| 4 | implementing-performance-fixes | Implement fix, validate improvement |
Termination Criteria
After all theories are processed (fixed/fix-failed/falsified), evaluate:
Continue optimization (loop to PHASE 2) if:
- •User requests more optimization
Stop optimization if:
- •One optimization iteration completed
- •User didn't request more optimization
- •Performance meets or exceeds baseline expectations
- •User indicates satisfaction
- •No more theories can be generated (diminishing returns)
- •All recent fixes failed (indicates deeper issues)
Edge Cases
| Situation | Action |
|---|---|
| All theories falsified | Loop to PHASE 2 with different focus |
| No performance gap found | Optimization complete, congratulate user |
Workflow Visualization
flowchart TD
Start([Start]) --> P1[PHASE 1<br/>Baseline]
P1 --> P2[PHASE 2<br/>Theories]
P2 -->|Deeper Investigation:<br/>SKIP| P4[PHASE 4<br/>Fix]
P2 -->|Deeper Investigation:<br/>REQUIRED| P3[PHASE 3<br/>Verify]
P3 --> P4
P4 -->|Gaps remain| P3
P4 -->|Done| End([Complete])
Key paths:
- •Phase 2 → Phase 4 directly if "Deeper Investigation: SKIP" (definitive evidence + low-risk fix)
- •Phase 2 → Phase 3 → Phase 4 if "Deeper Investigation: REQUIRED" (circumstantial evidence OR high-risk fix)
Orchestrator Checklist
Copy this to track progress:
Optimization Progress: - [ ] State determined - [ ] PHASE 1: Baseline established (BENCHMARK_BASELINE.md exists) - [ ] PHASE 2: Theories generated (PERFORMANCE_THEORIES.md exists) - [ ] PHASE 3: Theory verified (at least one verified) - [ ] PHASE 4: Fix implemented and validated - [ ] Termination evaluated - [ ] Loop or complete
Integration
This skill CALLS the phase skills:
- •
establishing-benchmark-baseline(PHASE 1) - •
broad-performance-investigation(PHASE 2) - •
deep-performance-investigation(PHASE 3) - •
implementing-performance-fixes(PHASE 4)
This skill does NOT call tool skills directly. Tool skills are called by PHASE 3.