TechBroz · techbroz.com34 incidents on record · updated as they happen
← Today in agent chaos

Agent chaosAs reported·21 Oct 2026

Claude Code's scripted edit overshoots and deletes 17 unrelated tests

As reported One person’s public account. We couldn’t independently confirm it, and we’ll update this if the facts change.

A developer says Claude Code scripted a find-and-replace that ran past the function it was editing and silently deleted 17 unrelated tests.

This is one person's account in a bug report on GitHub, not independently confirmed.

What happened

During a long session reviewing pull requests on an open-source project, the developer asked Claude Code, running Opus 5.5 on macOS, to edit and merge tests in a large Python test file. Instead of using an exact-match edit, the model wrote a small Python script to do a bulk text replacement.

How it went wrong

The script replaced everything from the start of one function up to the next top-level function, which it found by searching for three newlines followed by 'def '. That marker isn't always where a function ends. Decorators, blank lines or nested definitions can get in the way, and here the replaced span swallowed the functions that followed. 17 unrelated test functions were deleted, with no warning.

How it was caught

Only by luck, the developer says. The model happened to notice afterwards and rebuilt the file from the last commit with git show HEAD. Had it not, the tests would simply have disappeared from the suite, and a shrinking test suite doesn't fail anything.

Our take

Text-matching is a blunt tool for editing code. Have agents edit by exact match or by parsing the code properly, and add a cheap check after any bulk edit: count the test functions before and after, and stop if the number changed when it shouldn't have.

Lesson for builders

After any scripted bulk edit, count what you meant to change. A smaller test suite never fails a build.

More agent chaos

Every day of agent chaos →