- Claude Code
- Agent
- Intermediate
- Claude Code
- Published
Claude Code Root-Cause Bug Investigation with Failing Test and Minimal Patch
Directs Claude Code to reproduce a bug, trace it to a root cause using repository evidence, write a failing regression test, and apply the smallest safe fix. Ends with a verified diff, risks, and next actions.
You get: Working code with an explanation
The prompt
mkdir -p .agents/skills/claude-code-root-cause-bug-investigation-with-failing-test-and-m && curl -sL "https://prompts-gpt.com/prompts/claude-code-root-cause-bug-investigation-with-failing-test-and-minimal-patch/raw" -o .agents/skills/claude-code-root-cause-bug-investigation-with-failing-test-and-m/SKILL.mdExample output
Tips and common edits
Run from the repository root in Claude Code. Provide a concrete repro command when possible; the prompt performs best with a deterministic failure. For large repos, ask Claude Code to use subagents for parallel searches. Review the Verification table to confirm which commands were actually executed.
Questions about this prompt
More like this
More in Claude CodeFailing Test First Bug Fix
Reproduces a bug with a failing test, finds the root cause, applies the smallest fix and shows the test passing.
Cursor Agent Bug Triage: Reproduce, Root-Cause, Fix, and Regression Test
Guides Cursor Agent through reproducing a bug, isolating the root cause with evidence, applying a minimal diff, and adding a regression test, ending with a verification checklist and risks.
Claude Code Behavior-Preserving Refactor with Characterization Tests and Staged Commits
Guides Claude Code to refactor a module safely by first pinning current behavior with characterization tests, then applying small reversible steps with verification after each. Delivers a diff, risk register, and rollback plan.
Claude Code Feature Implementation Plan and Build from a Ticket with Repo Convention Discovery
Has Claude Code investigate how similar features are built in the repository, produce an implementation plan with acceptance tests, then implement it in verified increments. Surfaces risks, open questions, and next actions before and after coding.
Debug an Error From the Message and the Code Around It
Finds the most likely cause of an error from the message and the relevant code, ranks other possible causes, and gives the smallest fix plus a way to prove it worked.
Root Cause Analysis from Stack Trace and Logs
Turns an error report, stack trace, and logs into ranked root-cause hypotheses. Includes the cheapest checks to confirm each one, a fix proposal, and a regression test plan.
Agent Run Post-Mortem: Trace Root Cause and Prompt or Tool Fixes
Analyzes a pasted agent trace to find the first real failure and proposes exact prompt rewrites or tool changes, each with a test.
Characterization Tests Before a Refactor
Writes tests that lock in a module's current behavior, including edge cases and quirks, so you can refactor safely.
Checkpoint and Rollback Manager with Compensation Steps and Failure Injection Tests
Guides Claude Code to implement checkpoint snapshots, rollback modes, and compensating actions for side-effecting agent phases, then prove them with failure-injection tests. Helps you decide the rollback strategy per phase.
Claude Code Hook Writer: Auto-Run Lint, Typecheck or Tests After Edits
Produces a PostToolUse hook entry for settings.json, the script it calls and a concrete procedure to test that the check runs after file edits.
Claude Code Plan-Then-Implement a Feature With Approval Checkpoints
Makes Claude Code explore the repo, write a step-by-step plan for your approval, then build the feature in small verified steps, stopping at each checkpoint for your go-ahead.
Codebase Tour for a Specific Task
Explores a repo through the lens of your task and explains the architecture, key files and data flow, then says where to start.