claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[Feature Request] PreToolUse approve and don't ask again in this session

Open ksarangmath opened this issue 1 year ago • 4 comments

Currently, the PreToolUse hook output allows the following:

{ "decision": "approve" | "block" | undefined, "reason": "Explanation for decision" }

I would like the option for the decision to be "approveSessionUse", similar to how when the user prompted for a tool use, they get the option of "Yes, and don't ask again this session".

The current workaround is to add an entry to .claude/settings.local.json in the permissions section, but claude code does not refresh its knowledge of that file while it's running. It requires a restart of Claude Code (side-note, it would be nice if claude code could read from that file realtime!).

This would enable a more native-like experience with external claude code clients.

ksarangmath avatar Jul 12 '25 07:07 ksarangmath

Hey,

Thanks for the detailed feature request and for clearly outlining your use case! This is a really thoughtful suggestion for improving the programmatic control over claude-code, especially for building custom clients and automations.

You are absolutely correct in your analysis. Based on the latest documentation, the PreToolUse hook is designed to make a decision on a per-instance basis for a tool call, not to grant permission for the entire session.

Current PreToolUse Hook Behavior

As you've noted, the current implementation allows you to programmatically allow, deny, or ask for a specific tool invocation. The documentation has recently been updated to a permissionDecision format, which you might find useful:

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "allow" | "deny" | "ask",
    "permissionDecisionReason": "Auto-approved read-only command."
  }
}

This is great for single approvals but, as you pointed out, doesn't have an option analogous to the UI's "Yes, and don't ask again this session."

Your Proposed Feature: Session-Level Approval

I think adding a new behavior like "permissionDecision": "allow_session" would be a fantastic enhancement. It would bridge the gap between the interactive user experience and what's possible for developers using hooks for automation, enabling the kind of native-like experience you're looking for.

Workaround & Hot-Reloading

Your workaround of programmatically modifying .claude/settings.local.json is clever and is currently the only way to persist a permission change.

Regarding your side-note about hot-reloading settings files: the documentation on hooks gives some insight into why this might not be the current behavior. Under the "Security Considerations" section in the Hooks reference, it mentions:

Claude Code captures a snapshot of hooks at startup and uses this snapshot throughout the session... This prevents malicious hook modifications from affecting your current session.

It seems this design choice was made for security, ensuring that the rules of a session can't be changed on the fly from an external process. While hot-reloading would be convenient for development, this security-first approach makes sense.

Again, this is a great suggestion that would definitely improve the power of hooks. While I'm not part of the Claude Code team, I hope the developers see this and consider it for a future release

coygeek avatar Aug 24 '25 19:08 coygeek

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 07 '25 10:12 github-actions[bot]

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] avatar Jan 07 '26 10:01 github-actions[bot]

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.

github-actions[bot] avatar Jan 15 '26 14:01 github-actions[bot]