refactor: simplify lite-fix command modes and parameters

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
This commit is contained in:
Claude
2025-11-20 10:44:20 +00:00
parent 5f0dab409b
commit 1e9ca574ed

View File

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