Feature Request: Expose Active Permission Mode to Hooks and Statusline
Feature Request: Expose Active Permission Mode to Hooks and Statusline
Labels: feature-request, enhancement, hooks, statusline
Is your feature request related to a problem? Please describe.
Currently, external scripts used for Hooks and the custom Status Line have no way to determine the active permission mode of the current Claude Code session.
The permission mode (default, acceptEdits, plan, or bypassPermissions) is a critical piece of session context that dictates the agent's security posture and capabilities. The JSON payload sent to these scripts contains a wealth of session information but omits this key detail, which prevents the creation of more intelligent, context-aware integrations.
This limitation means it's impossible to:
- Display the current mode in the status line for better user situational awareness (e.g., showing a
[PLAN]or[BYPASS]indicator). - Create smarter hooks that modify their behavior based on the active mode (e.g., a
PreToolUsehook that auto-approves a safe tool only if the session is inacceptEditsmode).
Describe the solution you'd like
I propose adding a new field, activePermissionMode, to the JSON payload sent via stdin to all relevant hook and status line scripts.
This field should reflect the actual, active permission mode for the session, accounting for the entire settings precedence hierarchy, including the default setting from settings.json and any temporary command-line overrides (e.g., claude --permission-mode plan).
The value should be a string literal matching one of the modes defined in the IAM documentation: "default", "acceptEdits", "plan", or "bypassPermissions".
Example: Proposed JSON Payload Changes
Here is how the input schemas for a PreToolUse hook and the Status event would be enhanced:
PreToolUse Hook Input:
// Current
{
"session_id": "abc123",
"transcript_path": "/path/to/transcript.jsonl",
"cwd": "/path/to/project",
"hook_event_name": "PreToolUse",
"tool_name": "Write",
"tool_input": { ... }
}
// Proposed
{
"session_id": "abc123",
"transcript_path": "/path/to/transcript.jsonl",
"cwd": "/path/to/project",
"hook_event_name": "PreToolUse",
"tool_name": "Write",
"tool_input": { ... },
"activePermissionMode": "plan" // <--- NEW FIELD
}
Status Line Script Input:
// Current
{
"hook_event_name": "Status",
"session_id": "abc123...",
"cwd": "/current/working/directory",
"model": { ... }
}
// Proposed
{
"hook_event_name": "Status",
"session_id": "abc123...",
"cwd": "/current/working/directory",
"model": { ... },
"activePermissionMode": "bypassPermissions" // <--- NEW FIELD
}
Describe alternatives you've considered
The only available workaround is for a script to manually parse the defaultMode from the project's or user's .claude/settings.json file.
However, this workaround is insufficient and unreliable because it cannot detect temporary, session-specific overrides set via the --permission-mode command-line flag. A user could launch a session with claude --permission-mode plan, and the script would have no way of knowing the active mode is plan instead of the one defined in the settings file.
The only robust solution is for Claude Code to expose the true, resolved session state directly in the payload.
Additional Context & Use Cases
This small but high-impact change would unlock several powerful use cases:
- Informative Status Line for Situational Awareness: Users could create a status line that provides at-a-glance visibility into the agent's current security posture.
- Example display:
[Opus | my-project] 📝 PLAN MODE - Example display:
[Sonnet | my-project] ⚠️ BYPASS
- Context-Aware Hooks: Hooks could implement more nuanced and dynamic logic based on the user's intent for the session.
- A
PreToolUsehook for theEdittool could be configured to automatically return{"permissionDecision": "allow"}but only ifactivePermissionModeisacceptEdits. - A security-focused logging hook could record actions with a higher level of scrutiny or send an alert when a tool is used in
bypassPermissionsmode. - A
UserPromptSubmithook could warn the user if they ask for file modifications while inplanmode, providing instant feedback.
- Richer Auditing: A
PostToolUsehook could log all tool executions with the active permission mode, providing a more complete audit trail for compliance and security monitoring.
Adding this single field would significantly enhance the power and utility of Claude Code's extensibility features. Thank you for your consideration.
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗