Blog

Claude Code 2.1.314: how to stop the agent from writing outside your project

A new Claude Code setting makes Write, Edit and NotebookEdit refuse paths outside the project in every permission mode. How to turn it on and what it leaves out.

Since Claude Code 2.1.314 you can stop the agent from writing files outside your project folders, even in the most permissive permission mode. I would turn it on at user level today, knowing it does not cover terminal commands.

What changed

Version 2.1.314 shipped on October 30, 2026 with a new setting: permissions.blockWritesOutsideWorkingDirectories. According to the release notes, when it is on, the Write, Edit and NotebookEdit tools “refuse paths outside the working directories in every permission mode”.

The key part is “every permission mode”. Until now, if you started Claude Code in bypassPermissions (the mode that never asks) or left it in auto mode, the only thing standing between the agent and a file elsewhere on your machine was the agent’s own judgment. With this setting the barrier becomes deterministic: the tool says no, whatever the model thinks.

Working directories, as Classmethod’s write-up lists them, come from four places:

  • The folder you launch claude from (or the one you set with /cd).
  • Folders added at launch with --add-dir <path>.
  • Folders added during the session with /add-dir.
  • Folders declared in permissions.additionalDirectories in your settings.

Everything else (your ~/.zshrc, the repo next door, ~/.ssh) is out of reach for those three tools.

There was already a read-side counterpart, permissions.blockReadsOutsideWorkingDirectories, which shows up in the 2.1.311 notes from October 26. Together they close both directions: the agent does not read what it should not, and does not write where it should not.

How to turn it on

The simplest place is your user settings, ~/.claude/settings.json, so it applies to every project:

{
  "permissions": {
    "blockWritesOutsideWorkingDirectories": true,
    "blockReadsOutsideWorkingDirectories": true
  }
}

If you work in a monorepo or with a shared folder the agent should touch, add it explicitly:

{
  "permissions": {
    "blockWritesOutsideWorkingDirectories": true,
    "additionalDirectories": ["../shared-libs"]
  }
}

To check it works, open a session in a test project and ask the agent to create a file in the sibling folder. In Classmethod’s test, in bypassPermissions mode, a Write to a sibling directory was refused with the setting on and went through without it.

One thing to watch: for the read-side setting, folders added through repository settings (.claude/settings.json) do not count as working directories, according to the same write-up and an open issue. If something breaks after you turn it on, check where you declared the extra folder first.

What it does not cover

The release notes name three tools: Write, Edit and NotebookEdit. They do not name Bash. I would assume that an echo "..." >> ~/.bashrc or a cp run from the agent’s terminal does not go through this setting, because nothing official says otherwise and Classmethod did not test it either.

For the terminal you need other layers:

  • Claude Code’s sandbox for Bash commands, which limits which parts of the file system a process can reach.
  • deny rules in your permissions for commands you never want it to run.
  • A container or a separate machine if you are going to leave it in bypassPermissions for hours.

This setting replaces none of those. It closes the most common case, the agent editing the wrong file, and leaves the rest to you.

While you are at it: 2.1.316

A day later, on October 31, version 2.1.316 brought two changes that matter if you already use auto mode:

  • CLAUDE_CODE_SUBAGENT_EFFORT, an environment variable that sets the default effort level for subagents. Handy so the small tasks you delegate do not spend like big ones.
  • Fast mode for Opus 4.8 is deprecated as of October 30 and “will be removed on November 30, 2026”. If a script or a CI job relies on it, you have a month to change it.

It also fixes a bug where --restricted sessions could upload files from outside the working directories when a Read allow rule covered them. One more reason to update.

My take

I would turn it on at user level, not project by project. It costs two lines of JSON and removes a whole category of surprises: the agent that, halfway through a long task, decides to “fix” your global config or writes a file in the wrong repo. When you work alone with several agents at once, that kind of mistake is the one that costs you the most time, because you only notice it days later.

I like that it is a rule in the tool and not an instruction in the prompt. A “do not touch anything outside this repo” line in CLAUDE.md depends on the model honouring it; this setting does not.

What I would not do is treat it as a reason to run bypassPermissions on my main machine without anything else. Until Bash is explicitly covered, the combination that seems reasonable to me is this setting plus the sandbox, and a container for long unattended sessions.

If you have Claude Code installed, run claude --version: if you are below 2.1.314, update before you touch the settings.

Sources

If these notes on day-to-day work with agents are useful, follow me on LinkedIn, where I share what I am trying.

← All articles

Have a product to build or a tech stack to put in order?

Tell me what you are trying to achieve and where you are today. I reply personally, usually within a day.

Free · 30 minutes

Digital strategy session

30 minutes to map where to start digitalizing and transforming your business. You pay nothing, before or after.

When you book, you answer three short questions: what you need, what stage your project is at and when. That way the session starts with context.