agentsclimarketplace

Bug fix

Skill paulingham/.claude/skills/bug-fix

Root cause analysis workflow with incremental TDD for bug fixes. Covers reproduce, analyze, regression test, fix, verify, and prevent. Use when fixing bugs to ensure proper methodology.From its SKILL.md

Install
npx -y skills add paulingham/.claude --skill bug-fix

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

6.2 KB, as published. Nobody here has run it

Bug Fix Workflow

Follow root cause analysis methodology with per-behaviour RED-GREEN-REFACTOR (the bug-fix exception to ATDD's batched cycle — see protocols/atdd-procedure.md § When per-behaviour TDD Still Applies).

IRON LAW: WRITE THE FAILING REPRO TEST AND SEE IT FAIL BEFORE WRITING ANY FIX CODE. NO EXCEPTIONS.

The repro test IS the contract. One bug, one repro test, observed RED for the right reason, BEFORE the fix is written. Bug fixes do NOT use the batched-RED ATDD cycle — per-behaviour RED-first TDD is mandatory here.

Process

  1. Step 0 — AssertFlip Reproducer (MANDATORY, BEFORE anything else): Write a passing test against the buggy code that captures its current (wrong) behaviour, then invert the assertions so the test fails on the bug. This guarantees a failing-for-the-right-reason reproducer before any fix attempt. Capture the path to this test file as the reproducer artifact — it is a required payload field on BUG_FIXED. Technique: arXiv 2507.17542 (AssertFlip), 43.6% fail-to-pass on SWT-Bench-Verified. Do NOT skip this in favour of a free-hand failing test — AssertFlip eliminates the "test fails for the wrong reason" failure mode (missing import, wrong fixture, typo) that ordinary RED-first authoring is prone to. The captured RED test output is red_evidence; the captured GREEN test output (after the fix) is green_evidence. Both MUST be persisted to the reproducer_artifact mapping alongside path. When root-cause analysis confidently identifies the originating merged pipeline (e.g. the prior PR that introduced the regression), record its task-id as triggered_by_pipeline_id in the Step 4d-i observation; OMIT when not confidently known — NEVER fabricate a link.
  2. Reproduce (MANDATORY RED): Run the suite ONCE with the Step 0 test in place. Capture the RED output. Verify it fails for the actual bug — not a syntax error, not a missing import. The RED output + the reproducer test path together are the audit artifact that proves the bug existed; without both, you have not reproduced anything.
  3. Root Cause Analysis: Trace the issue to the exact source
  4. Regression Test: Ensure the failing test covers the exact bug scenario
  5. Fix: Write minimum code to make the test pass
  6. Verify: All tests pass including new regression test
  7. Prevention: Apply design patterns to prevent recurrence
  8. PR: Create PR with bug description, root cause, and fix

Context

Gather state before starting:

# Recent failures and changes
git status
git log --oneline -5

Worktree Isolation

Spawn the fixing engineer with isolation: "worktree":

Agent({
  subagent_type: "software-engineer",
  isolation: "worktree",
  prompt: "Fix bug: [description]. Root cause: [analysis]..."
})

This ensures the fix is isolated and can be discarded if the approach is wrong.

Root Cause Analysis Template

  • Symptom: What the user sees
  • Expected Behavior: What should happen
  • Actual Behavior: What actually happens
  • Root Cause: Why it happens (trace to exact file:line)
  • Fix: What changes resolve it
  • Prevention: How to prevent recurrence (pattern, validation, test)

Fix Verification Checklist

  • Failing test written BEFORE fix
  • Fix is minimal - only what's needed
  • All existing tests still pass
  • No regressions introduced
  • Root cause documented in PR description
  • Design pattern applied if recurrence risk exists

Complex Bug Escalation

If the bug meets ANY of these criteria, invoke /harness:debug to create persistent debug state:

  • Requires environment-dependent testing (device, staging, browser)
  • Root cause is not obvious after initial analysis
  • Multiple hypotheses need systematic elimination
  • Fix requires more than 2 fix-test cycles

The /harness:debug skill creates $state_dir/{task-id}/debug.md that survives context compaction and session boundaries. See the debug skill for the full hypothesis tracking protocol.

Design Patterns for Prevention

  • Guard clauses: Prevent invalid state from propagating
  • Value Objects: Ensure data integrity at construction
  • Strategy: Replace fragile conditionals with polymorphism
  • Observer: Decouple event handling to prevent cascading failures

Tech-Stack-Specific Debugging

Read the project's tech stack pattern file for language-specific and framework-specific debugging guidance:

  • Check ~/.claude/skills/[stack]-patterns/SKILL.md (e.g., react-native-patterns/SKILL.md)
  • The pattern file contains debugging strategies, common pitfalls, and framework-specific tools
  • If no pattern file exists, apply general debugging principles: trace the call stack, check error boundaries, verify state management

Prerequisite

  • Bug reported with reproduction steps (or steps to be discovered)
  • Codebase accessible and tests runnable

Verdict

After the fix verification checklist passes, produce:

  • BUG_FIXED: Regression test written, fix minimal, all tests green, root cause documented. Payload MUST include reproducer_artifact: as a mapping with required keys {path, red_evidence, green_evidence} per AssertFlip Step 0. path is the Step 0 reproducer test file; red_evidence captures the pre-fix RED output; green_evidence captures the post-fix GREEN output. Verdict without any of these three keys is rejected by hooks/bug-fixed-payload-validator.sh.
  • BUG_UNRESOLVED: Cannot reproduce, or fix introduces regressions. Document findings.

Phase Output

Verdict: BUG_FIXED / BUG_UNRESOLVED
Next: /harness:code-review + /harness:security-review (parallel, single message)
Reproducer artifact: mapping {path, red_evidence, green_evidence} (REQUIRED on BUG_FIXED — AssertFlip Step 0 output; all three keys mandatory)
Artifacts: [list of changed/created files, regression test file]
Root cause: [1-2 sentence summary]
Agent summaries: [engineer's 2-3 sentence contribution summary]

$ARGUMENTS

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.