What they did
The author, who posts on dev.to as Agent Shipped, wanted parallel Claude Code subagents to stop overwriting each other. They had Claude write a PreToolUse hook that reads a plan file and the active task id, then blocks any Edit, Write or MultiEdit outside that task's file scope with exit code 2 and a reason. The task id lives in a file set from the terminal so an agent cannot switch itself to another scope. A PM agent, allowed to write only the plan, split the job into three tasks (a slug helper, a word counter, usage docs) and printed an overlap check. The author committed the plan, then the main agent handed each task to a subagent through the Task tool with a four-line hand-back: result, commit, tests, open items.
How it went
The first hook blocked a legal write: Claude Code sends absolute paths and the gate compared them as plain strings against relative scopes. Normalising paths against the project directory, and treating anything that resolves above it as outside, fixed that, pinned by five tests. In the real run all three tasks finished with one commit each, and the single write the author forced the second subagent to make into the first task's file was refused and logged, with git status showing no change.
Worth knowing
The gate only watches the file edit tools, not Bash, so a shell redirect can still write anywhere. The tasks were small demo tasks on a public repo, and the post is also a video walkthrough of the author's technique.