All articles

Allow and Deny Rules Explained

By default Claude Code asks before it runs a command or edits a file. That's safe, but the prompts add up. The permissions key lets you pre-approve safe actions and block risky ones, so you get asked less and stay protected.

The shape of it

Under permissions you get two arrays, allow and deny. Each holds patterns that match a tool and, for some tools, its arguments.

{
  "permissions": {
    "allow": [
      "Read",
      "Bash(npm run test:*)",
      "Edit(src/*)"
    ],
    "deny": [
      "Bash(rm *)"
    ]
  }
}

Reading the patterns

The part before the parenthesis is the tool: Read, Edit, Write, Glob, Grep, or Bash. The part inside narrows it down. Bash(git *) matches any git command. Bash(npm run test:*) matches your test scripts but not other npm commands. Write(/tmp/*) allows writing only under /tmp. A bare Read allows all reads.

Allow vs deny

An allow rule means "do this without asking me." A deny rule means "never do this, don't even ask." Deny is the stronger of the two, so use it for anything you truly want off the table, like destructive shell commands.

A sensible start

Allow the read-only tools and your safe scripts. Deny the commands that could wreck things. Leave everything else to the default prompt, so Claude still checks with you on anything you didn't list.

{
  "permissions": {
    "allow": ["Read", "Grep", "Glob", "Bash(git status)"],
    "deny": ["Bash(git push:*)"]
  }
}

You can also edit these live with /permissions. Start narrow, then add rules as you learn which prompts you're tired of seeing.

Comments

Be the first to comment.