From 1e9ca574ed3203416900483998a100d62c9efb5d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 20 Nov 2025 10:44:20 +0000 Subject: [PATCH] refactor: simplify lite-fix command modes and parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reduced complexity from 3 modes to 2 modes with intelligent adaptation: Before (complex): - 3 modes: Regular, Critical, Hotfix - 3 parameters: --critical, --hotfix, --incident After (simplified): - 2 modes: Default (auto-adaptive), Hotfix - 1 parameter: --hotfix Key improvements: - Default mode intelligently adapts based on risk score (Phase 2) - Automatic workflow adjustment (diagnosis depth, test strategy, review) - Risk score thresholds determine process complexity automatically - Removed manual Critical mode selection (now auto-detected) - Removed --incident parameter (can include in bug description) Adaptive behavior: - risk_score <3.0: Full test suite, comprehensive diagnosis - 3.0-5.0: Focused integration tests, moderate diagnosis - 5.0-8.0: Smoke+critical tests, focused diagnosis - ≥8.0: Smoke tests only, minimal diagnosis Line count: 652 lines (reduced from 707) Matches lite-plan simplicity while maintaining full functionality --- .claude/commands/workflow/lite-fix.md | 553 ++++++++++++-------------- 1 file changed, 249 insertions(+), 304 deletions(-) diff --git a/.claude/commands/workflow/lite-fix.md b/.claude/commands/workflow/lite-fix.md index 1668d0a0..d5ce0537 100644 --- a/.claude/commands/workflow/lite-fix.md +++ b/.claude/commands/workflow/lite-fix.md @@ -1,7 +1,7 @@ --- name: lite-fix -description: Lightweight bug diagnosis and fix workflow with fast-track verification and optional hotfix mode for production incidents -argument-hint: "[--critical|--hotfix] [--incident ID] \"bug description or issue reference\"" +description: Lightweight bug diagnosis and fix workflow with intelligent severity assessment and optional hotfix mode for production incidents +argument-hint: "[--hotfix] \"bug description or issue reference\"" allowed-tools: TodoWrite(*), Task(*), SlashCommand(*), AskUserQuestion(*), Read(*), Bash(*) --- @@ -9,15 +9,15 @@ allowed-tools: TodoWrite(*), Task(*), SlashCommand(*), AskUserQuestion(*), Read( ## Overview -Fast-track bug fixing workflow optimized for quick diagnosis, targeted fixes, and streamlined verification. Supports both regular bug fixes and critical production hotfixes with appropriate process adaptations. +Fast-track bug fixing workflow optimized for quick diagnosis, targeted fixes, and streamlined verification. Automatically adjusts process complexity based on impact assessment. **Core capabilities:** - Rapid root cause diagnosis with intelligent code search -- Impact scope assessment (affected users, data, systems) +- Automatic severity assessment and adaptive workflow - Fix strategy selection (immediate patch vs comprehensive refactor) -- Risk-aware verification (smoke tests for hotfix, full suite for regular) -- Automatic hotfix branch management -- Follow-up task generation for comprehensive fixes +- Risk-aware verification (smoke tests to full suite) +- Optional hotfix mode for production incidents with branch management +- Automatic follow-up task generation for hotfixes ## Usage @@ -26,33 +26,28 @@ Fast-track bug fixing workflow optimized for quick diagnosis, targeted fixes, an /workflow:lite-fix [FLAGS] # Flags ---critical, -c Critical bug requiring fast-track process ---hotfix, -h Production hotfix mode (creates hotfix branch) ---incident Associate with incident tracking ID +--hotfix, -h Production hotfix mode (creates hotfix branch, auto follow-up) # Arguments Bug description or issue reference (required) ``` -### Severity Modes +### Modes | Mode | Time Budget | Use Case | Workflow Characteristics | |------|-------------|----------|--------------------------| -| **Regular** (default) | 2-4 hours | Non-blocking bugs, <20% user impact | Full diagnosis + comprehensive testing | -| **Critical** (`--critical`) | 30-60 min | Core feature degraded, 20-50% user impact | Focused diagnosis + key scenario testing | -| **Hotfix** (`--hotfix`) | 15-30 min | Production outage, 100% user impact | Minimal diagnosis + smoke testing + auto follow-up | +| **Default** | Auto-adapt (15min-4h) | All standard bugs | Intelligent severity assessment + adaptive process | +| **Hotfix** (`--hotfix`) | 15-30 min | Production outage | Minimal diagnosis + hotfix branch + auto follow-up | ### Examples ```bash -# Regular mode: Standard bug fix +# Default mode: Automatically adjusts based on impact /workflow:lite-fix "User avatar upload fails with 413 error" - -# Critical mode: Urgent but not fatal -/workflow:lite-fix --critical "Shopping cart randomly loses items at checkout" +/workflow:lite-fix "Shopping cart randomly loses items at checkout" # Hotfix mode: Production incident -/workflow:lite-fix --hotfix --incident INC-2024-1015 "Payment gateway 5xx errors" +/workflow:lite-fix --hotfix "Payment gateway 5xx errors" ``` ## Execution Process @@ -62,21 +57,21 @@ Fast-track bug fixing workflow optimized for quick diagnosis, targeted fixes, an ``` Bug Input → Diagnosis (Phase 1) → Impact Assessment (Phase 2) ↓ - Fix Planning (Phase 3) → Verification Strategy (Phase 4) + Severity Auto-Detection → Fix Planning (Phase 3) ↓ - User Confirmation (Phase 5) → Execution (Phase 6) + Verification Strategy (Phase 4) → User Confirmation (Phase 5) → Execution (Phase 6) ``` ### Phase Summary -| Phase | Regular | Critical | Hotfix | -|-------|---------|----------|--------| -| 1. Diagnosis | Full (cli-explore-agent) | Focused (direct grep) | Minimal (known issue) | -| 2. Impact | Comprehensive | Targeted | Critical path only | -| 3. Planning | Multiple strategies | Single best | Surgical fix | -| 4. Verification | Full test suite | Key scenarios | Smoke tests | -| 5. Confirmation | 4 dimensions | 3 dimensions | 2 dimensions | -| 6. Execution | Via lite-execute | Via lite-execute | Via lite-execute + monitoring | +| Phase | Default Mode | Hotfix Mode | +|-------|--------------|-------------| +| 1. Diagnosis | Adaptive search depth | Minimal (known issue) | +| 2. Impact Assessment | Full risk scoring | Critical path only | +| 3. Fix Planning | Strategy options based on complexity | Single surgical fix | +| 4. Verification | Test level matches risk score | Smoke tests only | +| 5. User Confirmation | 3 dimensions | 2 dimensions | +| 6. Execution | Via lite-execute | Via lite-execute + monitoring | --- @@ -86,39 +81,38 @@ Bug Input → Diagnosis (Phase 1) → Impact Assessment (Phase 2) **Goal**: Identify root cause and affected code paths -**Execution Strategy by Mode**: +**Execution Strategy**: + +**Default Mode** - Adaptive search: +- **High confidence keywords** (e.g., specific error messages): Direct grep search (5min) +- **Medium confidence**: cli-explore-agent with focused search (10-15min) +- **Low confidence** (vague symptoms): cli-explore-agent with broad search (20min) -**Regular Mode** - Comprehensive search: ```javascript -Task( - subagent_type="cli-explore-agent", - prompt=` - Bug: ${bug_description} - - Execute diagnostic search: - 1. Search error message: Grep "${error}" --output_mode content - 2. Find related code: Glob "**/affected-module/**/*.{ts,js}" - 3. Trace execution path - 4. Check recent changes: git log --since="1 week ago" - - Return: Root cause hypothesis, affected paths, reproduction steps - Time limit: 20 minutes - ` -) +// Confidence-based strategy selection +if (has_specific_error_message || has_file_path_hint) { + // Quick targeted search + grep -r '${error_message}' src/ --include='*.ts' -n | head -10 + git log --oneline --since='1 week ago' -- '*affected*' +} else { + // Deep exploration + Task(subagent_type="cli-explore-agent", prompt=` + Bug: ${bug_description} + Execute diagnostic search: + 1. Search error patterns and similar issues + 2. Trace execution path in affected modules + 3. Check recent changes + Return: Root cause hypothesis, affected paths, reproduction steps + `) +} ``` -**Critical Mode** - Direct targeted search: +**Hotfix Mode** - Minimal search: ```bash -grep -r '${error_message}' src/ --include='*.ts' -n | head -10 -git log --oneline --since='1 week ago' -- '*affected*' | head -5 +Read(suspected_file) # User typically knows the file git blame ${suspected_file} ``` -**Hotfix Mode** - Minimal search (assume known issue): -```bash -Read(suspected_file) # User provides file path -``` - **Output Structure**: ```javascript { @@ -141,19 +135,30 @@ Read(suspected_file) # User provides file path --- -### Phase 2: Impact Assessment +### Phase 2: Impact Assessment & Severity Auto-Detection -**Goal**: Quantify blast radius and risk level +**Goal**: Quantify blast radius and auto-determine severity **Risk Score Calculation**: ```javascript risk_score = (user_impact × 0.4) + (system_risk × 0.3) + (business_impact × 0.3) -// Severity mapping +// Auto-severity mapping if (risk_score >= 8.0) severity = "critical" else if (risk_score >= 5.0) severity = "high" else if (risk_score >= 3.0) severity = "medium" else severity = "low" + +// Workflow adaptation +if (severity >= "high") { + diagnosis_depth = "focused" + test_strategy = "smoke_and_critical" + review_optional = true +} else { + diagnosis_depth = "comprehensive" + test_strategy = "full_suite" + review_optional = false +} ``` **Assessment Output**: @@ -161,8 +166,7 @@ else severity = "low" { affected_users: { count: "5000 active users (100%)", - severity: "high", - workaround: "Re-login required" + severity: "high" }, system_risk: { availability: "degraded_30%", @@ -174,15 +178,16 @@ else severity = "low" sla_breach: "yes" }, risk_score: 7.1, - severity: "high" + severity: "high", + workflow_adaptation: { + test_strategy: "focused_integration", + review_required: false, + time_budget: "1_hour" + } } ``` -**Auto-Severity Suggestion**: -If `risk_score >= 8.0` and user didn't provide `--critical`, suggest: -``` -💡 Suggestion: Consider using --critical flag (risk score: 8.2/10) -``` +**Hotfix Mode**: Skip detailed assessment, assume critical **TodoWrite**: Mark Phase 2 completed, Phase 3 in_progress @@ -192,71 +197,61 @@ If `risk_score >= 8.0` and user didn't provide `--critical`, suggest: **Goal**: Generate fix options with trade-off analysis -**Strategy Generation by Mode**: +**Strategy Generation**: + +**Default Mode** - Complexity-adaptive: +- **Low risk score (<5.0)**: Generate 2-3 strategy options for user selection +- **High risk score (≥5.0)**: Generate single best strategy for speed -**Regular Mode** - Multiple strategies (1-3 options): ```javascript +strategies = generateFixStrategies(root_cause, risk_score) + +if (risk_score >= 5.0 || mode === "hotfix") { + // Single best strategy + return strategies[0] // Fastest viable fix +} else { + // Multiple options with trade-offs + return strategies // Let user choose +} +``` + +**Example Strategies**: +```javascript +// Low risk: Multiple options [ { strategy: "immediate_patch", description: "Fix comparison operator", - files: ["src/auth/tokenValidator.ts:47"], estimated_time: "15 minutes", risk: "low", - pros: ["Quick fix", "Minimal change"], - cons: ["Doesn't address token refresh"] + pros: ["Quick fix"], + cons: ["Doesn't address underlying issue"] }, { - strategy: "comprehensive_refactor", - description: "Refactor token validation with proper refresh", - files: ["src/auth/tokenValidator.ts", "src/auth/refreshToken.ts"], + strategy: "comprehensive_fix", + description: "Refactor token validation logic", estimated_time: "2 hours", risk: "medium", pros: ["Addresses root cause"], cons: ["Longer implementation"] } ] -``` -**Critical/Hotfix Mode** - Single best strategy: -```javascript +// High risk or hotfix: Single option { strategy: "surgical_fix", description: "Minimal change to fix comparison", files: ["src/auth/tokenValidator.ts:47"], - change: "currentTime > expiryTime → currentTime >= expiryTime", estimated_time: "5 minutes", risk: "minimal" } ``` -**Complexity Assessment & Planning**: +**Complexity Assessment**: ```javascript -complexity = assessComplexity(fix_strategies) - -if (complexity === "low" || mode === "hotfix") { - plan = generateSimplePlan(selected_strategy) // Direct by Claude -} else if (complexity === "medium") { - plan = Task(subagent_type="cli-lite-planning-agent", ...) -} else { +if (complexity === "high" && risk_score < 5.0) { suggestCommand("/workflow:plan --mode bugfix") -} -``` - -**Plan Output**: -```javascript -{ - summary: "Fix timestamp comparison in token validation", - approach: "Update comparison operator", - tasks: [{ - title: "Fix token expiration comparison", - file: "src/auth/tokenValidator.ts", - action: "Update", - implementation: ["Locate validateToken", "Update line 47", "Add comment"], - verification: ["Manual test at boundary", "Run auth tests"] - }], - estimated_time: "30 minutes", - recommended_execution: "Agent" + return // Escalate to full planning } ``` @@ -268,17 +263,19 @@ if (complexity === "low" || mode === "hotfix") { **Goal**: Define testing approach based on severity -**Test Strategy Selection**: +**Adaptive Test Strategy**: -| Mode | Test Scope | Duration | Automation | -|------|------------|----------|------------| -| **Regular** | Full test suite | 10-20 min | `npm test` | -| **Critical** | Focused integration | 5-10 min | `npm test -- auth.test.ts` | -| **Hotfix** | Smoke tests | 2-5 min | `npm test -- auth.smoke.test.ts` | +| Risk Score | Test Scope | Duration | Automation | +|------------|------------|----------|------------| +| **< 3.0** (Low) | Full test suite | 15-20 min | `npm test` | +| **3.0-5.0** (Medium) | Focused integration | 8-12 min | `npm test -- affected-module.test.ts` | +| **5.0-8.0** (High) | Smoke + critical | 5-8 min | `npm test -- critical.smoke.test.ts` | +| **≥ 8.0** (Critical) | Smoke only | 2-5 min | `npm test -- smoke.test.ts` | +| **Hotfix** | Production smoke | 2-3 min | `npm test -- production.smoke.test.ts` | **Branch Strategy**: -**Regular/Critical**: +**Default Mode**: ```javascript { type: "feature_branch", @@ -288,7 +285,7 @@ if (complexity === "low" || mode === "hotfix") { } ``` -**Hotfix**: +**Hotfix Mode**: ```javascript { type: "hotfix_branch", @@ -304,74 +301,48 @@ if (complexity === "low" || mode === "hotfix") { ### Phase 5: User Confirmation & Execution Selection -**Multi-Dimension Confirmation**: +**Adaptive Confirmation Dimensions**: + +**Default Mode** - 3 dimensions (adapted by risk score): -**Regular Mode** (4 dimensions): ```javascript -AskUserQuestion({ - questions: [ - { - question: "Confirm fix approach?", - header: "Fix Confirmation", - options: [ - { label: "Proceed", description: "Execute as planned" }, - { label: "Modify", description: "Adjust strategy" }, - { label: "Escalate", description: "Use /workflow:plan" } - ] - }, - { - question: "Execution method:", - header: "Execution", - options: [ - { label: "Agent", description: "@code-developer" }, - { label: "CLI Tool", description: "Codex/Gemini" }, - { label: "Manual", description: "Provide plan only" } - ] - }, - { - question: "Verification level:", - header: "Testing", - options: [ - { label: "Full Suite", description: "All tests" }, - { label: "Focused", description: "Affected tests" }, - { label: "Smoke Only", description: "Critical path" } - ] - }, - { - question: "Post-fix review:", - header: "Code Review", - options: [ - { label: "Gemini", description: "AI review" }, - { label: "Skip", description: "Trust tests" } - ] - } - ] -}) +dimensions = [ + { + question: "Confirm fix approach?", + options: ["Proceed", "Modify", "Escalate to /workflow:plan"] + }, + { + question: "Execution method:", + options: ["Agent", "CLI Tool (Codex/Gemini)", "Manual (plan only)"] + }, + { + question: "Verification level:", + options: adaptedByRiskScore() // Auto-suggest based on Phase 2 + } +] + +// If risk_score >= 5.0, auto-skip code review dimension +// If risk_score < 5.0, add optional code review dimension +if (risk_score < 5.0) { + dimensions.push({ + question: "Post-fix review:", + options: ["Gemini", "Skip"] + }) +} ``` -**Critical Mode** (3 dimensions - skip code review) - -**Hotfix Mode** (2 dimensions - minimal confirmation): +**Hotfix Mode** - 2 dimensions (minimal): ```javascript -AskUserQuestion({ - questions: [ - { - question: "Confirm hotfix deployment:", - options: [ - { label: "Deploy", description: "Apply to production" }, - { label: "Stage First", description: "Test in staging" }, - { label: "Abort", description: "Cancel" } - ] - }, - { - question: "Post-deployment monitoring:", - options: [ - { label: "Real-time", description: "Monitor 15 minutes" }, - { label: "Passive", description: "Rely on alerts" } - ] - } - ] -}) +[ + { + question: "Confirm hotfix deployment:", + options: ["Deploy", "Stage First", "Abort"] + }, + { + question: "Post-deployment monitoring:", + options: ["Real-time (15 min)", "Passive (alerts only)"] + } +] ``` **TodoWrite**: Mark Phase 5 completed, Phase 6 in_progress @@ -380,25 +351,24 @@ AskUserQuestion({ ### Phase 6: Execution Dispatch & Follow-up -**Step 6.1: Dispatch to lite-execute** +**Dispatch to lite-execute**: ```javascript executionContext = { mode: "bugfix", - severity: mode, // "regular" | "critical" | "hotfix" + severity: auto_detected_severity, // From Phase 2 planObject: plan, diagnosisContext: diagnosis, impactContext: impact_assessment, verificationStrategy: test_strategy, branchStrategy: branch_strategy, - executionMethod: user_selection.execution_method, - monitoringLevel: user_selection.monitoring + executionMethod: user_selection.execution_method } SlashCommand("/workflow:lite-execute --in-memory --mode bugfix") ``` -**Step 6.2: Hotfix Follow-up Tasks** (auto-generated if hotfix mode) +**Hotfix Auto Follow-up**: ```javascript if (mode === "hotfix") { @@ -407,33 +377,24 @@ if (mode === "hotfix") { id: `FOLLOWUP-${taskId}-comprehensive`, title: "Replace hotfix with comprehensive fix", priority: "high", - due_date: "within_3_days" + due_date: "within_3_days", + description: "Refactor quick hotfix into proper solution with full test coverage" }, { id: `FOLLOWUP-${taskId}-postmortem`, title: "Incident postmortem", priority: "medium", - due_date: "within_1_week" + due_date: "within_1_week", + sections: ["Timeline", "Root cause", "Prevention measures"] } ] Write(`.workflow/lite-fixes/${taskId}-followup.json`, follow_up_tasks) -} -``` -**Step 6.3: Real-time Monitoring** (if selected) - -```javascript -if (user_selection.monitoring === "real-time") { console.log(` - 📊 Real-time Monitoring Active (15 minutes) - - Metrics: - - Error rate: <5% - - Login success: >95% - - Auth latency: <500ms - - Auto-rollback: Enabled + ⚠️ Hotfix follow-up tasks generated: + - Comprehensive fix: ${follow_up_tasks[0].id} (due in 3 days) + - Postmortem: ${follow_up_tasks[1].id} (due in 1 week) `) } ``` @@ -450,6 +411,7 @@ if (user_selection.monitoring === "real-time") { symptom: string, error_message: string | null, keywords: string[], + confidence_level: "high" | "medium" | "low", // Search confidence root_cause: { file: string, line_range: string, @@ -468,7 +430,13 @@ if (user_selection.monitoring === "real-time") { system_risk: { availability: string, cascading_failures: string }, business_impact: { revenue: string, reputation: string, sla_breach: string }, risk_score: number, // 0-10 - severity: "low" | "medium" | "high" | "critical" + severity: "low" | "medium" | "high" | "critical", + workflow_adaptation: { + diagnosis_depth: string, + test_strategy: string, + review_optional: boolean, + time_budget: string + } } ``` @@ -477,7 +445,6 @@ if (user_selection.monitoring === "real-time") { { strategy: string, summary: string, - approach: string, tasks: [{ title: string, file: string, @@ -490,85 +457,72 @@ if (user_selection.monitoring === "real-time") { } ``` -### executionContext (passed to lite-execute) -```javascript -{ - mode: "bugfix", - severity: "regular" | "critical" | "hotfix", - planObject: fixPlan, - diagnosisContext: diagnosisContext, - impactContext: impactContext, - verificationStrategy: {...}, - branchStrategy: {...}, - executionMethod: string, - monitoringLevel: string -} -``` - --- ## Best Practices -### Severity Selection Guide +### When to Use Default Mode -**Use Regular Mode when:** -- Bug is not blocking critical functionality -- Have time for comprehensive testing (2-4 hours) -- Want to explore multiple fix strategies -- Can afford full test suite run +**Use for all standard bugs:** +- Automatically adapts to severity (no manual mode selection needed) +- Risk score determines workflow complexity +- Handles 90% of bug fixing scenarios -**Use Critical Mode when:** -- Bug affects significant user base (>20%) -- Features degraded but not completely broken -- Need fix within 1 hour -- Have clear reproduction steps +**Typical scenarios:** +- UI bugs, logic errors, edge cases +- Performance issues (non-critical) +- Integration failures +- Data validation bugs -**Use Hotfix Mode when:** +### When to Use Hotfix Mode + +**Only use for production incidents:** - Production is down or critically degraded - Revenue/reputation at immediate risk - SLA breach occurring -- Need fix within 30 minutes -- Issue is well-understood +- Issue is well-understood (minimal diagnosis needed) -### Branching Best Practices +**Hotfix characteristics:** +- Creates hotfix branch from production tag +- Minimal diagnosis (assumes known issue) +- Smoke tests only +- Auto-generates follow-up tasks +- Requires incident tracking -**Hotfix Branching**: +### Branching Strategy + +**Default Mode (feature branch)**: +```bash +# Standard feature branch workflow +git checkout -b fix/issue-description main +# ... implement fix +git checkout main && git merge fix/issue-description +``` + +**Hotfix Mode (dual merge)**: ```bash # ✅ Correct: Branch from production tag git checkout -b hotfix/fix-name v2.3.1 -# ❌ Wrong: Branch from main (unreleased code) -git checkout -b hotfix/fix-name main -``` - -**Merge Strategy**: -```bash -# Hotfix merges to both targets +# Merge to both targets git checkout main && git merge hotfix/fix-name git checkout production && git merge hotfix/fix-name git tag v2.3.2 + +# ❌ Wrong: Branch from main +git checkout -b hotfix/fix-name main # Contains unreleased code! ``` -### Follow-up Task Management - -**Always create follow-up for hotfixes**: -- ✅ Comprehensive fix (within 3 days) -- ✅ Test coverage improvement -- ✅ Monitoring/alerting enhancements -- ✅ Documentation updates -- ✅ Postmortem (if critical) - --- ## Error Handling | Error | Cause | Resolution | |-------|-------|------------| -| Root cause not found | Insufficient search | Expand search or escalate to /workflow:plan | -| Reproduction fails | Stale bug or env issue | Verify environment, request updated steps | -| Multiple causes | Complex interaction | Use /cli:discuss-plan for analysis | -| Fix too complex | High-risk refactor | Suggest /workflow:plan --mode refactor | -| Verification fails | Insufficient tests | Add test cases or adjust mode | +| Root cause unclear | Vague symptoms | Extend diagnosis time or use /cli:mode:bug-diagnosis | +| Multiple potential causes | Complex interaction | Use /cli:discuss-plan for analysis | +| Fix too complex | High-risk refactor | Escalate to /workflow:plan --mode bugfix | +| High risk score but unsure | Uncertain severity | Default mode will adapt, proceed normally | --- @@ -577,10 +531,10 @@ git tag v2.3.2 **Lite-fix directory**: ``` .workflow/lite-fixes/ -├── BUGFIX-2024-10-20T14-30-00.json # Bug fix task JSON -├── BUGFIX-2024-10-20T14-30-00-followup.json # Follow-up tasks (hotfix) -└── diagnosis-cache/ # Cached diagnosis - └── auth-token-hash.json +├── BUGFIX-2024-10-20T14-30-00.json # Task JSON +├── BUGFIX-2024-10-20T14-30-00-followup.json # Follow-up (hotfix only) +└── diagnosis-cache/ # Cached diagnoses + └── ${bug_hash}.json ``` **Session-based** (if active session): @@ -597,39 +551,36 @@ git tag v2.3.2 ## Advanced Features -### 1. Diagnosis Caching +### 1. Intelligent Diagnosis Caching -Speed up similar issues: +Reuse diagnosis for similar bugs: ```javascript cache_key = hash(bug_keywords + recent_changes_hash) -cache_path = `.workflow/lite-fixes/diagnosis-cache/${cache_key}.json` - -if (cache_exists && cache_age < 1_week) { +if (cache_exists && cache_age < 7_days && similarity > 0.8) { diagnosis = load_from_cache() + console.log("Using cached diagnosis (similar issue found)") } ``` -### 2. Auto-Severity Detection +### 2. Auto-Severity Suggestion +Detect urgency from keywords: ```javascript -if (bug_description.includes("production|down|critical|outage")) { - suggested_flag = "--critical" -} else if (bug_description.includes("hotfix|urgent|incident")) { - suggested_flag = "--hotfix" +urgency_keywords = ["production", "down", "outage", "critical", "urgent"] +if (bug_description.includes(urgency_keywords) && !mode_specified) { + console.log("💡 Tip: Consider --hotfix flag for production issues") } ``` -### 3. Rollback Plan (Hotfix) +### 3. Adaptive Workflow Intelligence +Real-time workflow adjustment: ```javascript -rollback_plan = { - method: "git_revert", - commands: [ - "git revert ${commit_sha}", - "git push origin hotfix/${branch}", - "# Re-deploy v2.3.1" - ], - estimated_time: "5 minutes" +// During Phase 2, if risk score suddenly increases +if (new_risk_score > initial_estimate * 1.5) { + console.log("⚠️ Severity increased, adjusting workflow...") + test_strategy = "more_comprehensive" + review_required = true } ``` @@ -638,47 +589,40 @@ rollback_plan = { ## Related Commands **Diagnostic Commands**: -- `/cli:mode:bug-diagnosis` - Root cause analysis only -- `/cli:mode:code-analysis` - Execution path tracing +- `/cli:mode:bug-diagnosis` - Detailed root cause analysis (use before lite-fix if unclear) **Fix Execution**: -- `/workflow:lite-execute --in-memory` - Execute fix plan (called by lite-fix) -- `/cli:execute` - Direct implementation -- `/cli:codex-execute` - Multi-stage fix +- `/workflow:lite-execute --in-memory` - Execute fix plan (automatically called) **Planning Commands**: -- `/workflow:plan --mode bugfix` - Complex bug requiring comprehensive planning -- `/cli:discuss-plan` - Multi-model collaborative analysis +- `/workflow:plan --mode bugfix` - Complex bugs requiring comprehensive planning **Review Commands**: -- `/workflow:review --type quality` - Post-fix code review -- `/workflow:review --type security` - Security validation +- `/workflow:review --type quality` - Post-fix quality review --- ## Comparison with Other Commands -| Command | Use Case | Time | Output | -|---------|----------|------|--------| -| `/workflow:lite-fix` | Bug fixes (regular to critical) | 15min-4h | In-memory + JSON | -| `/workflow:lite-plan` | New features | 1-6h | In-memory + JSON | -| `/workflow:plan` | Complex features | 1-5 days | Persistent session | -| `/cli:mode:bug-diagnosis` | Analysis only | 10-30min | Diagnostic report | +| Command | Use Case | Modes | Adaptation | Output | +|---------|----------|-------|------------|--------| +| `/workflow:lite-fix` | Bug fixes | 2 (default + hotfix) | Auto-adaptive | In-memory + JSON | +| `/workflow:lite-plan` | New features | 1 + explore flag | Manual | In-memory + JSON | +| `/workflow:plan` | Complex features | Multiple | Manual | Persistent session | +| `/cli:mode:bug-diagnosis` | Analysis only | 1 | N/A | Report only | --- ## Quality Gates -**Before execution**: -- [ ] Root cause identified (>80% confidence) -- [ ] Impact scope clearly defined -- [ ] Fix strategy reviewed and approved +**Before execution** (auto-checked): +- [ ] Root cause identified (>70% confidence for default, >90% for hotfix) +- [ ] Impact scope defined +- [ ] Fix strategy reviewed - [ ] Verification plan matches risk level -- [ ] Branch strategy appropriate **Hotfix-specific**: -- [ ] Incident ticket linked -- [ ] Incident commander approval +- [ ] Production tag identified - [ ] Rollback plan documented - [ ] Follow-up tasks generated - [ ] Monitoring configured @@ -687,21 +631,22 @@ rollback_plan = { ## When to Use lite-fix -✅ **Good fit**: -- Clear bug symptom with reproduction steps -- Localized fix (1-3 files) -- Time-sensitive but not catastrophic +✅ **Perfect for:** +- Any bug with clear symptoms +- Localized fixes (1-5 files) - Known technology stack +- Time-sensitive but not catastrophic (default mode adapts) +- Production incidents (use --hotfix) -❌ **Poor fit**: -- Root cause unclear → use `/cli:mode:bug-diagnosis` first +❌ **Not suitable for:** +- Root cause completely unclear → use `/cli:mode:bug-diagnosis` first - Requires architectural changes → use `/workflow:plan` -- Complex legacy code → use `/workflow:plan --legacy-refactor` -- Performance investigation → use `/workflow:plan --performance-optimization` -- Data migration needed → use `/workflow:plan --data-migration` +- Complex legacy code without tests → use `/workflow:plan --legacy-refactor` +- Performance deep-dive → use `/workflow:plan --performance-optimization` +- Data migration → use `/workflow:plan --data-migration` --- **Last Updated**: 2025-11-20 -**Version**: 1.0.0 -**Status**: Design Document +**Version**: 2.0.0 +**Status**: Design Document (Simplified)