Bug: Claude CLI non-interactive mode doesn't respect configured tool permissions
Status Fixed / completed
Maintainer reply ✓ Yes — rboyce-ant
Activity 13 comments · opened Mar 21, 2025 · closed Jun 20, 2025
💡 Likely answer: A maintainer (rboyce-ant, contributor)
responded on this thread — see the highlighted reply below.
Bug: Claude CLI non-interactive mode doesn't respect configured tool permissions
Description
When using Claude CLI in non-interactive mode with the -p flag to run bash commands, Claude requests permission to use the Bash tool even though permissions are already configured. The same commands run without any permission issues in interactive mode.
Steps to Reproduce
- Configure Claude CLI with Bash tool permissions (already done, see config below)
- Run this command:
````
claude -p "npm run build and git commit and git push"
- Observe the error message: "I need permission to use the Bash tool to run these commands. Once granted, I'll build the project and commit the changes."
Expected Behavior
Claude should recognize the pre-configured Bash tool permissions and execute the commands without requesting additional permissions, just as it does in interactive mode.
Actual Behavior
Claude asks for permission to use the Bash tool despite the tool being listed in the allowed tools configuration.
Configuration
{
"allowedTools": [
"Bash",
"Create",
"Edit",
"Read",
"Write"
],
"dontCrawlDirectory": false,
"hasTrustDialogAccepted": "true",
"hasCompletedProjectOnboarding": "true",
"ignorePatterns": []
}
Additional Information
- The exact same command sequence works perfectly when used in interactive mode
- Command used:
claude -p "npm run build and git commit and git push" - Claude CLI version: [Include your version here]
- Operating System: [Include your OS here]
- This issue started occurring after a recent update (within the last few updates)
- The functionality used to work correctly in previous versions
Impact
This issue prevents using Claude CLI effectively in scripts or automated workflows where interactive mode isn't feasible.
13 Comments
$ claude -p "echo 'Hello World' > test.txt && cat test.txt"I'll need permission to use the Bash tool to execute that command. Once granted, I'll create the test.txt file with "Hello World" and display its contents.
I ran into the same issue a couple of days ago (see #563 )
As it turns out, Claude Code does not use the allowed tools as defined in the configs when running in non-interactive mode. You have to pass the allowed tools to the command with the --allowedTools flag followed by a comma separated list of your required tools - like so:
claude -p "npm run build and git commit and git push" --allowedTools "Bash(git:*),Edit"Legend @TomDigitalDavid that gets me going :) I always just did
claude config set hasCompletedProjectOnboarding true
claude config set hasTrustDialogAccepted true
claude config add allowedTools Bash
claude config add allowedTools Read
claude config add allowedTools Write
claude config add allowedTools Edit
claude config add allowedTools Create
I cannot get this to work. Trying to get a global config that will remove the endless interruptions.
Hi all, I've verified that permission rules
.claude/settings.jsonare respected when runningclaude -p. Please ensure that your settings are configured properly: https://docs.anthropic.com/en/docs/claude-code/settings#settings-files@rboyce-ant This isn't working when not running in
-p- claude keeps asking me for permission on every curl command it wants to run. I just want to let it cook!@rboyce-ant I'm still seeing this exactly as described by the OP. The issue is as described in https://github.com/anthropics/claude-code/issues/1188. Although
.claude/settings.jsonis being read, permissions are ignored where patterns are used.So this works:
But this doesn't:
@rboyce-ant I am finding similar results to the other reporters. Claude Code works fine for me in interactive mode, but in non-interactive mode:
.claude\settings.local.jsonhas:I am still seeing the same issue as OP. In non-interactive mode:
This works
claude -p "create a file called add.py that adds two numbers" --output-format json --allowedTools WriteThis doesn't work
claude -p "create a file called add.py that adds two numbers" --output-format json --allowedTools Write(/**)@rboyce-ant can you please reopen this issue? There have been multiple independent reproductions of the issue since you closed it.
I am having the exact same issue, which prevents me from restricting where Claude Code can write. Just allowing Write seems a bit risky to me.
Definitely not fixed. But this specific case with path patterns is covered in #1188
MCP settings are also not respected. It picks up the global settings, but does not allow passing in mcpSettings.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.