agentleFS
unlockers-aiunlockers-ai/unlockers-skills-library/skills/bugszero-root-cause/SKILL.md

bugszero-root-cause

Skill4 starsChanged 3 months agoMITView on GitHub

Fix a bug by removing the design weakness that allowed it, not just the failing behaviour. Use when a bug is the second of its kind, when the obvious fix is another defensive check, or whenever a fix should prevent the whole family.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Design the prevention constraint: Prefer constraints that make the mistake unwriteable — types, constructor invariants, a boundary that no …

    line 40
  2. Distinctive:

    If the structural fix is too large for the current change, say so explicitly: apply the narrow fix, name the weakness in the PR …

    line 65

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

BugsZero Root-Cause Fix

Treats a bug as evidence of a design weakness. The fix is not complete when the symptom stops; it is complete when the same family of defect has become hard to write.

Method: docs/bugszero-root-cause.md — read it first, including the bug-pattern catalogue it links to.

Relationship to the ordinary bug workflow

bugfix-workflow.md is the default: reproduce with a failing test, fix, confirm. This skill is what you run when that is not enough — when the bug is the second of its kind, when the natural fix is another guard clause, or when the reproduction was hard to write because the code offers nowhere to stand. It replaces the "fix" step with a structural change; the test-first discipline still applies.

Input

  • The failing behaviour: {bug-description}. If omitted, infer it from the current task or the failing test.
  • The affected code path and a known reproduction.

Process

  1. Characterize the failure. Reproduce it. State actual versus expected. Then widen: what is the family of inputs or states that could fail the same way? Fixing one member of a family is the thing this skill exists to prevent.
  2. Find the enabling weakness. Not "what line is wrong" but "what design choice made this easy to write and hard to notice?" Match it to a known pattern where you can — hidden testable code, index arithmetic, unconstrained construction, temporal coupling, primitive obsession, a null used as a flag, validation that happens too late.
  3. Design the prevention constraint. Prefer constraints that make the mistake unwriteable — types, constructor invariants, a boundary that no longer admits the bad state, an ordering the API enforces — over checks that catch it at runtime. A new defensive if is usually a sign that step 2 has not finished.
  4. Refactor structurally. The smallest coherent change that removes the cause. If it is large, say so and agree the scope before starting rather than half-applying it.
  5. Prove the new invariant. A test for the original bug, and a test that asserts the constraint itself — the one that would fail if someone removed the guarantee later.

Gates before completion

  • The reported bug is fixed.
  • The design weakness has been changed, not bypassed.
  • Reintroducing the same family of defect is now materially harder.
  • Tests assert the new invariant, not just the old symptom.

Output

  • The failure characterization: reproduction, expected versus actual, and the family.
  • The bug pattern identified, and how it allowed this bug.
  • The prevention constraint, and the structural change made.
  • The tests added, and which invariant each one pins.

If the structural fix is too large for the current change, say so explicitly: apply the narrow fix, name the weakness in the PR description, and file the follow-up. An unstated compromise is how the family survives.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.