# 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.