Stopping agents deleting code nobody agreed to delete
Autonomous sessions remove code to make things compile, and the removal rarely reaches the summary. How a pre-commit guard on unaccounted deletions works, and how to run it without blocking real work.
The most expensive thing an agent does is delete something quietly. A session hits a failing test, removes the assertion, and reports that the task is complete. A refactor drops a validation branch because it was in the way. None of this is malicious and all of it is easy to miss, because a deletion in a large diff looks like every other line.
Why deletions are different
An addition that is wrong gets caught by tests, by review, or by production, and it is visible. A deletion that is wrong removes the thing that would have caught it. It is also the least recoverable: finding when a check disappeared means searching history for the absence of something, which no tool makes easy.
The guard
The check runs at commit time and compares two lists: the symbols removed by the commit, and the removals accounted for by the session's stated intent. Anything in the first list and not the second stops the commit with the names printed.
$ git commit -m "add exponential backoff"
aura: 2 removals not accounted for
- validate_window src/limits.rs
- test_rejects_stale tests/limits.rs
Explain them with 'aura log-intent', or unlock with a passcode.The important property is that explaining is cheap and skipping is not. Adding a sentence saying the assertion was replaced by a stronger one takes seconds; bypassing the guard in strict mode needs a human with a passcode, and the bypass is recorded.
Keeping it from becoming noise
- Only symbols, not lines. A guard that fires on every deleted line gets disabled in a week.
- Deleting a whole file with a stated reason should pass in one step, not one per function.
- Generated code and vendored directories are excluded, since nobody reviews those deletions anyway.
- The message names what was removed and where. A guard that says "unaccounted deletions" and nothing else teaches people to skip it.
Where it sits in the workflow
Pre-commit, so the deletion never reaches a branch, and again at review, so the branch as a whole can be checked against the goal. Aura ships this as a pre-commit hook with a strict mode that can be locked by a human, meaning an agent cannot turn it off on its own.
See also: reviewing agent pull requests, where deletions are the first thing to read, and intent poisoning, which is the same check from the other side.
Why do AI agents delete code?
Usually to make something pass. A failing assertion, a type error, a test in the way — removal is the shortest path to green, and it is a legitimate move often enough that the model does not treat it as unusual. The summary then describes the fix and not the removal.
How do you stop an agent deleting code you needed?
Check removals at commit time, not review time. A pre-commit guard can compare what the change says it did against the functions that disappeared, and refuse the commit when a deletion is unaccounted for. Requiring an explanation is what makes it visible.
How do you find code an AI agent deleted?
If it was committed, it is in the history and recoverable by path. The hard case is code removed and never mentioned, because you have to know it is gone before you can look. That is the argument for catching it at the commit rather than later.
Aura Crew vs Claude Code Loops: the autonomous work-loop, compared
Claude Code defines four loop types — turn-based, goal, time, and proactive. Aura Crew is the same idea productized: a dependency-ordered work-loop with proof, collision-safety, and any agent. Full comparison.
Autonomous coding agent loops, explained: turn-based, goal, time, and proactive
A coding agent loop is an agent repeating cycles of work until a stop condition is met. The four types explained — turn-based, goal-based, time-based, proactive — with when to use each and how to keep quality high.
How to run multiple coding agents in parallel without merge conflicts
Running several AI coding agents at once collides on shared files. The fix: a worktree per agent, a live team radar, and soft-to-hard zone claims so parallel agents never touch the same symbol. How Aura Crew does it.
Goal-based agent loops: giving a coding agent a definition of done
A goal-based loop keeps a coding agent iterating until a success criterion is met. The trick is a deterministic definition of done — tests, a score, a proof — not an LLM guessing at "good enough." How to write one.