Home › Agent workflows › Systematic debugging CLAUDE.md

Systematic debugging CLAUDE.md

CLAUDE.md workflow for debugging with Claude Code: reproduce, isolate, hypothesize, verify, and avoid guess-fixes.

Claude Code (CLAUDE.md)Agent workflows

How to use

Save this as CLAUDE.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

CLAUDE.mdDownload  
# CLAUDE.md: Debugging workflow

Use this whenever the task is "fix this bug", "this is broken", or an error message.

## 1. Reproduce
- Get the exact error, stack trace, inputs, and environment. Run the failing command yourself.
- Turn the reproduction into a failing automated test when possible. If you can't reproduce it, say so and ask for more detail instead of guessing.

## 2. Isolate
- Read the stack trace from the top frame in our code. Open the actual files; don't assume what they contain.
- Narrow it down: smaller input, `git log -p` / `git bisect` for regressions, targeted logging around the suspect code.

## 3. Hypothesize
- Write down one or two hypotheses with the evidence for each. Pick the cheapest one to test.
- Test one variable at a time. Remove temporary logs afterward.

## 4. Fix the cause
- Fix the root cause, not the symptom. No blanket `try/catch`, `?.` chains, retries, or longer timeouts unless they *are* the right fix, and explain why.
- Check for the same bug pattern elsewhere (`rg` for similar code).

## 5. Verify
- The reproduction test now passes, the full suite passes, and the original command works.

## Report
Root cause (one paragraph), the fix, how it was verified, and any related risks.

## Don't
- Don't change multiple things at once and hope.
- Don't delete or skip failing tests to "fix" a build.

More: all Agent workflows rules · all Claude Code (CLAUDE.md) rules

Related rules

Code review Copilot instructions

Copilot instructions focused on pull request review: what to flag, severity labels, and how to word comments.

GitHub CopilotAgent workflows

Code review prompt file (Copilot)

A Copilot prompt file (/review-changes) that reviews the current changes and reports issues by severity without editing.

GitHub CopilotAgent workflows

Code reviewer subagent (Claude Code)

A Claude Code subagent definition that reviews the current diff for bugs, security, and tests, reporting by severity.

Claude Code (CLAUDE.md)Agent workflows

/commit slash command (Claude Code)

A Claude Code /commit slash command that reviews staged changes and writes a Conventional Commits message.

Claude Code (CLAUDE.md)Agent workflows

Context management for long agent sessions CLAUDE.md

CLAUDE.md practices for keeping Claude Code effective in long sessions: lean memory, notes files, subagents, and resets.

Claude Code (CLAUDE.md)Agent workflows

Git commits & PRs AGENTS.md

AGENTS.md rules for how agents commit: Conventional Commits, atomic changes, safe git commands, and PR descriptions.

AGENTS.mdAgent workflows

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.