# Debugging with your agent: reproduce, find, fix, prove

> Debugging is the step-by-step method your coding agent uses when something breaks: first reproduce the bug reliably, next locate its root cause in the logs and code, then fix it with one change at a time, and finally add a test so it cannot return.

## Analogy

When a lamp stops working, you don't rewire the whole house at random. You flip the switch to see it fail, check the bulb and the outlet one by one, replace the burnt bulb, and flip the switch again to prove it lights up.

## How it works

A bug is simply a mistake in the code that makes your app behave differently from what you expected. debugging is how you and your coding-agent solve it—not by guessing or changing five files at once, but by following four calm steps: **reproduce, find, fix, prove**.

First, **reproduce** and **find**: you tell the agent the exact steps that trigger the problem, and the agent reads the error-message and log lines to localize the exact file and line where things go wrong. It reduces the problem to its real root cause before touching any code.

Next, **fix** and **prove**: the agent makes **one change at a time** to fix the root cause (never a blind guess), adds an automated test that would have caught the bug, and verifies the whole flow from start to finish so the bug cannot silently return later.

What if the first fix doesn't work? The Agentic Makers Guide sets a strict rule: **after two failed attempts**, the agent must stop, return your project to the last working commit (`git revert` or a clean branch, never deleting history), and explain your options plainly so you never end up in a tangled mess.

## In your project

When something breaks, your agent activates its `debugging-and-error-recovery` skill. It tells you in two plain sentences what caused the bug and how the fix works, adds a test, and asks you to verify that the problem is gone.

## Copy for your agent

```text
Something broke: when I [steps you took], I expected [expected result] but got [actual result]. Follow the debugging loop: reproduce it, find the root cause in the logs, explain it in two plain sentences, fix one thing at a time, and add a test.
```

---
Source: [Agentic Makers](https://agenticmakers.app/en/learn/debugging-with-your-agent) · License: CC BY 4.0
