[FEATURE] Allow prompt hooks to approve commands, otherwise ask user
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 want to have an LLM evaluate proposed tool usages to see if they are read-only. If they are read-only, I want it to auto-approve them. If they are not, then I want Claude Code to go through its 'normal' permission request flow.
At present, I can use a prompt PreToolUse hook to approve / deny, but I cannot support this escalation flow without workarounds (see below).
This is similar to #3990 , but the fix for that did not include support for prompt hooks.
Proposed Solution
I'm sure there are a number of potential solutions here, but the first that comes to mind for this particular use case would be a third outcome of ask or undefined rather than just true or false for relevant hooks -- meaning escalation to the user rather than an outcome.
Alternative Solutions
Currently, I work around this by using a command type hook that invokes the LLM itself; this is a) a bit annoying b) requires a separate api key, which is annoying when using OAuth
current hook is:
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "/path/to/check-destructive.sh",
"timeout": 15
}
]
}
with command: check-destructive.sh
Priority
Medium - would be very helpful
Feature Category
CLI commands and flags
Use Case Example
I want to set CC off on a long-ish running task where it may need to pull information from a variety of systems (e.g., trigger a preview deployment, make some requests against it, pull logs -> repeat). I don't want to have to --dangerously-skip-permissions every time, but I want the agent to be smart enough to know that it doesn't need to ask me to run head -30 on log output.
Additional Context
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗