Omniscio

OmniscioGuidesPermission rulesProtect files

Claude Code permissions: protect files from edits

Lockfiles, migration folders, workflow files and generated code have one thing in common: a person edits them through a tool that understands them, and a stray edit is expensive. Five deny rules keep them out of reach.

Checked on November 27, 2026 against the Claude Code 2.1.332 documentation. By the Omniscio team. Updated .

The block

{
  "permissions": {
    "deny": [
      "Edit(**/package-lock.json)",
      "Edit(**/pnpm-lock.yaml)",
      "Edit(**/migrations/**)",
      "Edit(./.github/workflows/**)",
      "Edit(./generated/**)"
    ]
  }
}

One list, five rules. The first two cover lockfiles at any depth, the third covers a migrations folder wherever it sits, and the last two cover the workflow folder and a generated folder at the repository root.

Put it in .claude/settings.json so the whole team gets it, or in ~/.claude/settings.json for every project on your machine. Deny rules apply as soon as the file loads, without the workspace trust step that allow rules need.

What each rule covers

The five rules and what each one protects.
RuleBlocksLeaves alone
Edit(**/package-lock.json)Any package-lock.json at or under the current directorypackage.json, and lockfiles with another name
Edit(**/pnpm-lock.yaml)Any pnpm-lock.yaml at or under the current directoryThe pnpm workspace file
Edit(**/migrations/**)A migrations folder at any depth, and every file under itA folder named migration, or a file named migrations.ts
Edit(./.github/workflows/**)The workflow files under the repository root.github/ISSUE_TEMPLATE and the rest of .github
Edit(./generated/**)The generated folder at the repository rootA nested generated folder under another directory

A bare filename follows gitignore semantics and matches at any depth, so Edit(.env) and Edit(**/.env) are the same rule. A relative pattern with a single directory segment behaves differently by list: as a deny rule, Edit(migrations/**) matches a folder with that name at any depth, while as an allow rule it would match only the folder at the current directory.

The glob rules are gitignore's: * stays inside one path segment, while ** crosses directories. A bare filename matches at any depth, which is what makes the first two rules cover a lockfile in any package folder.

Where a path anchors

The leading characters of the pattern decide where it starts counting, and this is the part that makes a rule protect the wrong folder.

The four path forms, and what each anchors to.
PatternMeans
//pathAn absolute path from the filesystem root
~/pathA path from your home directory
/pathA path relative to the settings source that defines the rule
path or ./pathA path relative to the current directory

A single slash is not absolute. In project settings, Edit(/src/**) resolves under the working directory. In ~/.claude/settings.json the same rule resolves under ~/.claude, which blocks ~/.claude/src and nothing in your project. Use // for an absolute path and ~/ for one from your home directory.

Edit rules, and the read rules that cover more

An Edit(path) rule applies to every built-in tool that edits files. A Read(path) deny rule does two jobs: it keeps the file's contents away from Claude, and it also blocks Edit and Write on the same path, including creating a new file there.

Read denies reach further than the file itself. The listing Claude receives leaves out the names a rule matches, and a pasted image path is not attached when a rule covers it. NotebookEdit is the exception, so add an Edit deny for a path no tool may change.

Write it as Edit, not Write. A Write(path) rule, a Glob(path) rule and a Grep(path) rule are accepted but match nothing. Use Edit(path) for an edit rule and Read(path) in place of a Glob or Grep rule.

For a file that must not be read at all, the secrets block is the fuller example, and it belongs to the .env and secrets page.

The edit a file rule does not see

A file rule is enforced on Claude's file tools. In a Bash command that Claude Code can analyze, it also applies to redirect targets and to file commands the tool recognizes, such as cat, head, tail, sed and tee. Those forms are covered.

What it does not cover is a command that touches the file without naming it, such as grep -r pattern . run from the folder that holds the file, and any subprocess that opens files itself, such as a Python or Node script. For enforcement at the operating-system level, Anthropic points to the sandbox, with the unsandboxed retry turned off.

Treat the block as a guardrail around the tools Claude usually reaches for, not as a filesystem permission. The distinction matters for a lockfile, because a package manager run by Claude writes it through a process of its own.

Confirm it took effect

  1. Run /permissions and check that the five deny rules are listed, with the settings file that supplied each.
  2. Ask Claude to edit package-lock.json. Refused.
  3. Ask it to edit a file under migrations/. Refused, including at a nested depth.
  4. Ask it to edit something outside those paths. The request goes through as it did before.

When a rule is dropped rather than applied, claude doctor lists the entries Claude Code rejected. A rule added while Claude is working applies from its next tool call.

The mistakes that make a file rule misfire

  • A single-slash path in user settings. Read(/migrations/**) there anchors under ~/.claude, not under your project.
  • Using Write, Grep or Glob in the rule. Those path rules match nothing. Edit and Read are the two that work.
  • Expecting NotebookEdit to be covered by a Read deny. It is not. Add an Edit deny for the path.
  • Assuming the rule follows the file. A script that opens the path itself, or a command that names no file, is outside what the rule can see.

The other new pages

Each page carries a complete block, not a fragment. The hub lists all ten.

Where Omniscio fits

Omniscio is a desktop app for running several Claude Code agents side by side in one window. The rules on this page are Claude Code's own and apply inside an Omniscio session, because each session runs Claude Code.

Where these answers come from

Common questions

Does an Edit deny rule also stop the Write tool?

Yes. Edit rules apply to every built-in tool that edits files, including Write and NotebookEdit, so one Edit deny covers them all. A Read deny also blocks Edit and Write on the same path, but not NotebookEdit, which is why the block on this page uses Edit rules.

Why does Read(/secrets/**) in my user settings block the wrong folder?

A pattern with a single leading slash anchors at the settings source, not at the filesystem root. In ~/.claude/settings.json it resolves under ~/.claude. Use // for an absolute path or ~/ for one from your home directory.

Do these rules stop a shell command that edits the file?

Sometimes. Claude Code checks redirect targets and the file commands it recognizes, such as cat, head, tail, sed and tee, against your file rules. It does not check a command that reads or writes files without naming them, such as grep -r run from the folder that holds the file, or a Python or Node script that opens the file itself.

Should I use a Write(path) or Grep(path) rule?

No. Claude Code accepts those rules but does not match them, so they protect nothing. Write it as Edit(path), and write Glob or Grep as Read(path).