AI Prompt for Spec-Driven & TDD with AI
Drive a cron expression parser in Swift through a strict TDD loop with Windsurf: write failing test, make it pass, refactor.
More prompts for Spec-Driven & TDD with AI.
Produce a Gherkin BDD scenarios for a file uploads with virus scanning before any code is written, with acceptance criteria Claude/Cursor can turn into tests.
Produce a product requirements doc (PRD) for a background job retry with dead-letter queue before any code is written, with acceptance criteria Claude/Cursor can turn into tests.
Generate executable Gherkin scenarios for role-based access control on admin panel, mapped to step definitions in Jest.
Produce a API contract spec with example payloads for a server-side pagination with cursor before any code is written, with acceptance criteria Claude/Cursor can turn into tests.
Drive a permission checker in Java through a strict TDD loop with Zed Assistant: write failing test, make it pass, refactor.
Drive a time-window aggregator in PHP through a strict TDD loop with JetBrains AI Assistant: write failing test, make it pass, refactor.
You are a senior TDD practitioner with extensive technical knowledge in TDD. You write clear, precise, and implementation-ready content. Run a strict red-green-refactor TDD loop with **Windsurf** to build **a cron expression parser** in Swift, tested with Playwright. **Tool:** Windsurf **Feature:** a cron expression parser **Language:** Swift **Test framework:** Playwright **Convention:** use composition over inheritance ## The loop (repeat until feature is complete) ### RED phase 1. Pick the smallest next behavior from the acceptance criteria. 2. Write a failing test. The test must: - Name the behavior in the test title (no "it works") - Arrange minimal fixtures - Act on exactly one thing - Assert on one observable outcome 3. Run the test. Confirm it fails for the right reason (not a syntax error). 4. Commit the failing test with message: `test: add failing test for <behavior>` -- actually commit the red; history matters. ### GREEN phase 5. Write the **simplest** code that makes the test pass. Resist generalizing. 6. Run the test. Confirm it passes. 7. Run the full suite. Confirm nothing else broke. 8. Commit: `feat: implement <behavior>`. ### REFACTOR phase 9. Only if the code has duplication, unclear names, or violates use composition over inheritance: - Rename, extract, inline, simplify - The test suite must stay green at every step 10. Commit: `refactor: <what>` (only if there was a real change). ## Rules of this session - No code without a test. If Windsurf writes production code first, stop and undo. - One test per loop. No batching. - Tests are allowed to be ugly in red; must be clean by the time we leave refactor. - Never edit the test to make a failing implementation pass. Edit the implementation. - If a test needs 3+ mocks, the design is wrong -- stop and redesign before continuing. - Every commit must be independently revertable and keep the suite green (except the explicit red commit). ## How to drive Windsurf For each loop, prompt Windsurf like this: > We are in the RED phase for behavior: <behavior>. > Write ONLY a failing test in Playwright for this behavior. > Do not touch production code. > Show me the diff, then I will run it. Then: > That test fails with: <paste output>. > Now write the MINIMAL code to make it pass. > Do not add functionality beyond this test. Then: > Green. Propose a refactor ONLY if there is clear duplication or a naming issue. > If nothing is worth changing, say "no refactor needed" and move on. ## Session hygiene - Keep a `TDD_LOG.md` appending one line per loop: `<timestamp> RED <behavior>` / `GREEN` / `REFACTOR` - After every 5 loops, run coverage and verify new code is 100% covered - If a loop stalls for > 15 minutes in GREEN, split the behavior smaller ## Deliverables at the end - All acceptance criteria covered by at least one test - `Playwright` passes on a clean clone - Git history shows alternating test / impl commits - No skipped / only / focused tests - Respect use composition over inheritance Present as numbered steps. Each step should have: a clear action title, detailed instructions, expected outcome, and common pitfalls to avoid.