Use when debugging regressions or identifying which commit introduced a bug - provides systematic workflow for git bisect with automated test scripts, manual verification, or hybrid approaches. Can be invoked from systematic-debugging as a debugging technique, or used standalone when you know the issue is historical.
This skill inherits all available tools. When active, it can use any tool Claude has access to.
Systematically identify which commit introduced a bug or regression using git bisect. This skill provides a structured workflow for automated, manual, and hybrid bisect approaches.
Core principle: Binary search through commit history to find the exact commit that introduced the issue. Main agent orchestrates, subagents execute verification at each step.
Announce at start: "I'm using git-bisect-debugging to find which commit introduced this issue."
| Phase | Key Activities | Output |
|---|---|---|
| 1. Setup & Verification | Identify good/bad commits, verify clean state | Confirmed commit range |
| 2. Strategy Selection | Choose automated/manual/hybrid approach | Test script or verification steps |
| 3. Execution | Run bisect with subagents | First bad commit hash |
| 4. Analysis & Handoff | Show commit details, analyze root cause | Root cause understanding |
These are non-negotiable. No exceptions for time pressure, production incidents, or "simple" cases:
✅ ANNOUNCE skill usage at start:
"I'm using git-bisect-debugging to find which commit introduced this issue."
✅ CREATE TodoWrite checklist immediately (before Phase 1):
✅ VERIFY safety checks (Phase 1 - no skipping):
git status)✅ USE AskUserQuestion for strategy selection (Phase 2):
✅ LAUNCH subagents for verification (Phase 3):
✅ HANDOFF to systematic-debugging (Phase 4):
If you catch yourself thinking ANY of these, you're about to violate the skill:
git status to verify.All of these mean: STOP. Follow the 4-phase workflow exactly.
Copy this checklist to track progress:
Git Bisect Progress:
- [ ] Phase 1: Setup & Verification (good/bad commits identified)
- [ ] Phase 2: Strategy Selection (approach chosen, script ready)
- [ ] Phase 3: Execution (first bad commit found)
- [ ] Phase 4: Analysis & Handoff (root cause investigation complete)
Purpose: Ensure git bisect is appropriate and safe to run.
Steps:
Verify prerequisites:
git status)Identify commit range:
git log --oneline, git tag, git log --since="last week"HEAD or a specific commit where issue confirmedVerify the range:
Safety checks:
Output: Confirmed good commit hash, bad commit hash, estimated steps
Purpose: Choose the most efficient bisect approach.
Assessment: Can we write an automated test script that deterministically identifies good vs bad?
MANDATORY: Use AskUserQuestion tool to present these three approaches (do NOT default to automated):
AskUserQuestion({
questions: [{
question: "Which git bisect approach should we use?",
header: "Strategy",
multiSelect: false,
options: [
{
label: "Automated - test script runs automatically",
description: "Fast, no manual intervention. Best for: test failures, crashes, deterministic behavior. Requires: working test script."
},
{
label: "Manual - you verify each commit",
description: "Handles subjective issues. Best for: UI/UX changes, complex scenarios. Requires: you can manually check each commit."
},
{
label: "Hybrid - script + manual confirmation",
description: "Efficient with reliability. Best for: mostly automated but needs judgment. Requires: script for most cases, manual for edge cases."
}
]
}]
})
Three approaches to present:
Approach 1: Automated Bisect
Approach 2: Manual Bisect
Approach 3: Hybrid Bisect
If automated or hybrid selected:
Write test script following this template:
#!/bin/bash
# Exit codes: 0 = good, 1 = bad, 125 = skip (can't test)
# Setup/build (required for each commit)
npm install --silent 2>/dev/null || exit 125
# Run the actual test
npm test -- path/to/specific-test.js
exit $?
Script guidelines:
If manual selected:
Write specific verification steps for subagent:
Good example:
1. Run `npm start`
2. Open browser to http://localhost:3000
3. Click the "Login" button
4. Check if it redirects to /dashboard
5. Respond 'good' if redirect happens, 'bad' if it doesn't
Bad example:
See if the login works
Output: Selected approach, test script (if automated/hybrid), or verification steps (if manual)
Architecture: Main agent orchestrates bisect, subagents verify each commit in isolated context.
Main agent responsibilities:
start, good, bad, reset)Subagent responsibilities:
Execution flow:
Main agent: Run git bisect start <bad> <good>
Loop until bisect completes:
a. Git checks out a commit to test
b. Main agent launches subagent using Task tool:
For automated:
Prompt: "Run this test script and report the result:
<script content>
Report 'good' if exit code is 0, 'bad' if exit code is 1, 'skip' if exit code is 125.
Include the output of the script in your response."
For manual:
Prompt: "We're testing commit <hash> (<message>).
Follow these verification steps:
<verification steps>
Report 'good' if the issue doesn't exist, 'bad' if it does exist.
Explain what you observed."
For hybrid:
Prompt: "Run this test script:
<script content>
If exit code is 0 or 1, report that result.
If exit code is 125 or script is ambiguous, perform manual verification:
<verification steps>
Report 'good', 'bad', or 'skip' with explanation."
c. Subagent returns: Result ("good", "bad", or "skip") with explanation
d. Main agent: Run git bisect good|bad|skip based on result
e. Main agent: Update progress
git bisect log | grep "# .*step" | tail -1f. Repeat until git bisect identifies first bad commit
Main agent: Run git bisect reset to cleanup
Main agent: Return to original branch/commit
Error handling during execution:
git bisect skipgit bisect reset runs in cleanupOutput: First bad commit hash, bisect log showing the path taken
Purpose: Present findings and analyze root cause.
Steps:
Present the identified commit:
Found first bad commit: <hash>
Author: <author>
Date: <date>
<commit message>
Files changed:
<list of files from git show --stat>
Show how to view details:
View full diff: git show <hash>
View file at that commit: git show <hash>:<file>
Handoff to root cause analysis:
<hash>, I'm using systematic-debugging to analyze why this change caused the issue."Output: Root cause understanding of why the commit broke functionality
git bisect skip, continuegit bisect skip, max 5 skipsgit bisect reset when done (success or failure)git bisect resetgit log --since="2 weeks ago" to find starting pointDo:
Don't:
Be specific:
Give exact steps:
npm start| Issue Type | Recommended Approach | Script/Steps Example |
|---|---|---|
| Test failure | Automated | npm test -- failing-test.spec.js |
| Crash/error | Automated | `node app.js 2>&1 |
| Performance | Automated | time npm run benchmark | awk '{if ($1 > 5.0) exit 1}' |
| UI/UX change | Manual | "Click X, verify Y appears" |
| Behavior change | Manual or Hybrid | Script to check, manual to confirm subjective aspects |
git bisect log| Rationalization | Reality | What to Do Instead |
|---|---|---|
| "User is in a hurry, skip safety checks" | Broken bisect from dirty state wastes MORE time | Run all Phase 1 checks. Always. |
| "This is simple, no need for TodoWrite" | You'll skip phases without tracking | Create checklist immediately |
| "I'll just use automated approach" | User might prefer manual for vague issues | Use AskUserQuestion tool |
| "I'll run the test in my context" | Context bleeding between commits breaks bisect | Launch subagent for each verification |
| "Working directory looks clean" | Assumptions cause failures | Run git status to verify |
| "I'll verify good/bad commits later" | Starting with wrong good/bad wastes all steps | Verify BEFORE git bisect start |
| "Found the commit, user knows why" | User asked to FIND it, not debug it | Hand off to systematic-debugging |
| "Production incident, no time for process" | Skipping process in incidents causes MORE incidents | Follow workflow. It's faster. |
| "I remember from baseline, no need to test" | Skills evolve, baseline was different session | Test at each commit with subagent |
If you catch yourself rationalizing, STOP. Go back to MANDATORY Requirements section.
When systematic-debugging determines an issue is historical:
systematic-debugging detects:
- Issue doesn't exist in commit from 2 weeks ago
- Issue exists now
→ Suggests: "This appears to be a regression. I'm using git-bisect-debugging to find when it was introduced."
→ Invokes: git-bisect-debugging skill
→ Returns: First bad commit for analysis
→ Resumes: systematic-debugging analyzes the breaking change
In Phase 4, after finding the bad commit:
git-bisect-debugging completes:
→ Announces: "Found commit abc123. Using systematic-debugging to analyze root cause."
→ Invokes: superpowers:systematic-debugging
→ Context: "Focus on changes in commit abc123"
→ Goal: Understand WHY the change broke functionality
This skill focuses on straightforward scenarios. It does NOT handle:
--first-parent)For these scenarios, manual git bisect with user guidance is recommended.
User: "The login test started failing sometime in the last 50 commits."
Claude: "I'm using git-bisect-debugging to find which commit introduced this issue."
[Phase 1: Setup]
- git status → clean
- Good commit: v1.2.0 tag (last release)
- Bad commit: HEAD
- Verify: checkout v1.2.0, run test → passes
- Verify: checkout HEAD, run test → fails
- Range: 47 commits, ~6 steps estimated
[Phase 2: Strategy Selection]
AskUserQuestion: Which approach?
User selects: Automated
Script created:
#!/bin/bash
npm install --silent 2>/dev/null || exit 125
npm test -- tests/login.spec.js
exit $?
[Phase 3: Execution]
Step 1: Launch subagent for commit abc123
Subagent: "Test failed. Exit code 1. bad"
Main: git bisect bad → ~3 steps remaining
Step 2: Launch subagent for commit def456
Subagent: "Test passed. Exit code 0. good"
Main: git bisect good → ~2 steps remaining
Step 3: Launch subagent for commit ghi789
Subagent: "Test failed. Exit code 1. bad"
Main: git bisect bad → ~1 step remaining
Step 4: Launch subagent for commit jkl012
Subagent: "Test passed. Exit code 0. good"
Main: git bisect good
Git bisect identifies: ghi789 is first bad commit
[Phase 4: Analysis]
Found first bad commit: ghi789
Author: John Doe
Date: 2025-11-10
feat: update authentication middleware
Files changed:
src/auth/middleware.js | 12 ++++---
tests/login.spec.js | 3 +-
Using systematic-debugging to analyze why this change broke the test...
[Hands off to systematic-debugging skill]
User: "The dashboard layout looks wrong, but I'm not sure when it broke."
Claude: "I'm using git-bisect-debugging to find which commit introduced this issue."
[Phase 1: Setup]
- git status → clean
- Good commit: 2 weeks ago (user remembers it working)
- Bad commit: HEAD
- Range: 89 commits, ~7 steps estimated
[Phase 2: Strategy Selection]
AskUserQuestion: Which approach?
User selects: Manual
Verification steps created:
1. Run `npm run dev`
2. Open browser to http://localhost:3000/dashboard
3. Check if the sidebar and main content are side-by-side
4. Respond 'good' if layout is correct, 'bad' if sidebar overlaps content
[Phase 3: Execution]
Step 1: Checkout commit abc123
Launch subagent with verification steps
User verifies: "Layout is correct. good"
Main: git bisect good → ~3 steps remaining
Step 2: Checkout commit def456
Launch subagent with verification steps
User verifies: "Sidebar overlaps content. bad"
Main: git bisect bad → ~2 steps remaining
... continues until first bad commit found
[Phase 4: Analysis]
Found first bad commit: mno345
Author: Jane Smith
Date: 2025-11-08
refactor: migrate to CSS Grid layout
Files changed:
src/components/Dashboard.css | 25 +++++++++++----------
Using systematic-debugging to analyze the CSS changes...
[Hands off to systematic-debugging skill]
User: "API response times got slower recently."
Claude: "I'm using git-bisect-debugging to find which commit introduced this issue."
[Phase 1: Setup]
- git status → clean
- Good commit: last release tag v2.1.0
- Bad commit: HEAD
- Range: 120 commits, ~7 steps estimated
[Phase 2: Strategy Selection]
AskUserQuestion: Which approach?
User selects: Hybrid
Script created:
#!/bin/bash
npm install --silent 2>/dev/null || exit 125
# Run benchmark 3 times, take average
total=0
for i in 1 2 3; do
time=$(npm run benchmark:api 2>/dev/null | grep "response_time" | awk '{print $2}')
[ -z "$time" ] && exit 125 # Can't test
total=$(echo "$total + $time" | bc)
done
avg=$(echo "scale=2; $total / 3" | bc)
# Threshold: 500ms is acceptable
if (( $(echo "$avg > 500" | bc -l) )); then
exit 1 # bad (too slow)
else
exit 0 # good (fast enough)
fi
Manual fallback steps:
"If script is ambiguous, manually test API and verify response time is <500ms"
[Phase 3: Execution]
Steps proceed with script automation...
If script returns 125 (can't test), subagent asks user to manually verify
[Phase 4: Analysis]
Found first bad commit: pqr678
Author: Bob Johnson
Date: 2025-11-11
feat: add caching layer for user preferences
Files changed:
src/api/middleware/cache.js | 45 ++++++++++++++++++++++++++++++++
Using systematic-debugging to analyze the caching implementation...
[Reveals: Cache lookup is synchronous and blocking, causing slowdown]
If early results suggest good/bad are swapped:
If >5 commits skipped:
If bisect state is corrupted or interrupted:
git bisect reset # Clean up bisect state
git checkout main # Return to main branch
# Restart bisect with better range/script
When to use: Historical bugs, regressions, "when did this break" questions
Key strengths:
Remember:
git bisect reset