Replit Agent (flagship Agent 3 in 2026) is an autonomous AI software engineer inside Replit: it reads your code, reproduces failing behavior in a real browser, finds the root cause, patches it, and creates a checkpoint you can roll back to. A good debugging prompt isn't "fix my app" — it's a precise bug report handed to an engineer.
Every prompt below follows the same shape that keeps fixes safe and cheap: the exact error text or the expected-versus-actual behavior, the file or flow involved, an instruction to find the root cause before editing, a scope guardrail so Agent doesn't rewrite half the app, and — for risky work — a note to run it in Plan Mode and approve the plan first. Because billing is effort-based, tight prompts also cost less and avoid runaway debugging loops. Fill in the [bracketed placeholders] and paste.
New to this style of prompting? Start with the full best Replit Agent prompts roundup, or see how to prompt Replit Agent for full-stack apps for the PRD formula behind every build. For quick reference while you work, keep the Replit Agent prompt cheat sheet open.
Paste-the-Error, Root-Cause Fixes
The fastest fixes start with real error text. Paste the exact message or stack trace, tell Agent what you were doing when it happened, and make it explain the root cause before it touches any code.
1. Paste the error and find the root cause
I'm getting this error. Find the root cause before changing anything.
Error (exact text):
[paste the full error message / console output here]
What I was doing when it happened: [e.g. clicking "Save" on the profile page].
Expected: [what should happen]. Actual: [what happens instead].
First, investigate and tell me in 2-3 sentences what the root cause is and which file/line it's in. Then propose the smallest fix. Don't refactor anything unrelated. After you fix it, reproduce my steps in the browser to confirm it's resolved, and create a checkpoint.Why it works: Making Agent name the root cause and location before editing stops it from patching a symptom, and the "smallest fix, nothing unrelated" guardrail keeps the change (and the cost) small.
2. Fix a runtime crash from a stack trace
The app crashes with the stack trace below. Trace it to the originating call, not just the line that threw.
Stack trace:
[paste full stack trace]
Trigger: [what action causes it]. It happens [always / sometimes when ...].
Walk the trace back to where the bad value or null actually comes from, explain it, then fix the origin — add the guard/validation where the data enters, not a try/catch that hides it. Keep the change scoped to the files involved. Test the trigger action afterward and create a checkpoint.Best for: Null/undefined and type crashes — telling Agent to fix the origin instead of wrapping the throw prevents a hidden bug from resurfacing elsewhere.
3. Reproduce and fix an intermittent bug
There's an intermittent bug I can't reliably reproduce: [describe what goes wrong, e.g. "sometimes the cart total is wrong after removing an item"].
It seems to happen when [any pattern you've noticed]. Expected: [X]. Actual: [Y].
First, try to reproduce it in the browser by repeating the flow several times, including edge cases (empty state, fast repeated clicks, back button). Once you can trigger it, tell me the condition that causes it before fixing. Fix the root cause, add a small test that covers that condition, and create a checkpoint. Don't change unrelated behavior.Why it works: Agent 3's self-testing browser loop is ideal for flaky bugs — asking it to reproduce first, then confirm the trigger, turns "sometimes" into a specific condition it can actually fix and test.
Broken Flows & UI Bugs
When a feature misbehaves but throws no error, describe the flow as expected-versus-actual and let Agent test it in the browser. Be exact about the steps and what "correct" looks like.
4. Fix a broken user flow (expected vs actual)
A user flow is broken. Fix it, then test the whole flow yourself.
Flow: [e.g. sign up → verify email → land on dashboard].
Steps to reproduce: 1) [...] 2) [...] 3) [...]
Expected: [what should happen at each step].
Actual: [what actually happens, and where it breaks].
Investigate the flow end to end and tell me where and why it breaks before editing. Fix only what's needed to make the flow work as described. Then run through all the steps in the browser to confirm each one, and create a checkpoint.Best for: Multi-step features (auth, checkout, onboarding) where nothing errors but the user still gets stuck — the step-by-step expected/actual gives Agent an exact target.
5. Fix a form that won't submit
The [name] form doesn't submit. When I fill it in and click [Submit], [nothing happens / it shows no confirmation / the data isn't saved].
Expected: on submit, validate the fields, save to the database, show a success message, and clear the form. Actual: [describe].
Check the whole chain: client-side validation, the submit handler, the API/route, and the database write. Tell me which link is failing before you fix it. Make validation errors visible to the user instead of failing silently. Test a real submission end to end and create a checkpoint.Why it works: Naming every link in the chain (validation → handler → route → DB) forces Agent to isolate the real break instead of guessing, and the "make errors visible" rule fixes the usual silent-failure cause.
6. Fix a responsive / layout bug
The layout breaks on [mobile / a narrow screen / tablet]. Problem: [e.g. "the nav overlaps the hero and a button is cut off"] on screens around [375px] wide. It looks fine on desktop.
Expected: [describe the correct responsive behavior]. Actual: [describe the breakage].
Reproduce it at that viewport in the browser, find the CSS/layout rule causing it, and fix it without changing the desktop layout. Check the fix at 375px, 768px, and 1280px. Keep changes scoped to the affected components. Create a checkpoint.Best for: CSS/responsive issues — giving exact breakpoints and "don't change desktop" lets Agent verify the fix visually without regressing the layout you already like.
Deploy & Environment Fixes
Deployment and environment bugs are their own category: the code may run fine in the workspace but fail on deploy, on a missing key, or on a version mismatch. Give Agent the deploy log and the deployment type.
7. App won't deploy — diagnose the failed deployment
My deployment is failing. Here is the deploy/build log:
[paste the full deployment log or the error from the Deployments pane]
Deployment type: [Autoscale / Reserved VM / Static / Scheduled].
Diagnose why the deploy fails — build error, missing dependency, wrong start/build command, missing environment variable, or port/config issue. Tell me the specific cause before changing anything. Fix the configuration and code as needed so it deploys successfully, then confirm the build passes. Don't change app features — only what's required to deploy. Create a checkpoint.Why it works: The deploy log plus the deployment type gives Agent the exact context it needs, and scoping it to "only what's required to deploy" keeps a config fix from turning into a rewrite.
8. Works in dev, breaks in production
The app works in the workspace but is broken on the deployed URL: [describe what's different, e.g. "images 404" / "API calls fail" / "blank page"].
Deployed URL behavior: [what you see]. Expected: same as the workspace.
Investigate the usual dev-vs-prod causes: hardcoded localhost URLs, missing production Secrets, relative vs absolute paths, build output not served, or CORS. Tell me the specific difference before fixing. Fix it so production matches the workspace, and don't touch working features. After fixing, verify against the deployed URL and create a checkpoint.Best for: The classic "but it works on my machine" gap — listing the common dev/prod causes points Agent straight at the environment difference.
9. Fix a dependency or version conflict
I have a dependency problem: [paste the error, e.g. a version-conflict / "module not found" / peer-dependency warning].
Figure out which packages conflict and why. Explain the conflict and your proposed resolution before changing anything — I want to know if you're upgrading, downgrading, or pinning a version and what could break. Prefer the smallest, most stable set of version changes. After updating, reinstall, run the app, and confirm nothing regressed. Create a checkpoint so I can roll back if a version bump causes issues.Why it works: Dependency changes are high-risk, so making Agent explain the resolution first (and checkpoint before it) means you can approve the strategy and roll back if a version bump breaks something else.
10. Fix an environment variable / Secrets issue
Something that depends on an API key or config isn't working: [describe, e.g. "the OpenAI call returns 401" / "Stripe key is undefined"].
The keys should be read from Replit Secrets, not hardcoded. Check that the code reads the right Secret names, that they're referenced correctly, and that nothing is committed in plain text. Tell me exactly which Secret names the app expects so I can confirm they're set. Add a clear startup check that fails with a readable message if a required Secret is missing. Don't print secret values in logs. Create a checkpoint.Best for: Integration and API-key failures — surfacing the exact Secret names the app expects makes it obvious whether the bug is missing config or wrong code.
Performance Fixes
For slowness, give Agent a concrete target and a way to measure. Point it at the slow page, endpoint, or query, and ask it to find the bottleneck before optimizing.
11. Fix a slow page or slow query
The [page/endpoint, e.g. "dashboard"] is slow — it takes about [X] seconds to load. It should feel fast (under [1] second).
Profile what's slow before changing anything: is it a slow database query, too many queries, a large payload, or blocking work on the main thread? Tell me the specific bottleneck and the numbers you measured. Then fix the biggest one first — add an index, batch/cache the query, paginate, or defer work — without changing what the page shows. Re-measure and report the before/after. Keep the change scoped and create a checkpoint.Why it works: Demanding a measured bottleneck and a before/after stops guess-optimizing, and "fix the biggest one first" gets you the real win in one scoped, cheap pass.
12. Find and fix an N+1 query
I think the [list/page, e.g. "orders list"] is running an N+1 query — it makes one query per row instead of one query for all rows, and it gets slower as data grows.
Confirm whether that's happening by inspecting the data-access code and the query count for that view. Tell me what you found before editing. If it's N+1, fix it by eager-loading / joining / batching so it's a small constant number of queries. Don't change the data shown or the API contract. Verify the query count drops and the page renders identically, then create a checkpoint.Best for: Lists and dashboards that degrade with scale — "don't change the API contract" ensures the optimization is invisible to the rest of the app.
13. Reduce bundle size and speed up load
Initial page load feels heavy. Reduce the front-end bundle size and improve first load without changing how the app looks or behaves.
First, report the current bundle size and the largest contributors. Then apply safe wins: code-split routes, lazy-load heavy components, drop or replace oversized dependencies, and ensure images are appropriately sized. Explain each change and its impact. Don't remove any feature. Re-measure and give me the before/after bundle size, then create a checkpoint.Why it works: Anchoring the work to a measured bundle size and "don't remove any feature" keeps the optimization honest and reversible instead of a risky rewrite.
Refactoring & Tests
Refactors change structure, not behavior — so run risky ones in Plan Mode, keep the external behavior identical, and add tests so nothing silently regresses.
14. Refactor a single file for readability
Refactor [file path] to be cleaner and easier to maintain, without changing its behavior.
Goals: extract repeated logic into well-named functions, improve names, remove dead code, and add short comments only where the intent isn't obvious. Do NOT change the file's public interface (exports, function signatures, props) or its behavior — this is a pure refactor. Tell me the changes you plan to make first. After refactoring, run the app and confirm the affected feature works exactly as before. Create a checkpoint.Best for: One messy file you keep dreading — "pure refactor, no interface change" makes the diff safe to accept because behavior is guaranteed to stay put.
15. Split a giant file into modules
Run this in Plan Mode. [file path] has grown too large ([~N] lines) and mixes several concerns. Split it into focused modules without changing behavior.
Propose a plan first: how you'll group the code (e.g. by feature/responsibility), the new file names, and how imports will be updated across the codebase. List "out of scope" so you don't rewrite logic. Wait for my approval before editing. After I approve, make the change, update all imports, run the app to confirm nothing broke, and create a checkpoint.Why it works: Plan Mode forces Agent to lay out the module structure and import changes for your approval before it touches a wide, high-blast-radius refactor.
16. Refactor a React component (Plan Mode)
Run this in Plan Mode. Refactor the [ComponentName] component: it's too big and hard to follow. Break it into smaller components and/or hooks, lift shared logic out, and clean up state — without changing what the user sees or how it behaves.
Propose the new component/hook breakdown and the prop interfaces before editing, and list what's out of scope. Keep the rendered output and interactions identical. After I approve, implement it, test the component's interactions in the browser, and create a checkpoint. Don't touch unrelated components.Best for: Bloated components — planning the breakdown up front prevents Agent from over-engineering the split or accidentally changing the UI.
17. Remove duplication (DRY) safely
There's duplicated logic across [describe, e.g. "the create and edit forms" or "several API handlers"]. Consolidate it into one shared, well-named function/module without changing behavior.
First, show me the duplicated blocks you found and the single abstraction you propose — I want to make sure the cases are actually the same before you merge them. Only unify code that's genuinely identical in intent; don't force-fit different cases into one function. After refactoring, run the affected features and confirm each still behaves the same. Create a checkpoint.Why it works: Asking Agent to show the duplicated blocks and its abstraction first guards against the common trap of merging code that only looks similar but should stay separate.
18. Add tests for existing code
Add tests for [file/module/feature]. Focus on the important behavior and edge cases, not trivial getters.
Cover: the happy path, the main error cases, and boundary conditions [list any you care about, e.g. empty input, max length, invalid values]. Use the project's existing test setup if there is one, otherwise set up a lightweight, standard test runner. Don't change the code under test — if you find a bug while writing tests, tell me instead of silently fixing it. Run the tests, make sure they pass, and create a checkpoint.Best for: Locking in behavior before a bigger change — "don't change the code, tell me if you find a bug" keeps test-writing from turning into a stealth refactor.
19. Add a regression test for a fixed bug
We just fixed this bug: [describe the bug and the fix]. Add a focused regression test that fails on the old buggy behavior and passes with the fix, so it can't come back.
Write the test to assert the correct expected behavior for the exact condition that used to break: [describe the trigger/input]. Keep it small and clearly named after the bug. Run it to confirm it passes now. Don't add unrelated tests or change other code. Create a checkpoint.Why it works: A targeted regression test is the cheapest insurance against a recurring bug — this pins the exact condition that broke so a future change can't quietly reintroduce it.
Hardening & Recovery
Round out a stable app with better error handling, logging you can debug from, a security pass, and — when a run goes sideways — a clean rollback and a scoped restart.
20. Improve error handling and user messages
Improve error handling across [the app / a specific feature]. Right now failures [crash the page / show a blank screen / expose a raw error].
For each place that can fail (API calls, form submits, data loading), catch errors gracefully, show the user a clear, friendly message, and keep the rest of the app usable. Add loading and empty states where they're missing. Log the technical detail for me but never show stack traces or secrets to the user. Tell me the list of places you're changing first. Test a few failure cases in the browser and create a checkpoint.Best for: Making a working prototype feel production-ready — the split between a friendly user message and a logged technical detail is exactly what most first-pass builds miss.
21. Add logging to diagnose a hard bug
I have a bug I can't pin down: [describe the symptom]. Before trying to fix it, add targeted logging so we can see what's actually happening.
Add clear, labeled log statements at the key points in the suspect flow [name the flow/files]: inputs, branch decisions, external call results, and the final output — enough to trace the path. Don't log secrets or full personal data. Tell me exactly what to do to trigger the flow, then read the logs and tell me what they reveal about the root cause. Once we understand it, we'll fix it. Create a checkpoint after adding the logging.Why it works: For a bug that resists guessing, instrumenting the flow first turns a blind fix-attempt loop into an evidence-based diagnosis — you see the real path before anyone edits logic.
22. Fix a database or migration issue
Run this in Plan Mode. I have a database problem: [describe, e.g. "a migration failed" / "a column is missing" / "queries error after a schema change" / "I need to add a field to an existing table"].
Error (if any): [paste it]. Current behavior: [X]. Expected: [Y].
Because this touches data, propose a plan before making changes: what schema change or migration you'll run, whether existing data is affected, and how to avoid data loss. Wait for my approval. Prefer a safe, reversible migration. After I approve, apply it, verify the schema and a sample query, and create a checkpoint. Never drop or overwrite data without explicitly confirming with me.Best for: Anything that can lose data — Plan Mode plus "never drop data without confirming" is the guardrail that keeps a schema fix from becoming a disaster.
23. Security review of the app
Do a security review of the app before I share it more widely. Report findings first; don't make sweeping changes without my say-so.
Check for the common issues: secrets or API keys hardcoded in the code, missing authentication/authorization on routes that need it, unvalidated user input (injection, XSS), sensitive data exposed in responses or logs, and insecure direct object references (users accessing others' data). Give me a prioritized list — High/Medium/Low — with the file/line and a one-line fix each. Then fix the High items with my approval, keeping each change scoped, and create a checkpoint after each fix.Why it works: A prioritized findings list with file/line lets you triage before Agent changes anything — you fix the High-risk holes deliberately instead of accepting a big unreviewed security diff.
24. Escape a debugging loop (roll back + scope down)
We've gone in circles on this bug and things are worse than when we started. Let's reset.
Stop trying new fixes. First, do NOT edit any code yet. Look at the History and tell me which recent checkpoint was the last known-good state for [feature]. I'll roll back to it. Then, in Plan Mode, focus on ONLY this single symptom: [one precise symptom + exact error]. Investigate and explain the root cause before proposing anything. Propose the smallest possible fix and wait for my approval. Nothing else is in scope. After the fix, add a test for it so it can't regress.Best for: Runaway sessions where each fix stacks a new problem — rolling back to a known-good checkpoint, scoping to one symptom, and switching to Plan Mode is the reliable way out (and it stops the effort-based cost from spiraling).
Frequently Asked Questions
What is Replit Agent?
Replit Agent (flagship Agent 3 in 2026) is an autonomous AI software engineer inside Replit. You describe an app or a change in plain language and it plans, writes code across many files, provisions a database, wires up auth, tests itself in a real browser, and deploys to a live URL — no local setup. For debugging it can read your error output, reproduce the failing flow, find the root cause, and patch it, then create a checkpoint you can roll back to.
How is a debugging prompt for Replit Agent different from a ChatGPT prompt?
A ChatGPT prompt asks for advice; a Replit Agent debugging prompt hands the whole job to an engineer working in your actual codebase. So you give it the exact error text, the file or flow, the expected-versus-actual behavior, and instructions to find the root cause before editing and keep the change scoped. Agent then reproduces it, fixes it, and tests the flow itself — you're not copying code back and forth.
What is Plan Mode and when should I use it for a fix?
Plan Mode makes Agent think first: it investigates, proposes an approach, asks clarifying questions, and waits for your approval before touching any files. Use it for anything risky — refactors, database migrations, security changes, or bugs that span many files. Build Mode is the opposite: Agent edits code directly and creates checkpoints as it goes. A good rule is Plan Mode for risky or wide changes, Build Mode for small scoped fixes.
What are checkpoints and can I roll back a bad fix?
Replit Agent creates a checkpoint after each significant change. If a fix makes things worse, open History, find the last known-good checkpoint, and choose Rollback here to restore that state — then re-prompt with a tighter scope. Rolling back is the single most important habit for escaping a debugging loop, because it stops you from stacking bad edits on top of each other.
How much does debugging with Replit Agent cost?
Billing is effort-based: a small scoped change is cheap (often under about $0.25) and a large refactor across many files costs more. Tight, well-scoped prompts are both cheaper and less likely to spiral into a runaway debugging loop. If a run starts thrashing, stop it, roll back to a checkpoint, and re-scope rather than letting it keep trying.
How do I stop Replit Agent from getting stuck in a debugging loop?
When Agent keeps trying the same fix without progress, stop the run, roll back to the last good checkpoint, and re-prompt with a smaller scope: one symptom, the exact error, and an instruction to investigate and explain the root cause before editing. Switching to Plan Mode helps too, because Agent proposes an approach for you to approve instead of blindly editing. Asking it to add a test for the bug prevents the same regression from returning.
Should I use Agent or Assistant to fix a bug?
Use Replit Assistant for a small, targeted edit or a quick question about one file. Use Replit Agent when the fix spans several files, needs reproduction and testing, involves the database or deployment, or is a refactor. Agent can open a browser and test the flow itself, which is what you want for anything beyond a one-line change.
Do I need to know how to code to debug with Replit Agent?
No. You can paste the error message and describe the expected-versus-actual behavior in plain language, and Agent will investigate and fix it. Knowing a little helps you write tighter prompts and sanity-check the change, but the core skill is describing the bug precisely: what you did, what you expected, what happened instead, and any error text on screen or in the logs.