What happened that day

Even if you hand an AI agent the rules as a document, once a session grows long the rules stop getting read, and the same violations recur. In development where several agents read and write the same repository in parallel, when the rules stop being followed like this, it leads to accidents: unsaved changes disappear, work proceeds against a stale main, writes to the same file collide.

So I stopped relying on getting the rules obeyed at all, and instead moved the rules to a place where they can't be broken even if you try. This article is a record of running that countermeasure across three repository groups, and the three, which I had been operating separately, have settled into the same pattern: isolation via git worktree, which carves each task out into an independent directory.

Of the rules I had written in documents, I moved three into a layer that takes effect without going through the agent's judgment: stopping state-changing git commands with a pre-execution hook, forbidding direct pushes to main with a setting on the hosting side, and connecting the environment-variable file to the worktree with a hook that runs when a session starts. Once I did, the violations that had kept recurring under the document-based approach stopped happening. Carving out one working directory takes 0.25 seconds, so even splitting it per agent, the carving itself barely costs any time.