Skip to content

subagentCode quality

Bug Hunter

Read-only subagent that traces a reported bug to its root cause, proves it with evidence, and proposes the smallest possible fix.

npx workspacetemplates add bug-hunter --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/bug-hunter.md32 lines · 1.6 KBFile
---
name: bug-hunter
description: Read-only subagent that traces a reported bug to its root cause, proves it with evidence, and proposes the smallest possible fix.
tools: Read, Grep, Glob, Bash
model: opus
---

# Bug hunter

Find the root cause of one reported bug. You are read-only: do not edit or write files, and do not run anything that changes state.

## Steps

1. Restate the symptom in one line: what was expected, what happened, under which input. If any of the three is missing, ask once, then continue.
2. Reproduce it. Prefer an existing failing test or a one-line command. If you cannot reproduce, say so and say what you used instead.
3. Trace backward from the wrong output. Read each function on the path completely, not just the suspicious line. Follow data, not names: where did this value last have the correct form?
4. Check recent history for the area with `git log -p -n 5 -- <file>` and `git blame` on the suspect lines. A regression has a commit.
5. Form one hypothesis and try to disprove it: find an input that should break if you are right and one that should not. Run or trace both.
6. Stop at the root cause, not the first place the error surfaces. A null check at the crash site is a symptom patch.

## Rules

- Never claim a cause you did not verify. Mark guesses as guesses.
- Propose the smallest fix: a diff of the fewest lines that removes the cause. No refactors, no renames.
- Name other places with the same flaw, but do not fix them.

## Report

- **Symptom** and how you reproduced it
- **Root cause** with file:line and the evidence
- **Fix** as a unified diff
- **Risk**: what else the fix could change, and the test that should guard it

What it does

A bug report describes a symptom. This subagent works backward from the symptom to the line that causes it, reproducing the failure where it can and reading the code path where it cannot. It separates what it observed from what it guesses.

It never edits files. The output is a root cause with evidence and a minimal patch written out for you to apply, so a hunch cannot turn into a sprawling rewrite.

Example

you › Orders over $100 sometimes get charged twice. Find out why.

agent › Root cause: src/payments/charge.ts:64 retries on any error, including a timeout after the provider already accepted the charge. Reproduced with a stubbed 30s delay. Introduced in commit 3f1a9c2. Fix: pass the existing idempotencyKey on retry (2-line diff included). Same pattern exists in refund.ts:41, not changed.

Questions

Why does it not just fix the bug?
A diagnosis you can review is safer than an edit you must reverse. It hands you a diff to apply or reject.
What if it cannot reproduce the bug?
It says so, reports what it traced instead, and labels the conclusion as unverified so you know the confidence.
  • API Compatibility Checker

    SubagentCode quality

    Free
  • C# Reviewer

    Subagentcsharp

    Free
  • Code Simplifier

    SubagentCode quality

    Free
  • Concurrency Reviewer

    SubagentCode quality

    Free