CONCEPT Three lists, one syntax: Tool or Tool(specifier)
Where modes (3.1) set the baseline, permission rules
make it precise. Every rule targets a tool and optionally narrows it with a specifier in parentheses. Rules live
in the permissions block of a settings file (or you manage them live with /permissions):
allow— Claude uses the tool without asking.ask— Claude prompts for confirmation each time.deny— Claude is blocked from the tool entirely.
| Rule | Effect |
|---|---|
Bash | Matches all Bash commands (bare name = whole tool) |
Bash(npm run build) | Matches the exact command npm run build |
Bash(npm run test:*) / Bash(npm run test *) | Matches commands starting with npm run test (trailing wildcard) |
Read(./src/**) | Reads under <cwd>/src/ (gitignore-style path) |
Read(./.env) | Matches reading the .env file in the current dir |
WebFetch(domain:example.com) | Fetch requests to example.com |
mcp__puppeteer__navigate | One tool from the puppeteer MCP server |
Bash(ls *) (with the space) matches ls -la but not lsof —
the space enforces a word boundary. Bash(ls*) matches both. The :* suffix is
equivalent to a trailing *, so Bash(npm run test:*) == Bash(npm run test *).CONCEPT Deny wins — precedence is deny → ask → allow
Rules are evaluated in order: deny first, then ask, then allow. The first match determines
the outcome, and rule specificity does not change the order. So a broad
deny like Bash(aws *) blocks even a call that also matches a narrow
allow like Bash(aws s3 ls) — a deny rule can't carry allowlist exceptions.
--allowedTools on the CLI — can re-allow it.Bash removes the tool from Claude's context entirely
(Claude never sees it). A scoped deny like Bash(rm *) leaves the tool available and blocks
only matching calls. Bash(*) is equivalent to bare Bash.CLAUDE.md shape what Claude tries, but they never change what the harness
allows. Read/Edit rules follow the gitignore spec: //abs, ~/home,
/settings-relative, and path/./path = cwd-relative.DIAGRAM A call is checked deny → ask → allow
CODE A realistic permissions block
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Bash(git commit *)",
"Read(./src/**)",
"WebFetch(domain:docs.claude.com)"
],
"ask": [
"Bash(git push *)"
],
"deny": [
"Bash(curl *)", // block network shell tools
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
]
}
}
git push), deny the never-OK (reading .env, raw curl). Because deny
beats allow, the Bash(curl *) deny holds even if a broader Bash allow exists.TRADE-OFFS Broad allow vs. explicit rules
✅ Narrow, explicit rules
- Least privilege — only the exact commands you meant
- Check into version control, share across the team
- Deny rules give a hard, un-overridable boundary
⚠️ Broad allow like Bash or Bash(*)
- Fewer prompts, but grants arbitrary shell
- Argument-constraining patterns (
Bash(curl example.com *)) are fragile — options, redirects, and variables slip past - Better: deny the tool and use a scoped tool like
WebFetch(domain:…)
EXAM TRAPS
Bash(aws *) in deny blocks
Bash(aws s3 ls) even with an explicit allow for it.CLAUDE.md enforces it." → No. Memory shapes
intent; only /permissions, settings rules, a permission mode, or a PreToolUse hook
enforce. Rules are enforced by the harness, not the model.Bash(ls*) and Bash(ls *) mean the same." → The space
matters. Bash(ls *) requires a word boundary (matches ls -la, not lsof);
Bash(ls*) matches both.PRACTICE
Q1 · You allow Bash(aws *) but deny Bash(aws s3 rm *). Can Claude run aws s3 rm s3://bucket/x?
No. Deny is checked first and wins regardless of the broader allow. The
aws s3 rm command is blocked; other aws commands still run via the allow.
Q2 · Write a rule set that lets Claude read source but never read secrets, and lets it fetch only the docs site.
allow: ["Read(./src/**)", "WebFetch(domain:docs.claude.com)"] and
deny: ["Read(./.env)", "Read(./secrets/**)"]. The deny guarantees secrets stay unreadable even if a
broader Read allow is added later.
Q3 · Why is Bash(curl https://safe.com *) a weak way to restrict curl to one host?
Argument patterns are fragile: -X GET before the URL, https vs
http, redirects, or a variable like $URL all evade it. Prefer denying
Bash(curl *) and granting WebFetch(domain:safe.com), or use a PreToolUse hook.