Feature request: blocking acknowledgment hook for /clear (and other slash commands)

Open 💬 0 comments Opened Jun 10, 2026 by skulas

Summary

Add support for a hook that can block /clear (and other slash commands) until the user explicitly acknowledges — enabling workflows like \"did you update your notes/memory before clearing context?\".

Motivation

The current Stop hook fires when Claude stops (including on /clear), but:

  • It cannot reliably block the clear action — continue: false is designed to keep Claude talking, not to gate a user-initiated command.
  • There is no PreToolUse-style intercept for slash commands; they are handled by the CLI before reaching the hook layer.

This means there's no way to build a \"confirm before clearing\" gate today. The only option is a non-blocking reminder message, which is a nudge but not a hard stop.

Proposed solution

One or more of the following:

  1. A new hook event — e.g. PreSlashCommand (or PreClear, PreCompact) — that fires before a slash command executes and supports continue: false to abort it with a user-facing message.
  1. Interactive hook support — allow command-type hooks to read from the terminal (stdin/tty) so a hook can present a y/N prompt and conditionally block based on the answer.
  1. Extend UserPromptSubmit to also fire for slash commands, with continue: false aborting execution before the command runs.

Example use case

{
  "hooks": {
    "PreClear": [{
      "hooks": [{
        "type": "command",
        "command": "printf 'Updated skills/memory? (y to proceed): ' > /dev/tty && read -r a < /dev/tty && [[ \"$a\" == y ]] || echo '{\"continue\": false, \"stopReason\": \"Update skills/memory first, then /clear again.\"}'"
      }]
    }]
  }
}

Current workaround

A Stop hook with a systemMessage reminder — shown at clear time but non-blocking.

🤖 Generated with Claude Code

View original on GitHub ↗