heal-workflow
Apply workflow improvements discovered during audit with approval workflow
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/marcusgoll/Spec-Flow/HEAD/.claude/commands/infrastructure/heal-workflow.md -o ~/.claude/commands/heal-workflow.mdheal-workflow.md
# /heal-workflow — Self-Healing Workflow Improvements
**Purpose**: Apply improvements to workflow system based on audit findings. Enables workflow to adapt and self-improve over time.
**Command**: `/heal-workflow [epic-slug | auto]`
**When to use**:
- After `/audit-workflow` identifies improvement opportunities
- Manual invocation to review and apply pending improvements
- After pattern detection suggests custom tooling
---
<instructions>
## Healing Workflow Process
### Step 1: Load Audit Report
**Locate most recent audit:**
```bash
if [ -n "$ARGUMENTS" ] && [ "$ARGUMENTS" != "auto" ]; then
EPIC_DIR="epics/$ARGUMENTS"
else
# Find most recent epic with audit report
EPIC_DIR=$(find epics -name "audit-report.xml" -printf '%T@ %p\n' | sort -rn | head -1 | cut -d' ' -f2- | xargs dirname)
fi
AUDIT_REPORT="$EPIC_DIR/audit-report.xml"
```
**Validate audit exists:**
```bash
test -f "$AUDIT_REPORT" || error "No audit report found. Run /audit-workflow first."
```
### Step 2: Parse Improvement Recommendations
**Extract actionable recommendations:**
```javascript
const audit = readXML(AUDIT_REPORT);
const improvements = {
immediate: audit.recommendations.immediate.filter(r => r.priority === 'high'),
short_term: audit.recommendations.short_term.filter(r => r.priority === 'medium'),
long_term: audit.recommendations.long_term.filter(r => r.priority === 'low'),
custom_tooling: audit.custom_tooling_suggestions
};
```
**Categorize by type:**
```javascript
const improvementTypes = {
phase_modifications: [], // Change phase behavior
gate_adjustments: [], // Modify quality gates
template_updates: [], // Update XML templates
skill_generation: [], // Generate custom skills
command_generation: [], // Generate custom commands
config_changes: [] // Update workflow configuration
};
```
### Step 3: Present Improvement Options
**Display recommendations with impact:**
```
Workflow Healing: 001-auth-epic
─────────────────────────────────────────
Audit Score: 85/100 (B+)
Found 8 improvement opportunities
IMMEDIATE (High Priority - Apply Now)
══════════════════════════════════════════
[1] Reduce clarification phase overhead
Type: phase_modification
Current: Asks 6 questions regardless of clarity
Proposed: Adaptive questioning (2-6 based on ambiguity)
Impact: Save ~45min per epic
Risk: Low
Effort: 1 hour to update clarify.md
[2] Auto-skip preview for non-UI epics
Type: gate_adjustment
Current: Manual preview required for all epics
Proposed: Auto-skip if no UI changes detected
Impact: Save ~1.5h for backend-only epics (40% of epics)
Risk: Low (AI pre-flight checks still run)
Effort: 30min to update preview.md
SHORT-TERM (Medium Priority - Next 2-3 Epics)
══════════════════════════════════════════════
[3] Generate service boilerplate skill
Type: skill_generation
Pattern: Detected 3x (DI + Repository pattern)
Impact: Save 30min per service, ensure consistency
Effort: 2 hours to build skill
[4] Improve sprint estimation for frontend
Type: config_changes
Current: Frontend sprints underestimated by avg 80%
Proposed: Increase frontend complexity multiplier 1.0x → 1.8x
Impact: More accurate estimates, better planning
Risk: Low
Effort: 5min config update
LONG-TERM (Low Priority - Strategic)
══════════════════════════════════════════
[5] Contract-first workflow enforcement
Type: phase_modification
Proposed: Lock contracts before any implementation starts
Impact: Prevent integration bugs proactively
Risk: Medium (adds overhead to planning phase)
Effort: 4 hours to build contract-locking mechanism
... (3 more)
```
### Step 4: Get User Approval
**Use AskUserQuestion for selections:**
```javascript
AskUserQuestion({
questions: [
{
question: "Which immediate improvements should I apply?",
header: "Immediate",
multiSelect: true,
options: [
{
label: "[1] Adaptive clarification",
description: "Save ~45min per epic, low risk"
},
{
label: "[2] Auto-skip preview",
description: "Save ~1.5h for backend epics, low risk"
}
]
},
{
question: "Which short-term improvements should I apply?",
header: "Short-term",
multiSelect: true,
options: [
{
label: "[3] Service boilerplate skill",
description: "2h effort, save 30min per service"
},
{
label: "[4] Frontend estimation fix",
description: "5min effort, better planning"
}
]
},
{
question: "Apply long-term improvements?",
header: "Long-term",
multiSelect: false,
options: [
{
label: "Yes, apply selected",
description: "I'll select which ones in next question"
},
{
label: "No, skip for now",
description: "Focus on immediate and short-term"
}
]
}
]
})
```
**If user selects improvements, proceed to application.**
### Step 5: Apply Phase Modifications
**Example: Adaptive clarification**
```javascript
// User approved: [1] Adaptive clarification
// Read current clarify.md
const clarifyCommand = read('.claude/commands/phases/clarify.md');
// Apply modification
const updated = clarifyCommand.replace(
/Ask 6 standard questions/,
`Analyze epic-spec.md ambiguity score:
- If score < 30: Ask 2 questions
- If score 30-60: Ask 4 questions
- If score > 60: Ask 6 questions`
);
// Show diff
console.log(`
Proposed Change to: .claude/commands/phases/clarify.md
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- Ask 6 standard questions
+ Analyze epic-spec.md ambiguity score:
+ - If score < 30: Ask 2 questions
+ - If score 30-60: Ask 4 questions
+ - If score > 60: Ask 6 questions
Apply this change?
`);
// Get confirmation
if (confirm()) {
write('.claude/commands/phases/clarifExecute multiple sprints in parallel based on dependency graph from sprint-plan.md
Build and validate locally for projects without remote deployment (prototypes, experiments, local-only dev)
Execute multi-sprint epic workflow from interactive scoping through deployment with parallel sprint execution and self-improvement
Execute feature development workflow from specification through production deployment with automated quality gates
Analyze workflow state and provide context-aware guidance with visual progress indicators and recommended next steps
Initialize project documentation, preferences, or design tokens
Implement small bug fixes and features (<100 LOC) without full workflow. Use for single-file changes, bug fixes, refactors, and minor enhancements that can be completed in under 30 minutes.
Enter deep craftsman mode - question everything, plan like Da Vinci, craft insanely great solutions, then materialize to roadmap