From develop
Reproduce-first bug resolution — capture bug in failing regression test, apply minimal fix, run quality stack and review loop.
npx claudepluginhub borda/ai-rig --plugin developThis skill is limited to using the following tools:
<objective>
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Reproduce-first bug resolution. Capture the bug in a failing regression test, apply the minimal fix, then verify via quality stack and review loop.
NOT for: unknown failures without a traceback (use /foundry:investigate); .claude/ config issues (use /audit).
Foundry plugin check: run
ls ~/.claude/plugins/cache/ 2>/dev/null | grep -q foundry(exit 0 = installed). If the check fails or you are uncertain, proceed as if foundry is available — it is the common case; only fall back if an agent dispatch explicitly fails.
When foundry is not installed, substitute foundry:X references with general-purpose and prepend the role description plus model: <model> to the spawn call:
| foundry agent | Fallback | Model | Role description prefix |
|---|---|---|---|
foundry:sw-engineer | general-purpose | opus | You are a senior Python software engineer. Write production-quality, type-safe code following SOLID principles. |
foundry:qa-specialist | general-purpose | opus | You are a QA specialist. Write deterministic, parametrized pytest tests covering edge cases and regressions. |
Skills with --team mode: team spawning with fallback agents still works but produces lower-quality output.
| Temptation | Reality |
|---|---|
| "I already know the root cause from the symptom" | Assumptions without verification produce fixes for the wrong bug. Read the code path first. |
| "The regression test can wait — I'll add it after the fix" | A fix without a failing test is unverifiable. The test is the proof the bug existed. |
| "I'll clean up nearby code while I'm here" | Scope creep produces side effects and obscures the actual fix. Touch only the root cause. |
| "The targeted test passes — that's sufficient" | The targeted test shows the bug is fixed; the full suite shows nothing else broke. Both are required. |
| "The fix is obvious — Step 1 analysis is overkill" | Obvious causes are often symptoms. Analysis reveals the actual root cause and blast radius. |
Task hygiene: Before creating tasks, call TaskList. For each found task:
completed if the work is clearly donedeleted if orphaned / no longer relevantin_progress only if genuinely continuingTask tracking: immediately after Step 1 (scope is known), create TaskCreate entries for all steps of this workflow before doing any other work. Mark each step in_progress when starting it, completed when done.
Gather all available context about the bug:
# If issue number: fetch the full issue with comments
gh issue view <number >--comments
If an error message or pattern was provided: use the Grep tool (pattern <error_pattern>, path .) to search the codebase for the failing code path.
# If failing test: run it to capture the exact failure
python -m pytest --tb=long <test_path >-v 2>&1 | tail -40
Structural context (codemap, if installed) — soft PATH check, silently skip if scan-query not found:
PROJ=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null) || PROJ=$(basename "$PWD")
if command -v scan-query >/dev/null 2>&1 && [ -f ".cache/scan/${PROJ}.json" ]; then
scan-query central --top 5
fi
If results are returned: prepend a ## Structural Context (codemap) block to the foundry:sw-engineer spawn prompt with the hotspot JSON. If scan-query is not found or index is missing: proceed silently — do not mention codemap to the user.
Spawn a foundry:sw-engineer agent to analyze the failing code path and identify:
If the root cause is not definitively established after analysis, surface assumptions before proceeding:
ASSUMPTIONS I'M MAKING:
- [assumption about root cause]
- [assumption about affected scope] → Correct me now or I'll proceed with these.
Scope gate: if the root cause spans 3+ modules, flag the complexity smell. Use AskUserQuestion to present the scope concern before proceeding, with options: "Narrow scope (Recommended)" / "Proceed anyway".
Create or identify a test that demonstrates the failure:
# If a failing test already exists — run it to confirm it fails
python -m pytest --tb=short <test_file >:: <test_name >-v
# If no test exists — write a regression test that captures the bug
Spawn a foundry:qa-specialist agent to write the regression test if one doesn't exist:
pytest.mark.parametrize if the bug affects multiple input patterns# Regression test for #123)Gate: the regression test must fail before proceeding. If it passes, the bug isn't properly captured — revisit Step 1.
Before applying any fix, critically evaluate the regression test itself:
If any issue is found: revise the regression test before applying the fix. A flawed reproduction means the fix will be validated against the wrong criteria.
Make the minimal change to fix the root cause:
python -m pytest --tb=short <test_file >:: <test_name >-v
python -m pytest --tb=short <test_dir >-v
Full review of the fix. This is a loop — review -> fix -> re-review until only nits remain. Maximum 3 cycles.
Each cycle:
5-axis quality scan — before the full criteria evaluation, assess the fix on each axis:
Use this scan to prioritize which criteria below get deepest scrutiny.
Evaluate against all criteria:
For every gap found: implement the fix immediately — tighten the patch, remove collateral edits, adjust the test. Return to Step 3 for any gap that requires re-examining the fix approach.
Re-run the test suite:
python -m pytest --tb=short -q <test_dir >-v 2>&1 | tail -20
Adjacent bugs (observation only): scan for similar patterns in the codebase; document in Follow-up — do not fix here to avoid scope creep.
If only nits remain: document in Follow-up and exit the loop.
If substantive gaps remain: start the next cycle (max 3 total).
After 3 cycles: if substantive issues remain, stop — surface them to the user before proceeding.
Read .claude/skills/_shared/quality-stack.md and execute the Branch Safety Guard, Quality Stack, Codex Pre-pass, Progressive Review Loop, and Codex Mechanical Delegation steps.
## Fix Report: <bug summary>
### Root Cause
[1-2 sentence explanation of what was wrong and why]
### Regression Test
- File: <test_file>
- Test: <test_name>
- Confirms: [what behavior the test locks in]
- Disposition: keep if a test runner auto-discovers this file; otherwise add to Follow-up as a cleanup candidate
### Changes Made
| File | Change | Lines |
|------|--------|-------|
| path/to/file.py | description of fix | -N/+M |
### Test Results
- Regression test: PASS
- Full suite: PASS (N tests)
- Lint: clean
### Follow-up
- [any related issues or code that should be reviewed]
- [if no test runner: `rm <test_file>` — no test suite will re-execute it; it served the gate, now expendable]
## Confidence
**Score**: 0.N — [high ≥0.9 | moderate 0.8–0.9 | low <0.8 ⚠]
**Gaps**: [e.g., could not reproduce locally, partial traceback only, fix not runtime-tested]
**Refinements**: N passes.
When to use team mode: root cause unclear after Step 1, OR bug spans 3+ modules.
Coordination:
{bug: <description>, traceback: <key lines>}Spawn prompt template:
You are a foundry:sw-engineer teammate debugging: [bug description].
Read ~/.claude/TEAM_PROTOCOL.md — use AgentSpeak v2 for inter-agent messages.
Your hypothesis: [hypothesis N]. Investigate ONLY this root cause.
Report findings to @lead using deltaT# or epsilonT# codes.
Compact Instructions: preserve file paths, errors, line numbers. Discard verbose tool output.
Task tracking: do NOT call TaskCreate or TaskUpdate — the lead owns all task state. Signal your completion in your final delta message: "Status: complete | blocked — <reason>".