# Debugging with the AI

Fix errors fast. Send an error to the AI, run the Doctor, describe bugs well, and revert when a change went the wrong way.

When something breaks, the AI is usually the fastest way to fix it. This page shows the tools and the prompts that work best.

A build error overlay on the canvas with the Fix with AI button.

## One-click fixes

- **Fix with AI**: build errors show an overlay on the canvas. Choose **Fix with AI** to send the error to the chat.
- **Fix** in the chat: runtime and build errors also appear above the composer. Choose **Fix** to send them.
- **Send all to AI**: the Doctor and the security scan can send all their findings at once.

## Run the Doctor

Type `/fix` and pick **Doctor** to detect and fix errors in your code. The Doctor checks your project for security, bugs, performance, accessibility, maintainability and complexity issues, and scores the result. Choose **Fix with agent** on a finding, or **Send all to AI**. See [Doctor](/features/test-and-debug/doctor).

## Describe a bug well

1. ### Say what you did

   "I filled the booking form and clicked Send."
2. ### Say what happened and what you expected

   "Nothing happened. I expected the success message."
3. ### Add evidence

   Mention **Problems** with `@`, paste the error text from DevTools, or attach a screenshot.
4. ### Ask for the cause first when it is unclear

   In **Ask** mode: "Explain why this happens. Don't change any code yet." Then fix it in **Build** mode.

## Useful debugging prompts

```text
The page is blank after my last change. Find the error in the console and fix it.
```

```text
This worked before the last change. Compare with the previous version,
find what broke, and fix only that.
```

```text
The layout breaks on phones below 400 px wide. Fix it without changing the
desktop layout.
```

## When to revert instead

If a change went the wrong way, going back is often faster than fixing forward:

- Choose **Revert to this version** on the version card before the change.
- Or edit your earlier message and choose **Revert and resend** with a clearer prompt.

See [Version history](/features/projects/version-history).

## When the chat itself has a problem

| Message                                       | What to do                                                                                   |
| --------------------------------------------- | -------------------------------------------------------------------------------------------- |
| **Connection Interrupted**                    | Anything already done is saved. Send your request again.                                     |
| **Session Expired** or **Connection Problem** | Choose **Reconnect** for your provider.                                                      |
| **Conversation Too Long**                     | Choose **Start New Chat**, or use `/compact`.                                                |
| **Usage Limit Reached** or **Credits Used**   | See [Plans and credits](/introduction/plans-and-credits), or switch to a connected provider. |
| **Temporarily Overloaded**                    | Wait a moment. The chat retries on its own.                                                  |

> [!NOTE]
>
> **Preview not updating?**
>
> Reload the frame from its toolbar. If the development server stopped, the chat error offers **Restart Dev Server**.

## Related

- [DevTools](/features/test-and-debug/devtools): Console, network and more.
- [Problems](/features/test-and-debug/problems): Errors and warnings in one list.
- [Troubleshooting](/tips-and-tricks/troubleshooting): Common issues and fixes.
