Skip to content

Error-Driven Development: Learning from Failures

In traditional development, errors are often seen as a nuisance. In AI-assisted development, they are a powerful signal. Error-Driven Development (EDD) is a workflow that embraces failures—from compiler messages to runtime exceptions—as the primary mechanism for guiding your AI partner to the correct solution.

Instead of aiming for a perfect first draft, you use a rapid, iterative cycle of “error → fix → re-run.” This approach provides the AI with the clearest, most direct feedback possible, allowing it to systematically solve even the most complex problems.

The EDD cycle is simple, fast, and incredibly effective. It leverages the AI’s ability to quickly parse complex error messages and propose targeted solutions.

1. Start with an Error

Your entry point is a failure. This could be a bug report from production, a stack trace from your error monitoring service (like Sentry), a failing test from your CI pipeline, or a simple compiler error in your local environment.

2. Feed the Error to the AI

You provide the complete error message, including the stack trace and any relevant context, directly to the AI assistant. This is the most important piece of information you can give it.

3. AI Diagnoses and Fixes

The AI analyzes the error, cross-references it with the codebase, diagnoses the root cause, and proposes a specific code change to fix it.

4. Apply and Re-run

You apply the fix and re-run the exact process that caused the error. If the error is gone, you’re done! If a new error appears, you simply feed the new error back to the AI and repeat the cycle.


  1. Get the Stack Trace. A user reports a bug, and your error tracking service (e.g., Sentry) has captured the exception. Copy the entire stack trace.

  2. Prompt the AI. Provide the stack trace and the relevant code files to the AI.

    We have a bug in production. Here is the stack trace from Sentry:
    [...paste full stack trace...]
    The relevant files seem to be @/src/services/payment.ts and @/src/controllers/checkout.ts.
    Please analyze the error and fix the bug.
  3. Receive and Apply the Fix. The AI will identify the line of code causing the NullPointerException and suggest a fix, such as adding a null check or ensuring an object is initialized correctly. You apply the change, and the bug is resolved.

  1. Make a Change. You’re refactoring a large, legacy module. You make a change that you know will break things, for example, changing the signature of a core function.

  2. Run the Compiler/Tests. You run the compiler or the test suite and are greeted with a long list of errors.

  3. Delegate to the AI. Instead of manually fixing each error, you feed the entire error log to the AI.

    I've changed the signature of the `calculate` function. Here are the resulting compiler errors. Please fix all of them.
    [...paste full compiler output...]
  4. Iterate Until Clean. The AI will work through the errors one by one, fixing import statements, updating function calls, and correcting type mismatches. It may take a few cycles, but it will systematically resolve all the breakages, completing in minutes a task that could have taken a human hours of tedious work.

By adopting an Error-Driven Development mindset, you learn to love errors. They are no longer obstacles but signposts, pointing you and your AI assistant on the most direct path to a working solution.