# Unstick an agent that's going in circles

Recipe · Shipping and running a product · AD12

Stops a spiralling bug-fix session, clears out half-broken patches, proves the real cause, fixes only that, and walks you through the final diff.

**Use it when:** An agent has tried three fixes in a row, things feel messier than when you started, and you want to regain control.

## Steps

Run one step per message.

1. [Stop and untangle](https://www.atlasscope.dev/prompts/stop-and-untangle): freeze edits and see what changed since the last working state
2. [Root cause first](https://www.atlasscope.dev/prompts/root-cause-first): in a clean state (or fresh chat), find the real cause with evidence
3. [Stay inside the lines](https://www.atlasscope.dev/prompts/stay-inside-the-lines): apply the narrow fix without touching neighbouring files
4. [Walk me through what changed before I merge](https://www.atlasscope.dev/prompts/walk-me-through-what-changed-before-i-merge): get a plain-English diff review and click-test list

### Step 1: Stop and untangle

```text
Stop editing files. Step back and untangle where we are right now. Check git status and git diff against the last known working commit, then tell me in plain English: (1) what the original goal was, (2) every fix we already tried and what happened, (3) which uncommitted changes are half-finished patches that should be reverted, and (4) the single cleanest path forward from a clean base. Wait for my approval before reverting or editing anything.
```

### Step 2: Root cause first

```text
Do not patch the visible symptom yet. Reproduce the problem first, then trace backward through code and data until you can explain in one or two plain sentences why it happens, citing the exact files, lines, or records involved. Search the codebase for every other place that shares the same cause. Report the cause, the proof, and every affected location. Then propose one fix that removes the underlying cause everywhere it applies, plus a check that fails if it returns. Wait for my yes before editing.
```

### Step 3: Stay inside the lines

```text
Stay strictly inside the task I asked for. Do not refactor neighbouring code, rename unrelated variables, reformat untouched files, delete comments, or upgrade dependencies unless the task cannot work without it. If you spot a separate bug or cleanup opportunity while working, leave it untouched and list it at the end under "Spotted outside scope" with the file and line so I can decide whether to do it next. Before finishing, check the diff and revert any accidental edit outside scope.
```

### Step 4: Walk me through what changed before I merge

```text
Inspect the current branch diff against the default branch (or the pull request I name) and explain it for a product owner who does not read code. Group the changes by what a user or operator will experience, call out any file touched outside the stated goal, flag risky areas (data writes, permissions, billing, migrations, config changes, deleted checks), and write a five-minute manual click-test checklist I can run myself to verify the change works and did not break nearby flows.

Treat this as a read-only investigation. Do not edit code, data, configuration, credentials or infrastructure. Report each finding with file:line or a command I can rerun, and a confidence.
Give me: A plain-English summary of user-visible and behind-the-scenes changes, a list of any out-of-scope edits with file paths, the top risks with file:line, and a numbered checklist of exact screens and actions for me to test.
Watch for: Agents summarize commit messages instead of reading the actual diff. Read the real diff line by line and flag anything the commits forgot to mention.
If this describes the project, say so and stop instead: A single-line wording fix or a branch with no changes against the default branch.
Start your report in plain English: what you found, what it means, and whether I need to do anything. Put files, lines and commands underneath.
```

Source: https://www.atlasscope.dev/prompts/unstick-an-agent-thats-going-in-circles
