Feature Request: Short-circuit hooks to bypass LLM evaluation

Resolved 💬 2 comments Opened Jan 20, 2026 by sparkling Closed Feb 28, 2026

Summary

Add the ability for UserPromptSubmit hooks to short-circuit the LLM pipeline and return a response directly, bypassing LLM evaluation entirely.

Use Case

Custom slash commands that are purely local operations (no LLM reasoning needed):

  • /sl n - switch statusline template (7ms operation)
  • /timer start - start a local timer
  • /env show - display environment info
  • /git status - run git status directly

Currently these go through the full LLM pipeline (~2-3 seconds) even when a hook could handle them in milliseconds.

Proposed Solution

Add a shortCircuit option to hooks:

{
  "UserPromptSubmit": [
    {
      "matcher": "^/sl( |$)",
      "hooks": [
        {
          "type": "command",
          "command": ".claude/sl.sh \"${PROMPT#/sl }\"",
          "shortCircuit": true
        }
      ]
    }
  ]
}

When shortCircuit: true:

  1. Hook runs and captures stdout
  2. If hook exits 0, display stdout as the response and skip LLM
  3. If hook exits non-zero, continue to LLM as normal

Alternative: Exit code based

Use exit codes to signal short-circuit:

{
  "hooks": [
    {
      "type": "command", 
      "command": "...",
      "shortCircuitOnExit": 0
    }
  ]
}

Benefits

  • Performance: 7ms vs 2-3 seconds for simple operations
  • Cost: Zero tokens for handled commands
  • Flexibility: Users can create instant local commands
  • Extensibility: Enables powerful automation without LLM overhead

Current Workaround

Hooks run but do not block LLM - the operation completes fast but user still waits for LLM response acknowledging it was already done.

Environment

  • Claude Code CLI
  • Hooks system (UserPromptSubmit, PreToolUse, etc.)

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗