bug-fix
Skill12 starsChanged 6 months agoMITView on GitHub
Use this skill when the user wants to fix a defect — a deviation between current behavior and intended behavior in existing code. Triggers on "fix bug", "fix this bug", "diagnose and fix", "investigate this regression", "this is broken", "crash", "wrong output", "perf regression". For defect-shaped tasks that touch more than one file. Do NOT use for new features (use `new-spec`) or refactors unrelated to fixing incorrect behavior.
19 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- BUGLAN/skillstheir own version, first seen Oct 6, 2026
- eugenelim/agent-ready-repoedited, first seen Oct 3, 2026
- lldwb/lldwb-claude-skillstheir own version, first seen Sep 28, 2026
- sd0xdev/sd0x-harnesstheir own version, first seen Sep 26, 2026
- GangJaeYu/harness_loop_full_koreantheir own version, first seen Sep 23, 2026
- syanga/astacktheir own version, first seen Sep 20, 2026
Used with
Projects with it also use refactor and code-review.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
GitHubSkillrefactor
Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
Also in 3 projects that use this
GoogleSkillcode-review
Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.
Also in 3 projects that use this
Other versions19 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- eugenelim/agent-ready-repo★ 2421% same
Wrote their own version · 18
- techygarg/lattice★ 197same name
- sd0xdev/sd0x-harness★ 191same name
- undeadlist/claude-code-agents★ 149same name
- nwiizo/claudelytics★ 89same name
- chrisallenlane/claude-swe-workflows★ 18same name
- hadyfayed/laravel-agent★ 14same name
- mae616/ai-template★ 9same name
- thixpin/claude-config★ 8same name
- ramboz/jig★ 7same name
- GangJaeYu/harness_loop_full_korean★ 4same name
8 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- new-adrSkill
- new-rfcSkill
- new-specSkill
- security-checklistsSkill
- update-conventionsSkill
- work-loopSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 0 are common, 12 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 15 edited versions we read keep these.
12
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Reproduce first: Don't write a fix until you have one of: a failing test, documented manual reproduction steps that fail reliably, or a …
- Distinctive: line 41
Test passes for the wrong reason: Run the test against the unfixed code.
- Distinctive: line 45
List candidate causes, then falsify each: Before asserting a root cause, name 2-3 plausible causes — not just the first one that comes to …
- Distinctive: line 63
Identify root cause before writing the fix: Write down a one-line answer to each:
- Distinctive: line 85
Minimum fix: Write the smallest change that turns the failing test green.
- Distinctive: line 90
Verify root vs symptom: Look at the diff and ask: does this address what step 4 identified, or does it mask the symptom?
- Very specific: line 95
Defensive checks at every call site: when the invariant should hold upstream.
- Distinctive: line 99
Retries around flaky code: when the right fix is to make the code deterministic.
- Distinctive: line 101
Feature flags that disable the broken path: instead of fixing it. Flags are for staged rollout, not for hiding bugs.
- Distinctive: line 104
If the failing test from step 2 still passes under a symptom-only fix, you wrote the wrong test — go back to step 2 and sharpen it.
- Distinctive: line 112
Don't delete it after the fix lands.
- Very specific: line 114
Commit body documents the root cause: Commit subject in the project's format (v2: task <N> - <summary> during the v2 migration.
- Distinctive: line 136
If the spec and the fix disagree, one of them is wrong — surface that explicitly before continuing, don't paper over it.
- Distinctive: line 139
Document what was tried, on what version, with what data, before giving up.
“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: bug-fix
Fix a defect in the smallest, most root-causing way. The discipline is universal: reproduce before fixing, write the failing test first, falsify rival hypotheses before asserting a cause, identify root vs symptom, close the coverage gap that let it through, minimum diff, commit body documents why.
When to invoke
Even a one-line fix benefits from walking this discipline; it forces the question "is this fixing the cause or hiding it?"
For multi-file changes that go beyond fixing one defect — refactors,
new features triggered by discovering the bug — stop and use
new-spec instead. This skill is for bug fixes, not opportunistic
restructuring.
Procedure
- Reproduce first. Don't write a fix until you have one of: a failing test, documented manual reproduction steps that fail reliably, or a captured error / stack trace / log signature. No reproduction = no fix; you might be fixing the wrong thing.
- Write the failing test (red). It should pin the observable
contract being violated, not the current implementation. Push
back on these failure modes:
- Mock-shape assertion.
expect(mock).toHaveBeenCalledWith(...)when the observable contract is a returned value or state change. Test the contract, not the implementation. (Seequality-engineer's "mock-shape assertions" check.) - Test passes for the wrong reason. Run the test against the unfixed code; confirm it fails because of the bug, not because the setup is wrong.
- Mock-shape assertion.
List candidate causes, then falsify each. Before asserting a root cause, name 2-3 plausible causes — not just the first one that comes to mind. For each, write Expected / Actual / Verdict: what you'd observe if that cause were true, what a probe (a log, a breakpoint, a one-off experiment) actually shows, and whether that rules the cause in or out. For example:
- Cause A: input arrives unsorted. Expected: log shows out-of-order keys. Actual: keys are sorted. Verdict: ruled out.
- Cause B: cache returns a stale entry. Expected: second call skips the loader. Actual: loader never runs on the repro. Verdict: ruled in.
Fixating on the first plausible cause is how you fix the wrong thing; making yourself name rivals and kill them with evidence keeps you honest. One survivor that the evidence supports becomes the root cause you assert in step 4.
- Identify root cause before writing the fix. Write down a
one-line answer to each:
- Where is the defect actually? In the called function, the
caller, their shared assumption, or upstream of both? A null
that crashes in
parse()may originate in the loader that should never have produced null. - When did it start?
git logandgit blameon the affected code. For regression-shaped bugs the commit that broke it often tells you why; even for non-regressions, the commit messages surrounding the affected lines surface the original intent and context. - Could the same class of bug exist elsewhere? Grep for similar patterns — same function called from other sites, same assumption made elsewhere. If yes, decide whether the fix's scope widens or whether you file follow-up tickets and add an explicit non-goal ("fix here only").
- Why wasn't it caught? Which test, assertion, or guard should have caught this and didn't — or never existed? Name the specific coverage gap (an untested branch, a contract no test pinned, an input class no fixture covered). The regression test in step 7 closes that gap, not just the one input you observed.
- Where is the defect actually? In the called function, the
caller, their shared assumption, or upstream of both? A null
that crashes in
- Minimum fix. Write the smallest change that turns the failing
test green. Refuse to fix adjacent issues in the same PR; note
them for follow-up. (Echoes
adversarial-reviewer's scope check — out-of-scope changes are a Blocker until justified or extracted.) Verify root vs symptom. Look at the diff and ask: does this address what step 4 identified, or does it mask the symptom? Common symptom-only anti-patterns to refuse:
- Catch-all exception handlers that swallow the bug instead of making the failing call not throw.
- Defensive checks at every call site when the invariant
should hold upstream. Twelve
if (x == null) returncallers of a function that should never return null is masking, not fixing. - Retries around flaky code when the right fix is to make the code deterministic.
- Feature flags that disable the broken path instead of fixing it. Flags are for staged rollout, not for hiding bugs.
If the failing test from step 2 still passes under a symptom-only fix, you wrote the wrong test — go back to step 2 and sharpen it.
- Regression test stays. The failing test from step 2 is the regression test. It lives in the suite; it must pin the real invariant so it catches this bug if it recurs — and it should close the coverage gap named in step 4, pinning the invariant that was missing rather than only the one input you observed. Don't delete it after the fix lands.
- Commit body documents the root cause. Commit subject in the
project's format (
v2: task <N> - <summary>during the v2 migration;fix(<scope>): <subject>after v2.0.0) plus a body explaining what was wrong (the observable bug), why it was wrong (the root cause from step 4), and why the fix takes the shape it does. The diff shows what; the commit body shows why. Future readers care more about the latter. - Loop back to the tracker (if any). Comment the PR URL on the
ticket and apply the next transition. The mechanism is
adopter-specific (Jira MCP, Linear CLI,
gh issue comment, etc.); the obligation — keeping the ticket synced — is universal.
Anti-patterns to refuse
- Fixing forward without a reproduction. The obvious fix is wrong about a third of the time, and you can't tell which third until the test fails red first.
- Fixing the bug plus adjacent cleanup in one PR. Each cleanup is its own PR with its own justification. Bug-fix PRs are for fixing bugs.
- Adjusting the spec or the test to match the buggy behavior. If the spec and the fix disagree, one of them is wrong — surface that explicitly before continuing, don't paper over it.
- Closing as "not reproducible" without trying hard enough. Document what was tried, on what version, with what data, before giving up. "Couldn't reproduce on my machine" is a hypothesis worth testing, not a closing condition.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

