Debugging
Tips on debugging errors with AI
Debugging with AI to fix errors is one of the most important skills in using Dyad — or any other AI coding tool — effectively.
If you haven't yet, I recommend reading the Chatting guide for tips on chatting with AI effectively.
Prompting Tips
Describe the issue clearly
Imagine you're talking to a human co-worker. If you said there's a bug, you'd try to provide as many details as possible so they know what you're referring to. The same principle applies when you're working with AI.
Bad prompt: (unclear what to fix)
fix broken app
Good prompt: (clear about what the issue is)
After I click the sign-up button, the page is blank.
The problem with the bad prompt is that it's so vague that:
- Dyad needs to guess which button you want fixed
- Dyad needs to guess what the issue is
Sometimes, even with an under-specified prompt, it will work — but often, it doesn’t.
Include detailed error messages
Similar to the tip above, include error messages with as much detail as possible.
If you see an error in the UI, copy and paste the error message and ask the AI to fix it. For many errors, you'll see a Fix with AI button, but in some cases, you'll need to manually copy and paste them.
What to do when there are no error messages
What if the app is broken but you don't see any error messages? You can still ask the AI:
I don't see anything after I log in.
Sometimes this alone will fix the issue.
You can also ask the AI to add error handling and display error messages in the UI.
Example
Let’s say you’re getting a vague error after clicking the Sign-in button. You can ask Dyad:
Add error handling when signing in and show detailed error messages in a toast.
Then, you can use the specific error message and have Dyad fix it.
Workflow Tips
Test often & use undo
One challenge with AI is that it can make unexpected changes, so I recommend regularly testing your app's main flows in the preview panel to make sure nothing is broken (e.g., every few prompts). If something is off, use the undo feature, explained in the versioning guide.
Try another model
Often, trying the same prompt with a different model — especially a more powerful one like Gemini Pro 2.5 or Claude Sonnet 3.7 — can get you much better results.
First, undo, then click the Retry button.
Manage your context
With Dyad, you can create multiple chats for the same app. If you run into an error saying you've hit your context window limit, start a new chat.
When you're getting close to the limit, Dyad will suggest Summarize into new chat above the chat input. Click that to start a new chat based on a summary of the current one — it’s a great way to clean up your context without starting from scratch.
Debugging Case Study
To see a real-world example of debugging an app in Dyad, watch this video where I integrate Supabase into an app and fix several errors along the way: