Skip to content
Back to skills

Bug Fixer Root Cause

ASecurity

Used by the Bug Fixer agent - method for finding the true root cause of a reproduced bug - trace the bad value back to its origin, compare with working code, test one written hypothesis at a time, never stack fixes, stop after three failed fixes, then search for the same bug elsewhere. Use after a bug is reproduced and before writing its fix.

  • 12 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentsrustgonodegitdatabasesecurity

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add MhdAljuboori/ZumiBot --skill bug-fixer-root-cause --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Bug Fixer Root Cause?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Bug Fixer Root Cause
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mhdaljuboori-bug-fixer-root-cause/badge)](https://www.skillsdirectory.com/skills/mhdaljuboori-bug-fixer-root-cause)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: bug-fixer-root-cause
description: Used by the Bug Fixer agent - method for finding the true root cause of a reproduced bug - trace the bad value back to its origin, compare with working code, test one written hypothesis at a time, never stack fixes, stop after three failed fixes, then search for the same bug elsewhere. Use after a bug is reproduced and before writing its fix.
---

# Tracing a root cause

The place where the error appears is rarely the place where things went wrong. A null dereference at line 300 is usually a null created at line 40 in another file. Fixing line 300 hides the bug; fixing line 40 removes it.

## 1. Trace the bad value backwards
Start at the symptom and walk upstream:
1. At the failing line, what value is wrong? Print it. Do not assume.
2. Where did that value come from? The caller, a field, a return value, a config read, a database row.
3. Go to that place. Was the value already wrong when it arrived, or did this code make it wrong?
4. Repeat until you find the first point where a correct input produces a wrong output. That is the root cause.
5. Before you change that line, run `git blame` on it and `git log -S '<snippet>'`: learn why it is that way. The commit message may name a case your fix would break.

Tools: the stack trace (each frame is one step up), a debugger with breakpoints at each step, or temporary prints of the value and its type at each step. When the call path is unclear, add a stack trace print at the point of failure (`console.trace()`, `traceback.print_stack()`, `Thread.dumpStack()`, `debug.PrintStack()`) to see who called it.

## 2. Distrust your assumptions
The bug lives in the gap between what you believe the code does and what it does. Check, do not assume:
- The value and its **type** (string `"0"` vs number `0`, `None` vs empty list, seconds vs milliseconds).
- That the code you are reading is the code that runs: right file, right branch, rebuilt, not cached, not a stale compiled copy, not a different version in `node_modules` or `site-packages`.
- That the function is called at all, and how many times.
- That config and environment variables hold what you think, in this process.
- That the test runs what you think it runs (not skipped, not filtered out).

When something "cannot happen", print it. It is happening.

## 3. Compare with working code
Find something similar that works: the same feature on another endpoint, the previous version, another caller of the same function, the library's own example.
- Read the working reference in full, not a skim.
- List **every** difference between it and the broken code, however small: argument order, an `await`, a default value, the order of setup calls, a config key, a version.
- Do not dismiss a difference because "that can't matter". Test it.

## 4. One hypothesis at a time
Write the hypothesis down, in one sentence: **"X is the root cause because Y."** For example: "The total is wrong because `discount` is read before the cart loads, so it is always 0."

Then:
- Predict what you will see if it is true, and what you will see if it is false.
- Run the smallest check that tells the two apart: one print, one assert, one changed input. Change one variable only.
- True: you can explain the full chain from cause to symptom. Go to the fix.
- False: write down what you learned, cross it off, form the next hypothesis. Do not pile a second change on top of the first; undo it.

Never stack fixes ("let me also change this while I am here"). If the bug goes away after three changes, you do not know which one fixed it, or whether the other two broke something.

## 5. Know when the cause is found
You have the root cause when all of these hold:
- You can explain every step from the cause to the symptom.
- The explanation also explains any other odd symptoms seen along the way.
- Changing the code at that point makes the symptom go away for the reason you predicted.
- You can say why it was not caught before (no test for that input, a recent change, an environment difference).

## 6. When fixes keep failing
Count your fix attempts. This is the one place this rule lives; the agent refers to it.
- One or two failed: go back to step 1 with what you learned. The data was wrong, or the trace stopped too early.
- **Three failed: stop.** If each fix reveals a new problem somewhere else, or each fix needs a bigger change than the last, the problem is the design: shared mutable state, a wrong abstraction, two sources of truth, an ordering assumption baked into the structure. Report what you tried and what each attempt showed, name the design question, and let the user decide before attempting more.

## 7. Defence in depth (after the real fix)
Once the source is fixed, consider whether the bad value could arrive again by another path. If it could cause serious harm (data loss, security, money), add a cheap check at the next layer too: validate at the boundary, assert an invariant, fail loudly with a clear message instead of carrying bad state forward. This is extra protection, never a replacement for fixing the source.

## 8. Variant analysis
A root cause is often a pattern, not a line. Once you know it, search for siblings:
- The same function called the same wrong way (`rg -n "functionName\("`).
- The same idiom copied elsewhere (the same unchecked index, the same missing `await`, the same time zone conversion).
- The same assumption in related modules.
List each one with `path:line`. Fix the ones that are clearly the same bug and in scope; report the rest.

## Red flags in your own thinking
- "Let me just try..." without a written hypothesis.
- "It is probably..." with no check run.
- Changing code before you can explain the symptom.
- A fix at the line where the error shows, with no look upstream.
- "It works now" without knowing why.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.