brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: scope --allowedTools to single git commands, with a space before the star

Claude
~/tips/tip-claude-allowedtools-scoped-bash

claude -p "Look at my staged changes and create an appropriate commit" \

Lets a scripted Claude Code run use only the git commands you list, without prompting.

Allowing plain Bash to a headless run is a big yes. Allowing four specific git commands is a small one.

--allowedTools lists tools that run without a permission prompt, and it accepts the same rule syntax as your settings. A Bash(...) rule can be narrow.

claude -p "Look at my staged changes and create an appropriate commit" \
  --allowedTools "Bash(git diff *),Bash(git log *),Bash(git status *),Bash(git commit *)"

That commit job can read the diff and commit, and nothing else in the shell. The trailing * matches the command with or without arguments.

My rule of thumb: the more unattended the job, the narrower the list. A prompt that nobody sees cannot be answered, so the list is the whole safety net. Four read and commit commands is a list I can reason about; a bare Bash is a shrug.

The caveat is the space. Bash(git diff *) with a space matches git diff, while Bash(git diff*) without one would also match git diff-index. Also note that this flag only approves tools; to remove tools from Claude’s reach entirely, use --tools or --disallowedTools.

Further reading: Run Claude Code programmatically – Claude Code docs, CLI reference – Claude Code docs, On this site: deny Read(./.env) so Claude never opens your secrets, On this site: scope instructions with paths in .claude/rules

More Claude tips /recap /focus /skill-doctor /autocompact 500k claude purge ~/work/my-repo --dry-run All Claude tips (83) All topics

Link