Rescue prompt: diagnose and fix a project an AI agent broke

Free template

A step-by-step prompt that makes an AI agent save your current state, map what changed, find the root cause and fix it with the smallest change, instead of rewriting everything.

Updated Oct 26, 2026 · Free to copy, change and use in your own projects. No sign-up needed. · Jump to the template

When to use this template

Your vibe-coded app worked yesterday. After many AI edits it is now broken, each new fix breaks something else, and the agent keeps going in circles.

Tools it works with

Works in any AI coding agent or chat assistant. Agents that can run commands in your project can follow the git steps themselves; in a chat-only tool, run the commands yourself and paste the output.

How to use it

  1. Open a new chat or agent session. A fresh context usually works better than continuing a long, confused one.
  2. Fill in the Context section. Paste the full error output exactly as it appears; do not summarize it.
  3. Send the whole prompt as one message. The agent should stop after Step 2 and wait for you.
  4. Run the commands it gives you and paste the results back, then continue step by step.
  5. When it is fixed, add the suggested lines to your AGENTS.md or rules file so the same mistake is less likely next time.

The template

rescue-prompt.md 58 linesDownload file
# Rescue prompt: diagnose and fix a project an AI agent broke

Paste this into a NEW chat or agent session (a fresh context works better than a long, confused one).
Fill in the brackets first. Send it as one message.

---

My project was working, and after a series of AI-made changes it is now broken. I need you to act as a careful senior engineer doing a rescue. Do not start rewriting code. Follow the steps below in order, and stop where I ask you to stop.

## Context
- What the project is: [ONE SENTENCE]
- Stack and how to run it: [e.g. "Vite + React, run with `npm run dev`"]
- What used to work: [e.g. "Login and the dashboard page loaded fine yesterday"]
- What is broken now: [exact symptom: error message, blank page, wrong behavior]
- Exact error output (copy and paste it, do not paraphrase):
```
[PASTE THE FULL ERROR, STACK TRACE OR TERMINAL OUTPUT HERE]
```
- Last known good state: [a git commit hash, a branch, a date, or "unknown"]
- What I or the AI changed since then (as far as I know): [list]

## Rules for this session
- Read before you write. Look at the files involved and at the recent changes before proposing anything.
- Do not add new dependencies, do not upgrade or downgrade packages, and do not rewrite whole files unless I approve it.
- One hypothesis and one change at a time. After each change, tell me exactly how to check it.
- If you are not sure about something (an API, a config option, a version), say that you are not sure instead of guessing.
- Keep a short running log of what you tried and what happened, so we never retry the same thing.

## Step 1: Secure the current state (do this first)
Tell me the commands to save the current state before anything else, for example:
- `git status` and `git diff --stat` to see what changed
- `git stash` or a commit on a new branch such as `rescue/[date]`, so nothing is lost
If the project is not in git, tell me to copy the folder and run `git init`, then commit everything as "broken state before rescue".

## Step 2: Map the damage (no code changes yet)
1. Summarize what the project does and how it is structured, based on the files.
2. List the changes since the last known good state (`git log --oneline -15`, `git diff [GOOD_COMMIT]..HEAD --stat`). Point out anything suspicious: deleted files, changed config, new or upgraded dependencies, duplicated code, files that look half-edited.
3. Reproduce the problem: give me the exact command or click path that shows the error, and what output you expect.

Stop here and wait for my reply with the results.

## Step 3: Diagnose
1. Give me up to three likely root causes, ranked by probability, each with the evidence for it.
2. For the top cause, propose the smallest experiment that would confirm or rule it out (for example: a log line, a single revert, checking an installed package version with `npm ls [package]`).
3. If the fastest safe fix is to revert specific commits or files to the last good state, say so, and show the exact `git` commands (for example `git checkout [GOOD_COMMIT] -- path/to/file`). Explain what would be lost.

## Step 4: Fix
1. Apply the smallest fix for the confirmed cause. Show the diff.
2. Tell me how to verify it (command to run, what I should see).
3. If the fix works, look for other places where the same mistake was made, and list them before changing them.

## Step 5: Prevent a repeat
1. Suggest one test or check that would have caught this problem, and write it if it is small.
2. Suggest two or three lines to add to my AGENTS.md, CLAUDE.md or rules file so future AI changes avoid this mistake.
3. Give me a short summary: root cause, fix, files changed, and anything still uncertain.

Start with Step 1 and Step 2 now.

Tips

We wrote this template from public documentation and common practice; we have not measured its results. Tools change often, so check each tool's own documentation if something does not work as described. Found a mistake? Email [email protected].

More free templates

All templates →

Get new templates in the newsletter

Get new templates in the newsletter: we email you when we add new free templates, together with the daily AI picks. Free, no spam, unsubscribe any time.

We'll send a confirmation email first (double opt-in). Sign-ups are handled by Kit.