[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_
4 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
amended initial issue -- #3990 is similar but for
commandrather thanprompthooks. Bringing this same functionality to theprompthooks is exactly what I'm getting at.closing, auto mode will solve this
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.