To stop Claude Code from asking about a command, add an allow rule such as Bash(npm test) or Bash(npm run *) to permissions.allow in settings.json, or pick "Yes, and don't ask again" on the prompt. Keep rules narrow, put the wildcard after the subcommand, and never allow broad patterns like Bash(git *) or Bash(curl *).
In Claude Code, you allow a command by adding an allow rule for it, such as Bash(npm test), to the permissions.allow list of a settings file. Claude Code then runs matching commands without a permission prompt. The trick is to allow the routine commands you run fifty times a day and nothing that can delete, publish or leak.
This guide shows the three ways to add rules, how the matching works, a starter allowlist, and the patterns to avoid. For the full permission system, see the complete guide to Claude Code permissions.
Which commands does Claude Code already allow?
Claude Code already runs a built-in set of read-only commands without asking, in every mode. The set includes ls, cat, echo, pwd, head, tail, grep, find, wc, which, diff, stat, du, cd and read-only forms of git such as git status.
So you do not need an allow rule for git status or ls. There are exceptions where even these commands prompt in Manual mode, for example a cd into another directory combined with git, or a command Claude Code cannot fully parse. Your allowlist is for everything else: tests, builds, linters, formatters and commits.
How do I allow a command in Claude Code?
You have three ways to allow a command in Claude Code, and they all end up as the same kind of rule.
- From the prompt. When Claude Code asks about a Bash command, choose "Yes, and don't ask again". Claude Code saves an allow rule to
.claude/settings.local.jsonat the root of your git repository, so it applies to future sessions in that repository. - With
/permissions. Run/permissionsin a session to see every rule and which file it comes from, and add or remove rules there. - In a settings file. Edit
permissions.allowdirectly. This is the best option when you want to review the whole list at once or share it with a team.
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [
"Bash(npm test)",
"Bash(npm run lint)",
"Bash(npm run test *)"
]
}
}For a single session, you can also pass rules on the command line with --allowedTools:
claude --allowedTools "Bash(git log *)" "Bash(git diff *)" "Read"Settings files are strict JSON, so a trailing comma or a // comment is a syntax error. After saving, run /status to confirm the file loaded.
Which settings file should my allowlist go in?
Put personal habits in your user file, team conventions in the shared project file, and one-off exceptions in the local file. Claude Code merges the allow lists from all of them.
| File | Use it for |
|---|---|
~/.claude/settings.json | Commands you trust in every project, such as your formatter |
.claude/settings.json (committed) | The project's test, lint and build scripts, shared with the team |
.claude/settings.local.json | Personal rules for one project; this is where "don't ask again" writes |
Allow rules in a committed .claude/settings.json only apply after each person accepts the workspace trust dialog for the folder. The settings.json reference has more on each file.
How does Claude Code match an allow rule?
A Claude Code Bash rule matches the whole command text, with * standing for any text including spaces. Without a *, the rule matches one exact command.
| Rule | Matches | Does not match |
|---|---|---|
Bash(npm test) | npm test | npm test -- --watch |
Bash(npm run *) | npm run build, npm run test --watch, npm run | npm install |
Bash(git log *) | git log, git log --oneline | git push |
Bash(ls *) | ls -la, ls | lsof |
Three rules from the docs explain most surprises:
- Put the
*after the subcommand.Bash(git log *)allows onlygit log.Bash(git *)allows every git command, including ones that rewrite history or push. Claude Code warns at startup about an allow rule with a*before the subcommand. - A trailing
*also matches the bare command.Bash(npm run *)matchesnpm runwith no arguments. - The space matters.
Bash(ls *)does not matchlsof, butBash(ls*)does.
Compound commands are split. A rule for Bash(npm test *) does not approve npm test && rm -rf dist: every part of the command must be allowed on its own. Claude Code also strips a few wrappers first (timeout, time, nice, nohup, stdbuf, command, builtin, noglob), so Bash(npm test *) also matches timeout 30 npm test.
What is a safe Claude Code allowlist?
A safe Claude Code allowlist covers commands that are local, repeatable and easy to undo: running tests, linting, formatting, type checking and reading git history. Here is a starting point for a Node project:
{
"permissions": {
"allow": [
"Bash(npm test)",
"Bash(npm run test *)",
"Bash(npm run lint *)",
"Bash(npm run typecheck)",
"Bash(npm run build)",
"Bash(npx prettier --check *)",
"Bash(git diff *)",
"Bash(git log *)",
"Bash(git show *)",
"Bash(git add *)",
"Bash(git commit *)"
],
"ask": [
"Bash(git push *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
]
}
}Adapt the script names to your project (pnpm, cargo test, pytest, go test ./...). The ask rule for git push is deliberate: because Claude Code evaluates deny, then ask, then allow, an ask rule always prompts even if a broader allow rule also matches.
Note that npm run * runs whatever is in your package.json scripts. That is fine in your own repository, but it means a change to package.json changes what the rule allows.
Which commands should you never allow?
Never allow a command that can destroy data, reach the network freely, publish something, or run arbitrary code passed as an argument. These are the patterns to keep out of permissions.allow:
| Rule to avoid | Why |
|---|---|
Bash or Bash(*) | Allows every shell command |
Bash(git *) | Includes git push, git reset --hard, and git -c which can run a program |
Bash(rm *) | Deletes files with no undo |
Bash(curl *), Bash(wget *) | Network access to any URL, the classic exfiltration path |
Bash(npx *), Bash(docker exec *) | Runs whatever comes after it |
Bash(npm publish *), deploy scripts | Publishes or ships code |
Bash(sudo *) | Root access |
Environment runners deserve a note. The docs warn that tools like devbox run, mise exec, npx and docker exec run their arguments as a command, so Bash(devbox run *) also matches devbox run rm -rf .. Write one specific rule per inner command instead, such as Bash(devbox run npm test).
Also remember that allowing a tool with * before a fixed argument does not restrict the URL or path the way you might expect. The docs show that Bash(curl http://github.com/ *) misses curl -X GET http://github.com/... and redirects. For network limits, deny curl and wget, use WebFetch(domain:github.com) rules, and consider the sandbox.
Why does Claude Code still ask after I allowed a command?
Claude Code still prompts after an allow rule when something with higher priority matches, or when the command does not match the rule as written. The most common causes:
- An
askordenyrule in another settings file matches the same command. Ask and deny are evaluated before allow. - The command is compound, and one part is not allowed.
- The
*is in the wrong place, or there is an extra flag your exact-match rule does not cover. - The rule is in a committed project file and you have not accepted workspace trust.
- The command starts with an exec wrapper like
watch, or is afindwith-deleteor-exec. A prefix rule cannot approve these; write an exact-match rule instead.
The guide to why Claude Code keeps asking for permission walks through each fix in order.
Answering the rest from the menu bar
A good allowlist removes the routine prompts. What remains are the commands you actually want to look at: a push, a migration, a dependency install. Those still need your answer, and they are easy to miss when Claude Code is waiting in a background terminal tab.
Allowbar is a Mac menu bar app that shows those remaining prompts at the top of the screen. It connects through Claude Code's own hooks; when the agent asks to run a command, a panel slides down with the project, the tool and the exact command, and you click Allow, Block or Terminal. Commands your allow rules already cover never show up, and Allowbar never approves anything on its own. If you do not answer in time or the app is closed, the question goes back to the terminal.
Allowbar runs on macOS 14 or later and supports Claude Code and Codex. It is in private beta. Join the waitlist; the launch price is $9.99 instead of $29.90.
Sources:
- Configure permissions, Claude Code docs
- Settings files and precedence, Claude Code docs
- CLI reference, Claude Code docs
Frequently asked questions
How do I allow npm test in Claude Code?
Add "Bash(npm test)" to permissions.allow in .claude/settings.json or ~/.claude/settings.json. To also cover extra arguments, use "Bash(npm test *)". You can also choose "Yes, and don't ask again" the next time Claude Code asks.
Do I need to allow git status?
No. git status is part of Claude Code's built-in read-only command set, which runs without a prompt. You only need rules for commands that change things, such as git add or git commit.
What is the difference between Bash(ls *) and Bash(ls:*)?
None. The :* suffix is an equivalent way to write a trailing wildcard, so both match ls and ls -la. The :* form is only recognized at the end of a rule.
Is it safe to allow all Bash commands?
Not on your own machine. Allowing Bash lets Claude Code run anything your user account can, including deleting files and sending data over the network. If you need that, the docs recommend an isolated container or VM, as covered in the dangerously skip permissions guide.
Can I allow a command for one session only?
Yes. Start Claude Code with --allowedTools, for example claude --allowedTools "Bash(npm test)". The rule applies to that session and is not written to any settings file.