Bash(npm run *) looks narrow, but Anthropic’s matcher also accepts the bare npm run command. It does not match npm install. That difference is why a Claude Code permissions settings file needs more than a list of tools. I checked the current docs and issue tracker on November 3, 2026; the examples below are documentation-only and haven’t been run.

The short answer: put personal rules in ~/.claude/settings.json, rules for one private checkout in .claude/settings.local.json, and shared defaults in the committed .claude/settings.json. Start with default, allow only commands you repeat, deny sensitive paths, and use /permissions to inspect the effective rules. For CI, use a narrow allow list with dontAsk, so an unlisted action is denied instead of waiting for a person.

Where should Claude Code permissions go?

Choose the file by who should inherit the rule: you, one checkout, everyone who clones the repo, or your organization’s administrators. Managed policy has the highest precedence; the settings lists themselves can still combine.

FileApplies toUse it for
~/.claude/settings.jsonYour projects on this machinePersonal defaults and rules you want everywhere
.claude/settings.local.jsonYour current project onlyTesting a policy or keeping your own project exceptions private
.claude/settings.jsonThe project, including teammates after it is committedShared team rules
Claude Code managed settingsMachines or accounts covered by your organizationCentrally deployed policy; administrators provide this file or policy

When Claude Code creates .claude/settings.local.json itself, it adds that file to its global Git excludes; if you create it yourself, add it to .gitignore (Anthropic settings guide (2026)). Commit the shared file only after reviewing each rule: a project allow rule grants capability and may be shown in the workspace trust dialog.

According to the Anthropic settings guide (2026), precedence is managed settings, session --settings, project-local settings, shared project settings, then user settings.

For list keys such as permissions.allow, entries from different files merge. For permission decisions, deny wins over ask, and ask wins over allow, even when the allow rule is more specific. An allow entry in one file won’t erase a deny from another.

How do Claude Code permissions match rules?

A rule is a tool name, optionally followed by a specifier in parentheses. Put repeatable, understood actions in allow, actions you want to review in ask, and actions you want blocked in deny.

json
{
	"permissions": {
		"allow": ["Bash(npm run test)", "WebFetch(domain:docs.example.com)"],
		"ask": ["Bash(git commit *)"],
		"deny": ["Read(./.env)", "Read(./.env.*)"]
	}
}

The Anthropic permissions guide (2026) documents Bash(npm run build) as an exact command, Read(./.env) as a path rule, and WebFetch(domain:example.com) as a domain rule. A * is a wildcard, not a regular expression. Bash(npm run *) matches npm run build, npm run test --watch, and even npm run; it does not match npm install.

Two gotchas:

  • A Bash rule is about the command Claude Code sees. It is not a boundary around what that program can do. The docs show Bash(rm *) does not match /bin/rm ... or bash -c 'rm ...'.
  • For a compound command such as npm test && git status, every subcommand must be allowed (or already considered read-only). A rule for npm test alone does not approve the whole line.

The current docs say rules are checked in this order: deny, ask, allow. An open Anthropic GitHub issue (2026) reports that a cd … && grep … form prompted in Claude Code 2.1.259 when a Read() deny rule was present. That is a user report, not a general rule or a replacement for the current docs. If a rule surprises you, check the command shape, installed version, and /permissions before widening it.

Which Claude Code permission mode should I use?

Use a mode for the session’s interaction style, then use rules to narrow individual tools and commands. The mode does not replace your allow, ask, and deny lists. These modes and their limits come from the Anthropic permissions guide (2026).

ModeWhat it doesGood fit
defaultPrompts the first time a tool needs approval; the CLI labels it ManualDay-to-day interactive work
acceptEditsAccepts edits and common file operations in working directoriesSupervised editing when you want fewer edit prompts
planReads files and runs read-only exploration without editing source filesPlanning before you approve changes
autoUses a background classifier to review actions where availableA supported interactive session where you want fewer routine prompts
dontAskDenies calls that would otherwise need a prompt; still permits allowed rulesHeadless runs that should stop at the edge of their allow list
bypassPermissionsSkips permission prompts, with exceptions; Anthropic says to use it only in an isolated container or VMIsolated environments only

You can set a starting mode with defaultMode in a settings file, or choose one for a single command with claude --permission-mode plan. In the terminal, /config changes the default mode and /permissions manages rules. For background on bypass mode, see our guide to using dangerously skip permissions safely.

How do I stop Claude Code asking for the same command?

To always allow a command, add the exact command you keep approving to permissions.allow, at the narrowest scope where you need it. If the command changes often, use * only for the part that varies and confirm the neighboring commands it matches.

This allows the project’s test script but not package installation:

json
{
	"permissions": {
		"allow": ["Bash(npm run test)"]
	}
}

/permissions lists each active rule and the settings.json file it came from (Anthropic permissions guide (2026)). You can also approve a repeated Bash command from a permission prompt with “Yes, and don’t ask again”; Claude Code normally saves that rule to .claude/settings.local.json. That is convenient for a personal repeat command, but inspect the generated pattern before relying on it.

What should I put in settings.json for solo development?

For a cautious solo setup, keep your default mode interactive, allow the few exact checks you repeat, and deny local environment files from the file-reading tool. Put this profile in .claude/settings.local.json if it should apply only to you in this checkout; use ~/.claude/settings.json if you want the same rules in every project.

json
{
	"permissions": {
		"defaultMode": "default",
		"allow": ["Bash(npm run lint)", "Bash(npm run test)"],
		"deny": ["Read(./.env)", "Read(./.env.*)"]
	}
}

The allow entries silence repeat prompts only for these two command strings. The deny entries cover reads of .env and .env.* under the current directory. Check for other secret filenames your project uses and add explicit path rules when needed.

Read and Edit deny rules also apply to the Bash file commands Claude Code recognizes, such as cat, head, tail, sed and tee, and to redirection targets. They do not stop a Python or Node script, or a command such as grep -r pattern ., that reads files without naming them.

How do I configure Claude Code permissions for CI?

In headless CI, use dontAsk and allow only the commands and file tools that the job needs. An unapproved action is denied instead of prompting a person, so the run can fail visibly when it reaches an action outside the profile. Anthropic documents dontAsk as an auto-deny mode for calls that would otherwise prompt (permissions guide, 2026).

For a disposable checkout where Claude is meant to edit files and run the project checks, put this in the CI job’s .claude/settings.local.json or an equivalent generated settings file:

json
{
	"permissions": {
		"defaultMode": "dontAsk",
		"allow": [
			"Edit",
			"Write",
			"Bash(npm run lint)",
			"Bash(npm run test)",
			"Bash(git diff --check)"
		],
		"deny": ["Read(./.env)", "Read(./.env.*)"]
	}
}

Start it with a prompt, for example:

sh
claude -p --permission-mode dontAsk "Fix the failing test and run the allowed checks"

This example is documentation-only. Replace the commands with the exact scripts your job uses; don’t turn Bash(npm run *) into a shortcut if the job should not install or invoke arbitrary package scripts. Allowing Edit and Write permits file-tool changes across the checkout, so use a disposable branch or worktree and keep credentials out of it.

For finer one-run control, --allowedTools adds tools that can run without a prompt; --disallowedTools adds deny rules. Neither makes broad Bash patterns a sandbox. For CI-specific project context, see the Octomind workflow comparison.

How should a team share Claude Code permissions?

Commit a reviewed .claude/settings.json for team defaults, and leave per-developer exceptions in .claude/settings.local.json. Keep the shared file short enough that a teammate can understand every command it authorizes.

json
{
	"permissions": {
		"defaultMode": "default",
		"allow": ["Bash(npm run lint)", "Bash(npm run test)"],
		"ask": ["Bash(git commit *)"],
		"deny": ["Read(./.env)", "Read(./.env.*)", "Bash(git push *)"]
	}
}

A different spelling such as git -C . push may not match that Bash pattern, so do not treat it as an OS-level block. Teammates should review and trust project settings before accepting permissions; organization-wide policy belongs in managed settings, which admins deploy.

Why is Claude Code still prompting after I added an allow rule?

First inspect /permissions, then check the command form and the file Claude Code loaded. The active rule may differ from the pattern you expected, or a deny/ask rule may take precedence.

  1. Run /permissions and look for the rule and its source file. Run /status to see the settings sources loaded for this session; the Anthropic settings guide (2026) explains what each shows.
  2. Compare the full command with the matcher. Bash(npm run test) does not match npm run test --watch; Bash(npm run *) may match more than you intend.
  3. Check whether the line has multiple shell commands. Every piece of a compound command needs approval.
  4. Look for a matching deny or ask rule in another scope. Permission lists merge, and deny/ask decisions outrank allow.
  5. If a new settings value is ignored, run claude doctor for malformed or skipped entries. Most permission edits reload in a running session, but organization settings delivered through MDM or the Claude console can arrive on a schedule (Anthropic settings guide, 2026).

If you only need permission to inspect files in another directory, add it as a working directory with --add-dir <path> or permissions.additionalDirectories (Anthropic CLI reference, 2026); don’t broaden unrelated command rules. For wider guardrail design beyond Claude Code, see our guide to locking down AI agent permissions.

Keep default, allow exact repeat commands, deny files Claude should not read, and check /permissions when the behavior differs from the file you edited. Claude Code’s rules reduce prompts; they are not a complete filesystem or process sandbox, as the Anthropic permissions guide (2026) explains.

Related reading: Claude Code workflows · Lock down AI agent permissions