Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Systematically debug issues using a structured REPRO → GATHER → HYPOTHESIZE → TEST → FIX → VERIFY workflow. Use when diagnosing bugs, investigating failures, tracing errors, or troubleshooting unexpected behavior in code. Do NOT use when the issue is already identified and a fix is obvious, for code exploration without a specific problem, or for proactive code review.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 50% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 72% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 72% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 70% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 74% | 0% |
Apply a systematic, repeatable workflow to diagnose and resolve bugs. Avoid guessing — every hypothesis must be grounded in evidence.
Follow these six stages in order. Do not skip ahead — each stage builds on the previous one.
Before investigating, confirm you can trigger the bug reliably.
Actions:
Commands:
bash# Run the specific failing test go test ./path/to/pkg -run TestFunctionName -v # Re-run the command that triggers the error <exact command the user reported> # Check recent commits that may have introduced the bug git log --oneline -10 -- <affected-file> # Record environment details go version git log --oneline -3
Checkpoint: You can reproduce the bug consistently before moving on.
Read the relevant code, logs, and context surrounding the failure.
Actions:
Commands:
bash# Read the file where the error occurs cat src/affected-file.ts # Trace imports and callers grep -rn "functionName" --include="*.ts" . # Check git blame for recent changes git log --oneline -5 -- src/affected-file.ts git blame src/affected-file.ts | head -40 # Find related tests grep -rn "TestFunctionName\|functionName" --include="*_test.go" . # Search for error handling around the area grep -B 5 -A 5 "errorMessage" src/affected-file.ts
Checkpoint: You understand what the code is doing, what it should do, and where the gap is.
Based on gathered evidence, propose possible root causes ranked by likelihood.
Actions:
Template:
markdown## Hypothesis 1 (Most Likely) - **Theory:** [description of suspected root cause] - **Evidence for:** [what you've observed that supports this] - **Evidence against:** [what contradicts this] - **How to test:** [specific action to confirm or rule out] ## Hypothesis 2 - **Theory:** [description] - **Evidence for:** [supporting observations] - **Evidence against:** [contradicting observations] - **How to test:** [specific action]
Checkpoint: You have at least one testable hypothesis with a clear verification step.
Run targeted experiments to confirm or eliminate each hypothesis.
Actions:
Commands:
bash# Add debug logging temporarily echo "DEBUG: variableName = $variableName" >&2 # Run with verbose output go test ./path -v -run TestName # Use a debugger or print statements to inspect state # Check intermediate values at key points in the code # If hypothesis is about a specific commit, test before/after git stash # revert changes go test ./... # does it pass? git stash pop # restore changes go test ./... # does it fail?
Checkpoint: You have confirmed the root cause through targeted testing.
Apply the minimal fix that addresses the confirmed root cause.
Actions:
Guidelines:
Validate that the bug is resolved and nothing else broke.
Actions:
Commands:
bash# Re-run the original failing test go test ./path/to/pkg -run TestFunctionName -v # Run the full test suite go test ./... # Run vet/lint to catch additional issues go vet ./... # Check for leftover debug code grep -rn "DEBUG\|TODO.*fix\|HACK" --include="*.go" .
Checkpoint: The bug no longer reproduces, all tests pass, and no debugging artifacts remain.
Scenario: TestUserCreate returns a nil pointer error.
REPRO:
bashgo test ./internal/user -run TestUserCreate -v # Output: panic: runtime error: invalid memory address # at user.Create(): user.go:42
GATHER:
bashcat internal/user/user.go | head -50 # Line 42: result.Email = input.Email # result is the return value of repository.FindByEmail() grep -rn "FindByEmail" --include="*.go" . # Found in internal/user/repository.go:28 cat internal/user/repository.go | sed -n '25,35p' # FindByEmail returns nil, nil when no user is found (correct behavior) # but caller doesn't check for nil before accessing .Email
HYPOTHESIS: The Create function calls FindByEmail to check for duplicates, but doesn't handle the nil-return case when no existing user is found.
TEST: Add a nil check before line 42 and re-run the test.
FIX: Add if result != nil { return nil, ErrAlreadyExists } before accessing result.Email.
VERIFY:
bashgo test ./internal/user -run TestUserCreate -v # passes go test ./internal/user/... -v # all user tests pass
Scenario: API returns 500 on POST /api/orders intermittently.
REPRO:
bashcurl -X POST localhost:3000/api/orders \ -H "Content-Type: application/json" \ -d '{"items": [{"id": 1, "qty": 1}]}' # {"error": "internal server error"} — fails ~30% of the time
GATHER:
bash# Check server logs tail -f logs/app.log | grep "order" # Intermittent: "ERROR: connection refused to database" # Check database connection pool config cat config/database.go | grep -A 5 "Pool" # MaxOpenConns: 5 (too low for production traffic) # Check for long-running queries grep -rn "SELECT" --include="*.go" src/order/ | head -10
HYPOTHESIS: The connection pool is exhausted under load, causing intermittent connection failures. The 30% failure rate matches peak traffic patterns.
TEST: Increase pool to 20 and load-test locally.
FIX: Update MaxOpenConns to 20 and add connection timeout config.
VERIFY:
bash# Load test ab -n 1000 -c 50 http://localhost:3000/api/orders # All requests return 200, no connection errors in logs
If the bug cannot be reproduced:
If the root cause is in a third-party library:
If several independent issues contribute to the bug:
a subagent for a second perspective
Other measured skills in the registry, with their headline benchmark lift.