| ▲ | BeetleB 8 hours ago | ||||||||||||||||||||||||||||||||||||||||
I wish there was a way to "freeze" the tests. I want to write the tests first (or have Claude do it with my review), and then I want to get Claude to change the code to get them to pass - but with confidence that it doesn't edit any of the test files! | |||||||||||||||||||||||||||||||||||||||||
| ▲ | simlevesque 8 hours ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||
I use devcontainers in all the projects I use claude code on. [1] With it you can have claude running inside a container with just the project's code in write access and also mount a test folder with just read permissions, or do the opposite. You can even have both devcontainers and run them at the same time. [1] https://code.claude.com/docs/en/devcontainer If you want to try it just ask Claude to set it up for your project and review it after. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | comradesmith 8 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
1. Make tests 2. Commit them 3. Proceed with implementation and tell agent to use the tests but not modify them It will probably comply, and at least if it does change the tests you can always revert those files to where you committed them | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
| ▲ | joegaebel 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
You'd be surprised - I know I was - you can encode Test-Driven development into workflows that agents actually follow. I wrote an in-depth guide about this and have a POC for people to try over here: https://www.joegaebel.com/articles/principled-agentic-softwa... | |||||||||||||||||||||||||||||||||||||||||
| ▲ | paxys 8 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
Why can't you do just that? You can configure file path permissions in Claude or via an external tool. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | pfortuny 8 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
Why not use a client-server infrastructure for tests? The server sends the test code, the client runs the code, sends the output to the server and this replies pass/not pass. One could even make zero-knowledge test development this way. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | 7 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
| [deleted] | |||||||||||||||||||||||||||||||||||||||||
| ▲ | aray07 8 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
yeah i agree - this is somewhat the approach I have been using more of. Write the tests first based on specs and then write code to make the tests pass. This works well for cases where unit tests are sufficient. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | SatvikBeri 8 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
You can remove edit permissions on the test directory | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
| ▲ | kubb 8 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
"Add a config option preventing you from modifying files matching src/*_test.py." | |||||||||||||||||||||||||||||||||||||||||
| ▲ | dboreham 8 hours ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||
Just tell it that the tests can't be changed. Honestly I'd be surprised if it tried to anyway. I've never had it do that through many projects where tests were provided to drive development. | |||||||||||||||||||||||||||||||||||||||||