Test-driven prompting is a development approach where you write or generate tests before asking AI to implement functionality. By defining expected behavior through tests first, you create clear specifications that guide AI toward correct implementations and make verification automatic.
Test-driven prompting adapts Test-Driven Development (TDD) for AI-assisted workflows. Tests become specifications that guide AI generation and automatically verify correctness.
Tests are precise specifications:
Compare:
Generate tests first: "Write tests for a password validation function that:
Then request implementation: "Now write the function that passes all these tests."