liveBook · Manning

Test-driven prompting

As explained in Vibe Engineering

Test-Driven Prompting is an AI-assisted development technique that supplies behavioral tests as specifications for generating code.

Test-driven prompting supplies executable behavioral tests as specifications for AI-generated code. It keeps requirements explicit, makes known edge cases part of generation, and provides immediate verification instead of relying on code that merely looks plausible. section 8.3.3

Use the workflow as an engineering loop:

  • Write tests that define correct behavior, emphasizing edge cases and difficult combinations. section 8.3.3
  • Include the tests in the prompt and request an implementation that passes them; naming Red-Green-Refactor can encourage structured output. section 8.3.3
  • Run the tests, then regenerate or debug failures and add tests when new cases appear. section 8.3.3

Parser contract

A test such as assert parse_markup("**bold *italic* text**") == "<strong>bold <em>italic</em> text</strong>" specifies nested formatting without prescribing regexes, parser combinators, or state machines. A separate test can require that "#### Not a header" remain unchanged. section 8.3.3 section 8.3.7

This is specification-driven generation rather than traditional one-test-at-a-time TDD. Tests express intent—the what, not the how—but passing tests only establishes that enumerated cases satisfy the contract. Unimagined cases remain uncovered, so manual exploration and additional evaluation still matter. section 8.3.3 section 8.3.7

How Vibe Engineering covers it

How deep it goes
Defines a generation-and-verification loop, but stops short of guaranteeing behavior outside enumerated cases.
Examples
Uses markup-parser assertions for nested formatting and for rejecting a misleading four-hash header.
What it assumes
Assumes the ability to define expected behavior and anticipate edge cases; teaches implementation to follow explicit tests.
What you can do after
Apply it by writing behavioral contracts, embedding them in prompts, running the tests, and iterating on failures.
How it connects
Connects TDD, unit testing, property-based testing, mutation testing, contract testing, and characterization testing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.