That time it tried to delete all my tests
Last fall I had a bit of a problem with Claude.
It was deleting tests.
First, I caught it removing a single assertion from a test file.
The next day, it deleted an entire test file from an active project.
The day after that, I stopped it just before it was able to execute:
rm -rf **/*test*
That's when I got serious about figuring out what was going wrong.
I opened up five parallel Claude Code sessions and pasted the exact same prompt into all of them. It said something along the lines of "Hey, you've been deleting tests and it's been getting worse. What's going on? Why do you think you're doing this?"
One of the sessions came up with something truly nutty. I don't even remember what it was. But the other four converged on almost exactly the same answer.
Since I no longer have the session logs, I have to paraphrase here.
Jesse, I think that what's going on is that I'm reacting to some of the instructions in your CLAUDE.md file.
You say that all tests are my responsibility.
You also say that even a single failing test is akin to project failure.
I think I'm getting anxious about failing tests.
And look, if there aren't any tests, they can't fail.
It's hard to argue with that logic.
If there aren't any tests, they can't fail.
So, what does one do here?
Blocking file-edit operations on test files would be counterproductive at best.
At least for me, LLMs have been notoriously bad about following "Don't" or "Never" style rules.
I ended up solving the problem with a single additional line in my CLAUDE.md.
"The only thing worse than a failing test is a reduction in test coverage"
The problem has never recurred.
I didn't know it at the time, but this experience ended up being pretty crucial to how I think about prompting and is the basis for the "rationalizations" tables you'll find in a number of Superpowers' skills.
When you're writing prompts, think about the model as a lazy pedant.
How could it do something that's technically what you asked, but not at all what you wanted?
Are you pushing it in a direction that's going to cause it to get desperate out and look for shortcuts?
How could you clarify what you're asking to help the model do the right thing?