# bugfix-executor-generator
> This skill should be used when the user asks to 'generate bugfix executor', 'create dynamic executor', 'prepare bugfix execution skill', or needs to generate a self-contained executor skill with architect review workflow.
- Author: Ngoc
- Repository: Vegarnom/mega-team-v4
- Version: 20260202115326
- Stars: 0
- Forks: 0
- Last Updated: 2026-02-06
- Source: https://github.com/Vegarnom/mega-team-v4
- Web: https://mule.run/skillshub/@@Vegarnom/mega-team-v4~bugfix-executor-generator:20260202115326
---
---
name: bugfix-executor-generator
description: This skill should be used when the user asks to 'generate bugfix executor', 'create dynamic executor', 'prepare bugfix execution skill', or needs to generate a self-contained executor skill with architect review workflow.
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
version: 1.1
---
# Bugfix Executor Generator v1.1
Generate dynamic executor skill với Hybrid approach.
---
## WHAT'S NEW IN v1.1
- **Hybrid Approach**: Architect Design → Implement → Architect Review
- **Scope Detection**: Tự động detect Backend/Frontend/Mobile từ files
- **Architect Review**: Gọi architect agents review code sau implement
- **Multi-Round Fix**: Fix issues từ architect review
---
## WHAT THIS DOES
1. Đọc PLAN.md từ `.claude/plans/fix-{ISSUE_ID}/`
2. Detect scope từ files (Backend/Frontend/Mobile)
3. Tạo skill mới tại `.claude/skills/_dynamic/exec-fix-{ISSUE_ID}/SKILL.md`
4. Skill mới chứa:
- Toàn bộ context của task
- Architect Review sau implement
- Multi-round fix nếu có issues
5. Khi execute xong, skill tự xóa chính nó
---
## USAGE
```bash
/bugfix-executor-generator # Find plan and generate skill
/bugfix-executor-generator .claude/plans/fix-123/ # Specific plan
```
---
## GENERATED SKILL LOCATION
```
.claude/skills/_dynamic/
├── exec-fix-123/
│ ├── SKILL.md # Generated executor for Issue #123
│ └── context.json # Embedded context from plan
├── exec-fix-456/
│ └── SKILL.md # Generated executor for Issue #456
└── ...
```
---
## WORKFLOW
### Step 1: Parse Plan & Detect Scope
```typescript
// Find plan
PLAN_DIR = ".claude/plans/fix-${ISSUE_ID}"
PLAN_FILE = "${PLAN_DIR}/PLAN.md"
ISSUE_ID = extractIssueId(PLAN_DIR)
// Read plan
${PLAN_FILE}
// Parse to extract structured data
plan = {
issue_id: ISSUE_ID,
summary: extractSection("Summary"),
root_cause: extractSection("Root Cause Analysis"),
implementation_steps: extractImplementationSteps(),
files_to_change: extractFilesTable(),
test_cases: extractTestCases()
}
// DETECT SCOPE from files
scope = []
FOR file IN plan.files_to_change:
IF file.path.includes("packages/backend") || file.path.includes(".entity.ts") || file.path.includes(".service.ts") || file.path.includes(".controller.ts"):
scope.push("Backend")
IF file.path.includes("packages/frontend") || file.path.includes(".vue") || file.path.includes("components/"):
scope.push("Frontend")
IF file.path.includes("packages/mobile") || file.path.includes(".dart"):
scope.push("Mobile")
scope = [...new Set(scope)] // Remove duplicates
IF scope.length == 0: scope = ["Backend"] // Default
plan.scope = scope
// Load detail files
IF exists("${PLAN_DIR}/details/data-flow.md"):
${PLAN_DIR}/details/data-flow.md
plan.data_flow = content
IF exists("${PLAN_DIR}/details/impact-analysis.md"):
${PLAN_DIR}/details/impact-analysis.md
plan.impact = content
IF exists("${PLAN_DIR}/details/test-cases.md"):
${PLAN_DIR}/details/test-cases.md
plan.test_cases_detail = content
```
### Step 2: Generate Dynamic Skill with Hybrid Approach
```typescript
// Create skill directory
SKILL_DIR = ".claude/skills/_dynamic/exec-fix-${ISSUE_ID}"
mkdir -p ${SKILL_DIR}
// Generate SKILL.md with embedded context + Hybrid approach
skill_content = `
---
name: exec-fix-${ISSUE_ID}
description: Execute bugfix #${ISSUE_ID} with Hybrid approach. Auto-generated, will self-delete after completion.
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Task, TodoWrite
version: 1.0
auto-generated: true
issue-id: ${ISSUE_ID}
scope: ${plan.scope.join(", ")}
hooks:
PostToolUse:
- matcher: { tool_name: "Edit" }
command: "bash ~/.claude/scripts/auto-lint.sh"
- matcher: { tool_name: "Write" }
command: "bash ~/.claude/scripts/auto-lint.sh"
---
# Executor for Bugfix #${ISSUE_ID}
> **Auto-generated skill** - Hybrid Approach: Implement → Architect Review → Fix
> **Scope:** ${plan.scope.join(", ")}
---
## EMBEDDED CONTEXT
### Issue Summary
${plan.summary}
### Root Cause
${plan.root_cause}
### Scope
${plan.scope.join(", ")}
### Implementation Steps
${plan.implementation_steps.map((step, i) => `
#### Step ${i + 1}: ${step.title}
- **File:** ${step.file}
- **Sub-steps:**
${step.sub_steps.map(s => ` - ${s.description}`).join('\n')}
${step.logic ? `- **Logic:**\n\`\`\`\n${step.logic}\n\`\`\`` : ''}
`).join('\n')}
### Files to Change
| # | File | Change | Lines |
|---|------|--------|-------|
${plan.files_to_change.map((f, i) => `| ${i + 1} | \`${f.file}\` | ${f.change} | ~${f.lines} |`).join('\n')}
${plan.data_flow ? `
### Data Flow
${plan.data_flow}
` : ''}
---
## EXECUTION (Hybrid Approach)
### Phase 1: Initialize
\`\`\`typescript
ISSUE_ID = "${ISSUE_ID}"
PLAN_DIR = ".claude/plans/fix-${ISSUE_ID}"
SKILL_DIR = ".claude/skills/_dynamic/exec-fix-${ISSUE_ID}"
PROGRESS_FILE = "\${PLAN_DIR}/.progress-${ISSUE_ID}.json"
SCOPE = ${JSON.stringify(plan.scope)}
// Load or create progress
IF exists(PROGRESS_FILE):
progress = JSON.parse(\${PROGRESS_FILE})
current_step = progress.current_step
ELSE:
current_step = 0
progress = {
issue_id: "${ISSUE_ID}",
scope: SCOPE,
steps_completed: [],
current_step: 0,
architect_review: null,
review_rounds: 0
}
console.log("🚀 Executing Bugfix #${ISSUE_ID} (Hybrid Approach)")
console.log("📋 Steps: ${plan.implementation_steps.length}")
console.log("📁 Scope: ${plan.scope.join(', ')}")
\`\`\`
### Phase 2: Implement Steps
${plan.implementation_steps.map((step, i) => `
#### Execute Step ${i + 1}: ${step.title}
\`\`\`typescript
IF current_step <= ${i}:
console.log("\\n${"=".repeat(50)}")
console.log("STEP ${i + 1}: ${step.title}")
console.log("${"=".repeat(50)}\\n")
// 1. Read target file
${step.file}
// 2. Implement changes
${step.sub_steps.map(s => `// - ${s.description}`).join('\n ')}
// 3. Verify
tsc_result = npx tsc --noEmit 2>&1 | head -20
IF tsc_result.hasErrors: fixErrors()
lint_result = npx eslint ${step.file} --quiet 2>&1
IF lint_result.hasErrors: npx eslint ${step.file} --fix
// 4. Save progress
progress.current_step = ${i + 1}
progress.steps_completed.push(${i})
\${JSON.stringify(progress, null, 2)}
console.log("✅ Step ${i + 1} COMPLETE")
\`\`\`
`).join('\n')}
### Phase 3: Architect Review (Hybrid)
\`\`\`typescript
console.log("\\n🏗️ ARCHITECT REVIEW")
console.log("Scope: ${plan.scope.join(', ')}")
// Get list of modified files
modified_files = ${JSON.stringify(plan.files_to_change.map(f => f.file))}
// Run architect review based on scope (PARALLEL)
${plan.scope.includes('Backend') ? `
## Bugfix Code Review Request
**Issue:** #${ISSUE_ID}
**Summary:** ${plan.summary}
**Modified Files:**
${plan.files_to_change.filter(f =>
f.file.includes('packages/backend') ||
f.file.includes('.entity.ts') ||
f.file.includes('.service.ts') ||
f.file.includes('.controller.ts')
).map(f => `- ${f.file}`).join('\n')}
**Review Focus:**
1. Code correctness - Does the fix address the root cause?
2. NestJS best practices - Proper DI, decorators, error handling
3. Performance - No N+1 queries, proper caching
4. Security - No vulnerabilities introduced
5. Side effects - Any unintended changes?
**Output Format:**
- PASS: Code is good
- ISSUES: List specific issues with file:line and fix suggestion
` : '// Skip Backend review - not in scope'}
${plan.scope.includes('Frontend') ? `
## Bugfix Code Review Request
**Issue:** #${ISSUE_ID}
**Summary:** ${plan.summary}
**Modified Files:**
${plan.files_to_change.filter(f =>
f.file.includes('packages/frontend') ||
f.file.includes('.vue')
).map(f => `- ${f.file}`).join('\n')}
**Review Focus:**
1. Vue 3 best practices - Composition API, reactivity
2. Component structure - Props, emits, slots
3. State management - Pinia store usage
4. Performance - Computed vs methods, v-memo
5. Accessibility - ARIA, keyboard navigation
**Output Format:**
- PASS: Code is good
- ISSUES: List specific issues with file:line and fix suggestion
` : '// Skip Frontend review - not in scope'}
${plan.scope.includes('Mobile') ? `
## Bugfix Code Review Request
**Issue:** #${ISSUE_ID}
**Summary:** ${plan.summary}
**Modified Files:**
${plan.files_to_change.filter(f =>
f.file.includes('packages/mobile') ||
f.file.includes('.dart')
).map(f => `- ${f.file}`).join('\n')}
**Review Focus:**
1. Flutter best practices - Widget composition
2. State management - BLoC/Provider patterns
3. Performance - Build method optimization
4. Platform handling - iOS/Android differences
**Output Format:**
- PASS: Code is good
- ISSUES: List specific issues with file:line and fix suggestion
` : '// Skip Mobile review - not in scope'}
// Collect review results
architect_reviews = await collectReviewResults()
progress.architect_review = architect_reviews
\${JSON.stringify(progress, null, 2)}
\`\`\`
### Phase 4: Fix Issues from Review (if any)
\`\`\`typescript
console.log("\\n🔧 FIX REVIEW ISSUES")
IF architect_reviews.hasIssues:
progress.review_rounds += 1
IF progress.review_rounds > 2:
console.log("⚠️ Max review rounds (2) reached. Manual review needed.")
ELSE:
FOR issue IN architect_reviews.issues:
console.log(\`Fixing: \${issue.file}:\${issue.line}\`)
// Apply fix
\${issue.file}
// Edit to fix the issue
Apply fix: \${issue.suggestion}
// Re-run verification
npx tsc --noEmit 2>&1 | head -20
npm run lint -- --quiet 2>&1 | head -20
// Update progress
\${JSON.stringify(progress, null, 2)}
console.log("✅ Review issues fixed")
ELSE:
console.log("✅ No issues from architect review")
\`\`\`
### Phase 5: Final Verification
\`\`\`typescript
console.log("\\n🔍 FINAL VERIFICATION")
npx tsc --noEmit
npm run lint -- --quiet
npm run test -- --passWithNoTests
await allBackgroundTasks()
IF all_passed:
console.log("✅ All verifications passed!")
ELSE:
console.log("❌ Some verifications failed")
showFailures()
\`\`\`
### Phase 6: Self-Cleanup
\`\`\`typescript
console.log("\\n🧹 CLEANUP")
IF all_passed:
ASK USER: "Delete executor skill and temp files? (Y/N)"
IF user_confirms:
// Delete progress file
rm "\${PROGRESS_FILE}"
// Delete detail files
rm -rf "\${PLAN_DIR}/details/"
// DELETE THIS SKILL (self-cleanup)
rm -rf "\${SKILL_DIR}"
console.log("🎉 Bugfix #${ISSUE_ID} complete! Skill self-deleted.")
console.log("ℹ To cleanup plan: rm -rf \${PLAN_DIR}")
\`\`\`
---
## STRICT RULES
1. **NO SKIP** - Execute each step in order
2. **VERIFY** - TypeScript + Lint after each step
3. **ARCHITECT REVIEW** - Run after all steps complete
4. **FIX ISSUES** - Apply fixes from architect review (max 2 rounds)
5. **SAVE** - Progress after each phase
6. **SELF-DELETE** - Remove this skill after completion
`
${skill_content}
// Save context as JSON for reference
${JSON.stringify(plan, null, 2)}
console.log(`
✅ Dynamic executor skill created (Hybrid Approach)!
Location: ${SKILL_DIR}/SKILL.md
Issue: #${ISSUE_ID}
Scope: ${plan.scope.join(", ")}
Steps: ${plan.implementation_steps.length}
Flow:
1. Implement all steps
2. Architect Review (${plan.scope.join(" + ")})
3. Fix issues (if any)
4. Final verification
5. Self-cleanup
To execute:
/exec-fix-${ISSUE_ID}
This skill will self-delete after successful completion.
`)
```
---
## CLEANUP
Skill tự xóa sau khi hoàn thành, hoặc manual:
```bash
# Delete specific dynamic skill
rm -rf .claude/skills/_dynamic/exec-fix-123/
# Delete all dynamic skills
rm -rf .claude/skills/_dynamic/
```