How to Use Test-Driven Development with AI Agents (Without Lowering Code Quality)

The video presents the “exact” workflow for test-driven development with AI agents, emphasizing example-guided development to improve code quality by using concrete examples, collaborative modeling, and predictive TDD. It highlights the importance of human oversight, multiple specialized AI agents, and iterative refinement to effectively integrate AI into software development without lowering standards, supported by open-source tools and empirical evidence.

The video explores a reimagined approach to test-driven development (TDD) tailored for working with agentic AI coding tools, emphasizing the concept of “example-guided development.” Daniel Turhus North and Matt Wyn suggest this term better captures the essence of behavior-driven development, acceptance test-driven development, and specification by example, especially since AI agents respond more effectively to concrete examples than abstract descriptions. The discussion centers on the “exact” coding workflow developed by Marco Emmerick and Ferdy Arbor, which integrates example mapping, collaborative modeling, and predictive TDD to harness AI’s strengths while maintaining high code quality.

Marco and Ferdy developed the exact workflow after observing the limitations of “wipe coding,” where AI-generated code often lacked precision and quality. Their approach begins with example mapping, a collaborative technique that helps build a shared understanding of user stories through concrete examples. This step involves both human stakeholders and AI, with the AI assisting in identifying missing test cases. The workflow then moves into an iterative TDD loop, where tests are written and code is developed incrementally, ensuring alignment with the desired behavior and improving code quality.

Empirical data shared in the video demonstrates that providing AI agents with example mappings significantly improves the correctness of generated code compared to giving only prose descriptions. This is particularly relevant in real-world scenarios where requirements are often ambiguous, and developers must clarify expectations through collaboration and examples. Marco and Ferdy also highlight the importance of predictive TDD, where the AI predicts test outcomes before implementation, helping maintain alignment with the problem and improving the reliability of the code produced.

The exact workflow also incorporates the use of multiple AI agents or sub-agents to handle different phases of TDD, such as a dedicated refactoring agent, which has shown to enhance code quality, especially with earlier AI models. Despite advances, human oversight remains crucial; developers can choose the level of autonomy for the AI, but active involvement tends to yield better results. This human-in-the-loop approach ensures that mental models are clear and that the AI’s output aligns with real-world requirements, underscoring the continued importance of human expertise in AI-assisted development.

Finally, the video emphasizes that while the exact workflow requires some familiarity with TDD principles, it is accessible to developers with varying levels of experience. Marco and Ferdy have made their tools and test lab open source, encouraging experimentation and learning. The video concludes with an invitation to an upcoming webinar on TDD with AI agents and highlights the value of empirical, iterative refinement in modern software engineering practices, showcasing how AI can be effectively integrated without compromising code quality.

Useful Links