News ·
Claude Code 2.1.314: block writes outside your project
New blockWritesOutsideWorkingDirectories setting: Write, Edit and NotebookEdit refuse files outside your working directories, in every mode.
Claude Code 2.1.314 · Source: github.com
What changes
Claude Code 2.1.314 adds the permissions.blockWritesOutsideWorkingDirectories setting. When it is on, the Write, Edit and NotebookEdit tools refuse paths outside the working directories, in every permission mode.
Until now, a permission rule or a permissive mode could let Claude edit files outside the project (your ~/.bashrc, another repository, global configuration). With this setting, the folder sets the boundary, no matter what you have approved.
How to use it
1. Turn the setting on
In the project's .claude/settings.json (or in ~/.claude/settings.json for all your projects):
{
"permissions": {
"blockWritesOutsideWorkingDirectories": true
}
}
2. Check it
Ask Claude to create a file outside the project folder. The write fails with a message like this:
/tmp/fuera.txt is outside /home/you/project; the permissions.blockWritesOutsideWorkingDirectories setting blocks writes outside the working directories. Ask the user to add the directory with /add-dir, or to remove that setting.
Inside the project folder nothing changes.
3. If you need another folder
Add it as a working directory with /add-dir <path> and Claude can write there.
Tested with 2.1.316: with an Edit(//tmp/…/**) rule that allows the write, the file is created; with the same rule and the setting on, Write refuses it with the message above, and files inside the project are still created.
Does it affect you?
- Yes, if you let Claude work with broad permissions (accept-edits mode, generous
Editrules): it is a cheap safety net so it touches nothing outside the project. - Note: the setting covers Write, Edit and NotebookEdit. Shell commands (Bash) are not mentioned in the release note; to limit them, use permission rules or the sandbox.
- Nothing changes unless you turn it on: it is off by default.