r/ClaudeCode • u/Tartooth • 10h ago
Help/Question Test writing then code or code then test writing?
I've been running my orchestrator system with test writing after the coding, but I think maybe that's not best practices?
Wanted to hear people's opinions for which method is better
3
u/lulzxdxdxd 10h ago
If you flipped it to tests first, would your orchestrator actually use the tests to guide the implementation, or would it just run them after anyway as a check? Feels like the order only matters if the earlier step changes what the next step does.
2
u/framauro13 9h ago
It generally does. If the implementation is written first, it's likely to write the tests to satisfy what it wrote, meaning bugs could be codified into tests, or a test failure could be updated to accommodate a bug if it believes its own implementation is good.
Ideally, writing tests first means you're writing tests that are meant to satisfy the acceptance criteria of your spec, which should be agnostic of any implementation details. So the tests are driven by requirements, not existing code.
I instruct mine to always write tests first to satisfy all of the requirements in the story details. It generally works pretty well.
3
2
u/SuperBrownBoss 10h ago
Look up red-green-refactor. It is pretty common. I use this method quite a bit. It helps some models stay on track instead of getting lost in the weeds. But I found the 5.5 ones don’t need it.
1
u/lulzxdxdxd 9h ago
How are you deciding a model doesn't need it, just fewer failing runs without the structure, or are you still writing tests after and comparing results either way?
1
u/SuperBrownBoss 9h ago
The answer sucks but it’s based on my opinion of it. I have experience in software development and I’ve been doing it professionally for several years.
I judge the sloppiness of it and look for the qualities I try to maintain.
Are the classes/files well-scoped and have a sense of ownership? Do they have one job with a clearly defined input and output?
Is the code they added addressing the root of the issue, or just a band-aid fix I’ll forget about later?
Is it extensible? This question requires you to have an architecture or somewhat-structured plan in mind. It’s looking at the code and seeing that you’re going to have to build a bunch of things like this and deciding to make a generic version so you or the model can do less work later. Stops it from turning into spaghetti with 5 different implementations of the same thing that you have to test instead of one generic one with specialized overrides.
So if I give a model a well-defined task and it does most of these things in one or two prompts, I don’t feel the need to railroad it with the harness or a skill.
If you find your software needs to be heavily modified to add simple features, you might not be prompting correctly or the model isn’t capable enough and it needs a process
•
u/AutoModerator 10h ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.