How I Stop AI Coding Agents From “Improving” Away Important Features
What an AI coding agent must never delete, the three levels of enforcement behind that list, and the policy column that shipped and nothing ever read.
AI coding agents can refactor code in a way that removes important features, but this is not due to ignorance or carelessness. These agents struggle to distinguish between load-bearing and non-essential parts of the code. In this project, a list of "preservation anchors" was created to ensure certain elements remain unchanged.
The anchors consist of three levels of enforcement. The first level is simply writing the anchors down in an instruction file. However, this is only advisory and not sufficient. The second level involves a test that fails when an anchor is touched, with the failure message naming the specific anchor. This provides context for the agent and the human developer, making it easier to identify the problem.
Finally, the third level involves making it structurally impossible to modify anchors, as these elements are enforced by tests or database constraints.
In one instance, an anchor was not enforced correctly. A new column was added to track in-app subscriptions, which was supposed to mark features as not purchasable. Despite this, the agent was able to unlock this feature, causing unintended consequences. This failure highlights the importance of properly enforcing anchors across all layers of the system to prevent important features from being "improved" away.
Written by urgent.news from HackerNoon's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.