How do I stop an AI agent from touching unrelated files?
Instructions help less than people hope. They are advisory, and the model weighs them against its instinct to tidy whatever it reads. The reliable fix is mechanical: give each task an explicit list of files it may touch and reject any change that strays, and check the diff's file list before accepting anything. A boundary that is enforced by machinery does not depend on the model's cooperation.
From Why AI keeps breaking features that already worked, published 20 August 2026. That article is where the reasoning behind this answer is set out, including what it does not cover.