[FEATURE] Built-in tool for consecutive bash commands for better allow-listing
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
I don't usually run Claude Code in yolo-mode, but I like it to be more autonomous, so I try to allow-list as many commands as I can.
I quite commonly see Claude Code do something like Bash(do something && echo "it worked") or Bash(git add foo.md && git add bar.md) or Bash(do something || echo "it failed").
Similarly, it often does things like Bash(for x in a b c do something) where something may be allow-listed.
Combined commands like this seem to work badly with the allow-listing permission system - and understandably so, we would not want allowing Bash(git status:*) to allow Bash(git status && rm -rf something-we-dont-want-to-remove) for obvious reasons.
Proposed Solution
The logic at hand is fairly simple -- "do something and then do another thing" or "do something and if it fails, do another thing" or "do something with these n parameters". And Claude Code seems to prefer doing that in a single command, rather than in multiple commands, partially by necessity, e.g. for the case of only doing the second thing if the first thing succeeded/failed.
Perhaps, if Claude Code had built-in tools that encode this logic, such as "chained bash" or so, it would use those directly.
And provided the commands do not pipe any content between them, and only depend on each other's exit code, I think the permissions from the allow list could be checked for each part individually, rather than for the entire command, which should make allow-listing more reliable.
Alternative Solutions
_No response_
Priority
Medium - Would be very helpful
Feature Category
Configuration and settings
Use Case Example
_No response_
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗