Debugging in an AI World
We previously set out a plan for how AI-assisted development could work:
- Develop, and refine a spec with a chat-based LLM.
- Review and approve the spec, checking high-risk areas carefully.
- Ask an AI agent to write an implementation plan.
- Review the plan, if necessary refine it, or cut it down.
- Ask the AI agent to implement the spec according to the agreed plan.
- Perform a code review, and iterate as required.
In the previous video we used Cursor to work on steps (3), (4) & (5). However, this plan assumed that the code that AI writes would just need a code review. It misses out a key step—check that the code works and fix it if it doesn’t.
- Develop, and refine a spec with a chat-based LLM.
- Review and approve the spec, checking high-risk areas carefully.
- Ask an AI agent to write an implementation plan.
- Review the plan, if necessary refine it, or cut it down.
- Ask the AI agent to implement the spec according to the agreed plan.
- Debug generated code.
- Perform a code review, and iterate as required.
We could go ahead and debug manually as we’re used to, but surely this is something that our AI agent could assist with?
Debugging with an AI Agent
We left Yesterday’s Weather in a state that built, but it immediately showed an error. We’re going to try an AI-first approach to debugging it:
- Run the app, discover an error
- Tell the agent what the error is.
- The agent attempts to fix it.
- Rinse and repeat.
If we were working on a project on a different platform, such as the web, then cursor could actually automate this loop to an extent. That’s much more difficult iOS projects, so we’re going to run this loop manually.
One really handy feature of Cursor is that we can take screenshots, and give them to the agent. This can save having to describe the errors that we’re seeing.
We’ll give this a go in the next video, and see whether AI uses the same techniques like descriptive error reporting and detailed logging to debug as we do.