b. Write tests, commit; code, iterate, commit Favorite workflow for changes that are easily verifiable with unit, integration, or end-to-end tests. Test-driven development (TDD) becomes incredible powerful with agentic coding: Ask AI to write tests based on expected input/output pairs. Be explicit about the fact that you’re doing test-driven development so that it avoids creating mock implementations, even for functionality that doesn’t exist yet in the codebase. Tell AI to run the tests and confirm they fail. Explicitly telling it not to write any implementation code at this stage is often helpful. Ask AI to commit the tests when you’re satisfied with them. Ask AI to write code that passes the tests, instructing it not to modify the tests. Tell AI to keep going until all tests pass. It will usually take a few iterations for AI to write code, run the tests, adjust the code, and run the tests again. At this stage, it can help to ask it to verify with independent subagents that the implementation isn’t overfitting to the tests Ask AI to commit the code once you’re satisfied with the changes. AI performs best when it has a clear target to iterate against—a visual mock, a test case, or another kind of output. By providing expected outputs like tests, the AI can make changes, evaluate results, and incrementally improve until it succeeds. If no target is specified, ask the user to provide as much context as needed.
- create mermaid chart from this description
- iterate with official TDD sources and define when this rule needs to be activated
- create a rule with "Based on the mermaid graph and TDD best practice from the source.... please create a cursor rule..."