When you fix a bug, AI agents usually add a test in the final step.
The problem is, the generated test often doesn't replicate the original bug.
I use TDD, or test-driven development, to ensure that I'm not just adding code coverage.
My next problem is: when agents do TDD, they tend to add a specific, brittle test for that issue. Over time, my test files become a disorganized and duplicative mess.
So, lately I've been adding something like this to my prompt: "Use TDD, and don't just bolt on a new test. Where helpful, refactor the test suite as you go. Consider the structure, DRY principles, and whether this should be a parameterized test case."
This should be in my AGENTS.md file, but I'm still fine-tuning the approach.
What are your tips on writing tests with AI agents?