Skip to content

Feature request: Add hooks for plan mode transitions (EnterPlanMode/ExitPlanMode) #21282

Description

@sgbett

Summary

Plan mode transitions (EnterPlanMode and ExitPlanMode tools) are completely invisible to the hooks system. There's no way to hook into plan mode entry or exit.

Current Behaviour

When investigating with --debug, we found:

  1. PreToolUse/PostToolUse hooks don't fire for EnterPlanMode or ExitPlanMode - only regular tools like Bash, Write, Read trigger these hooks
  2. Stop hook fires but with no context - query: undefined provides no way to distinguish plan mode exit from other stop events
  3. Debug log shows no plan mode events - the log jumps straight from SessionStart to tool execution with no trace of plan mode

Evidence from debug log

17:25:24 [DEBUG] Getting matching hook commands for SessionStart with query: clear
17:25:28 [DEBUG] executePreToolHooks called for tool: Write

No plan mode events between session start and first tool use, despite plan mode being active.

Hook events that DO fire (for reference)

  • SessionStart
  • PreToolUse (Bash, Write, Read, etc. - but NOT EnterPlanMode/ExitPlanMode)
  • PostToolUse (same)
  • PermissionRequest
  • UserPromptSubmit
  • Stop (but with query: undefined)
  • SubagentStop
  • Notification

Requested Behaviour

Either:

  1. Make plan mode tools fire standard hooks - PreToolUse/PostToolUse with query EnterPlanMode or ExitPlanMode
  2. Add dedicated plan mode hook events - PlanModeEnter and PlanModeExit
  3. Add context to Stop hook - include query: "plan_mode_exit" or similar when exiting plan mode

Use Case

Users want to run custom scripts when plan mode exits, for example:

  • Automatically presenting the plan for review
  • Triggering notifications
  • Logging plan mode usage
  • Integrating with external workflow tools

Environment

  • Claude Code version: 2.1.20
  • OS: macOS

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions