Skip to content

[BUG] --allowedTools no working reliably #563

@TomDigitalDavid

Description

@TomDigitalDavid

Environment

  • Platform (select one):
    • Anthropic API
    • AWS Bedrock
    • Google Vertex AI
    • Other:
  • Claude CLI version: 0.2.49
  • Operating System: Windows (Windows Server 2022 Datacenter)
  • Terminal: WSL2

Bug Description

I am trying to run Claude Code from a script using a command like claude -p "test the application and fix any errors you encounter" --allowedTools "Bash(dotnet:*)" Edit.
Claude Code will always reply that it needs permissions for the Edit tool, when it encounters an error. When prompting Claude Code to simply edit a file with the same --allowedTools specification it can edit files.

Steps to Reproduce

  1. Open WSL terminal in a .NET project
  2. Prompt it something like claude -p "test the application and fix any errors you encounter" --allowedTools "Bash(dotnet:*)" Edit
  3. It runs the tests and then you get a reply that it needs permissions to edit files (if it encounters errors)
  4. Prompt something like claude -p "Check which files you have access to and give me list of the files' names. Then write 'test' at the end of README.md. If you require permissions stop your task and reply with a message explaining what permissions you need." --allowedTools Edit
  5. Result: Claude Code can execute Bash (ls) and edit the file.

Expected Behavior

I would expect Claude Code to work the same in interactive mode and non-interactive mode, i.e. either use the allowedTools as defined in the project's claude config or correctly apply the --allowedTools flag with its parameters.
When using --allowedTools I expect Claude Code to use all tools defined with the command.

Actual Behavior

Claude Code cannot use all tools that were defined with --allowedTools

Additional Context

I'm running Claude Code in WSL on a virtual machine.
I played around with different prompts and different --allowedTools configurations. I could not find an explanation as to why this happens. When giving Claude Code a task like claude -p "Write 'hello' to README.md" --allowedTools Edit it worked. The same when I used a prompt that required it to run a bash command like "ls" and then edit a file.
I also added more allowed tools to the prompt and it still worked. Somehow, it failed once the prompt got a bit more complex, i.e. run "dotnet test" and then, if there are error during the build, editing files.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions