# Permission Rule

> A line that says yes, ask or no to a tool.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** Claude Code permission rules, allow rule, deny rule

## Think of it like

It is like a house list. Always fine, ask me first, and never.

## Definition

A permission rule tells Claude Code to allow a tool, ask about it, or deny it. A rule names a tool and can add a pattern, such as Bash(npm test) or Read(./.env). Rules live in the permissions block of a settings file, and /permissions lets you see and change them. They are checked in a fixed order: deny first, then ask, then allow. The first rule that matches decides.

## Example

Jack is tired of approving npm test. He adds one allow rule for it, and one deny rule so Claude can never read his .env file.

## Example code

```json
{"permissions": {"allow": ["Bash(npm test)"], "deny": ["Read(./.env)"]}}
```

Allow the test command. Never read the secrets file.

## Why it matters

The mode sets the broad rule. Rules give exact control over each tool.

## Common mistake

Expecting allow to beat deny. Deny is checked first, so a deny rule always wins.

## Three principles

- **Allow, ask, deny.** Three kinds.
- **Tool and pattern.** Bash(npm test).
- **Deny first.** First match wins.

## Related terms

- [Permission Mode](https://learn.benibix.com/term/ai/permission-mode)
- [JavaScript Object Notation (JSON)](https://learn.benibix.com/term/development/json)
- [Auto Mode](https://learn.benibix.com/term/ai/auto-mode)
- [Claude Code Sandbox](https://learn.benibix.com/term/ai/claude-code-sandbox)
- [Claude Code Built-in Tool](https://learn.benibix.com/term/ai/claude-code-built-in-tool)

## Told apart from

- [Permission Mode vs Permission Rule](https://learn.benibix.com/compare/permission-mode-vs-permission-rule): People think a permission mode and a permission rule are the same switch. They are not. A mode sets how often Claude asks, for the whole session. A rule names one tool, or one command, and says allow, ask or deny for just that one. A deny rule wins in every mode, even bypass.

## Taught in

- [Permission Rules and Sandbox](https://learn.benibix.com/learn/ai-claude-code/permission-rules-and-sandbox): Claude Code, 6/16
- [Setup and Config Commands](https://learn.benibix.com/learn/ai-claude-code-commands/setup-and-config-commands): Claude Code Commands, 9/17

![A tool call meets three lists in order: deny, then ask, then allow. The first match decides.](https://learn.benibix.com/diagrams/cc-permission-rule.svg)

---

Source: https://learn.benibix.com/term/ai/permission-rule
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
