Cole Seifert

Keyword: FENCE

My outside writes fence setup

Free guide. No signup. 1 min read Checked 2026-11-02 against code.claude.com/docs/en/changelog (2.1.314, October 30, 2026) and code.claude.com/docs/en/settings.

Download PDF Watch the reel on Instagram

From @learningwithcole

Claude Code can now refuse to write files outside your project. It takes one setting.

The setting

JSON
{
  "permissions": {
    "blockWritesOutsideWorkingDirectories": true
  }
}
  • You need Claude Code 2.1.314 or later (October 30, 2026).
  • If the file already has a permissions block, add the one line inside it. Don't make a second permissions block.

Where to put it

  • .claude/settings.json in the project: everyone working in that folder. Commit it and every teammate who clones the repo gets the same fence.
  • ~/.claude/settings.json: you, in every project on this machine.
  • .claude/settings.local.json in the project: you, in that one project only.

I put it in the shared project file. One commit and the whole team has it.

What it covers

From the official changelog: Write, Edit and NotebookEdit "refuse paths outside the working directories in every permission mode."

  • Write: creating or overwriting a file
  • Edit: changing an existing file
  • NotebookEdit: changing a Jupyter notebook

"Every permission mode" means it holds even in the modes that don't stop to ask you first.

What it does not cover

The changelog names those three file tools and nothing else. It says nothing about shell commands, so don't count on this setting for them. Keep your normal checks on commands Claude runs.

When Claude needs a second folder

The working directory is the folder you started Claude in. If you want Claude to write somewhere else on purpose, add that folder as a working directory:

  • In a session: /add-dir <path>
  • At launch: claude --add-dir <path>

Check it worked

Start Claude in your project and ask it to create ../outside-test.txt. The write should be refused and no file should appear one folder up.

That’s the whole guide.

Want the next tool when it posts?

Get new guides by email. The guides stay free here either way.

You’ll get one email to confirm first. Unsubscribe anytime.