smart-bug-fix
关于
This skill provides an intelligent bug-fixing workflow that systematically identifies root causes using deep analysis and multi-model reasoning. It then generates fixes through Codex auto-fix and validates them with comprehensive testing and regression analysis. Use this skill for methodical debugging that combines automated fixes with thorough validation.
快速安装
Claude Code
推荐/plugin add https://github.com/DNYoussef/ai-chrome-extensiongit clone https://github.com/DNYoussef/ai-chrome-extension.git ~/.claude/skills/smart-bug-fix在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Smart Bug Fix
Purpose
Systematically debug and fix bugs using root cause analysis, multi-model reasoning, and automated testing.
Specialist Agent
I am a debugging specialist using systematic problem-solving methodology.
Methodology (Root Cause + Fix + Validate Pattern):
- Deep root cause analysis (5 Whys, inverse reasoning)
- Multi-model reasoning for fix approaches
- Codex auto-fix in isolated sandbox
- Comprehensive testing with iteration
- Regression validation
- Performance impact analysis
Models Used:
- Claude (RCA): Deep root cause analysis
- Codex (Fix): Rapid fix implementation
- Claude (Validation): Comprehensive testing
- Gemini (Context): Large codebase analysis if needed
Output: Fixed code with test validation and impact analysis
Input Contract
input:
bug_description: string (required)
context_path: string (directory or file, required)
reproduction_steps: string (optional)
error_logs: string (optional)
depth: enum[shallow, normal, deep] (default: deep)
Output Contract
output:
root_cause: object
identified: string
contributing_factors: array[string]
evidence: array[string]
fix_applied: object
changes: array[file_change]
reasoning: string
alternatives_considered: array[string]
validation: object
tests_passed: boolean
regression_check: boolean
performance_impact: string
confidence: number (0-1)
Execution Flow
#!/bin/bash
set -e
BUG_DESC="$1"
CONTEXT_PATH="$2"
echo "=== Smart Bug Fix Workflow ==="
# PHASE 1: Root Cause Analysis
echo "[1/6] Performing deep root cause analysis..."
npx claude-flow agent-rca "$BUG_DESC" \
--context "$CONTEXT_PATH" \
--depth deep \
--output rca-report.md
# PHASE 2: Context Analysis (if large codebase)
LOC=$(find "$CONTEXT_PATH" -name "*.js" -o -name "*.ts" | xargs wc -l | tail -1 | awk '{print $1}')
if [ "$LOC" -gt 10000 ]; then
echo "[2/6] Large codebase detected - analyzing with Gemini MegaContext..."
gemini "Analyze patterns related to: $BUG_DESC" \
--files "$CONTEXT_PATH" \
--model gemini-2.0-flash \
--output context-analysis.md
else
echo "[2/6] Standard codebase - skipping mega-context analysis"
fi
# PHASE 3: Alternative Solutions (multi-model reasoning)
echo "[3/6] Generating fix approaches..."
# Claude approach (from RCA)
CLAUDE_FIX=$(cat rca-report.md | grep "Solution" -A 10)
# Codex alternative approach
codex --reasoning-mode "Alternative approaches to fix: $BUG_DESC" \
--context rca-report.md \
--output codex-alternatives.md
# PHASE 4: Implement Fix with Codex Auto
echo "[4/6] Implementing fix with Codex Auto..."
codex --full-auto "Fix bug: $BUG_DESC based on RCA findings" \
--context rca-report.md \
--context "$CONTEXT_PATH" \
--sandbox true \
--network-disabled \
--output fix-implementation/
# PHASE 5: Comprehensive Testing with Iteration
echo "[5/6] Testing fix with Codex iteration..."
npx claude-flow functionality-audit fix-implementation/ \
--model codex-auto \
--max-iterations 5 \
--sandbox true \
--regression-check true \
--output test-results.json
# Check if tests passed
TESTS_PASSED=$(cat test-results.json | jq '.all_passed')
if [ "$TESTS_PASSED" != "true" ]; then
echo "⚠️ Tests failed after 5 iterations - escalating to user"
exit 1
fi
# PHASE 6: Performance Impact Analysis
echo "[6/6] Analyzing performance impact..."
npx claude-flow analysis performance-report \
--compare-before-after \
--export performance-impact.json
# Display summary
echo ""
echo "================================================================"
echo "Bug Fix Complete!"
echo "================================================================"
echo ""
echo "Root Cause: $(cat rca-report.md | grep 'Primary Root Cause' -A 2 | tail -1)"
echo "Tests: ✓ All passing"
echo "Regression: ✓ No regressions detected"
echo "Performance Impact: $(cat performance-impact.json | jq '.impact_summary')"
echo ""
echo "Files changed:"
find fix-implementation/ -name "*.js" -o -name "*.ts" | head -10
echo ""
Integration Points
Cascades
- Part of
/bug-triage-workflowcascade - Used by
/production-incident-responsecascade - Invoked by
/fix-bugcommand
Commands
- Uses:
/agent-rca,/gemini-megacontext,/codex-auto,/functionality-audit - Chains with:
/style-audit,/performance-report
Other Skills
- Input to
regression-validatorskill - Used by
incident-responseskill - Integrates with
code-review-assistant
Advanced Features
Automatic RCA Depth Selection
function selectRCADepth(bugDescription, errorLogs) {
if (errorLogs.includes("intermittent") || errorLogs.includes("race condition")) {
return "deep"; // Complex issues need deep analysis
} else if (errorLogs.includes("TypeError") || errorLogs.includes("undefined")) {
return "normal"; // Common errors need normal analysis
} else {
return "shallow"; // Simple issues
}
}
Multi-Model Fix Approach
fix_strategy:
1. Claude RCA → Deep understanding
2. Codex alternatives → Multiple approaches
3. Codex auto-fix → Rapid implementation
4. Claude validation → Comprehensive testing
Codex Iteration Loop
Test → FAIL → Codex fix → Test → FAIL → Codex fix → Test → PASS → Apply
↑ ↓
└────────────────── Max 5 iterations ──────────────────────────────┘
Usage Example
# Fix bug with description
smart-bug-fix "API timeout under load" src/api/
# Fix with reproduction steps
smart-bug-fix "Login fails on Firefox" src/auth/ \
--reproduction-steps "1. Open Firefox 2. Try login 3. See error"
# Fix with error logs
smart-bug-fix "Database connection fails" src/db/ \
--error-logs "logs/error.log"
Failure Modes
- RCA inconclusive: Request more context, run additional diagnostics
- Codex fix fails tests: Try alternative approach, escalate if max iterations reached
- Regression detected: Rollback fix, analyze conflicting requirements
- Performance degradation: Optimize fix, consider alternative approach
GitHub 仓库
相关推荐技能
content-collections
元Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。
evaluating-llms-harness
测试该Skill通过60+个学术基准测试(如MMLU、GSM8K等)评估大语言模型质量,适用于模型对比、学术研究及训练进度追踪。它支持HuggingFace、vLLM和API接口,被EleutherAI等行业领先机构广泛采用。开发者可通过简单命令行快速对模型进行多任务批量评估。
cloudflare-turnstile
元这个Skill提供完整的Cloudflare Turnstile集成知识,用于在表单、登录页面和API端点中实现无验证码的机器人防护。它支持React/Next.js/Hono等框架集成,涵盖令牌验证、错误代码调试和端到端测试等场景。通过运行后台不可见挑战,在保持用户体验的同时有效阻止自动化流量和垃圾信息。
webapp-testing
测试该Skill为开发者提供了基于Playwright的本地Web应用测试工具集,支持自动化测试前端功能、调试UI行为、捕获屏幕截图和查看浏览器日志。它包含管理服务器生命周期的辅助脚本,可直接作为黑盒工具运行而无需阅读源码。适用于需要快速验证本地Web应用界面和交互功能的开发场景。
