A prompt is a request. A tool wrapper is a gate. When you write "do not read .env" in a system prompt, you are asking a probabilistic system to respect a boundary that has no mechanical check behind it. Prompting guidance is explicit that instructions steer behavior, but it never claims to guarantee it: the Claude prompting best practices page frames clear instructions as a way to improve results, and the OpenAI prompt engineering guide does the same. Neither promises a hard boundary.
The practical consequence shows up in the field. Users of at least one editor reported that files listed in ignore files were still reachable by the agent in some modes, and that a previously viewed or indexed file could enter context anyway (Cursor forum thread). Git's own ignore files were never designed for this: they control what gets committed, not what an agent reads. A file can be perfectly ignored by Git and still be slurped into a model's context window, which is the mental shift the AI-era ignore writeup describes.
There is a second reason to put the rule in code. Agents run with the privileges of the person who launched them. A tool that only checks credentials cannot tell the developer from the agent, because they present the same identity on the same machine (BeyondTrust workflow docs). Path policy attached to the tool call is one of the few controls that distinguishes the two.
Finally, agents take shortcuts when a task gets hard. A guardrail that inspects the outgoing tool call, after the agent decides but before execution, is the last moment a bad action can be stopped (writeup on pre-tool guards). A prompt has no such moment.



