Feature Request: Non-blocking PreToolUse hooks that inject context to Claude

Resolved 💬 3 comments Opened Nov 28, 2025 by FabianHertwig Closed Dec 2, 2025

Summary

I would like PreToolUse hooks to have an option to inject a message/context to Claude (the model) while still allowing the tool to execute (non-blocking).

Current Behavior

Based on the documentation and testing:

  • Exit code 0: Command executes, but stdout/JSON output is only shown to the user in verbose mode - Claude does not see it
  • Exit code 1: Command executes (non-blocking), stderr shown to user in verbose mode - Claude does not see it
  • Exit code 2: Command is blocked, stderr is shown to Claude - but this prevents execution

The permissionDecisionReason field with permissionDecision: "allow" is explicitly documented as "shown to the user but not to Claude."

Desired Behavior

A way for PreToolUse hooks to:

  1. Allow the tool to execute (non-blocking)
  2. Inject a message/context that Claude sees before or alongside the tool result

Use Case

I want to remind Claude to run quality checks (linting, type checking, tests) before creating PRs or pushing code. The ideal flow would be:

  1. Claude attempts git push or gh pr create
  2. Hook triggers and injects a reminder: "Have you run npm run lint:format and npm run check?"
  3. Command still executes (or Claude can choose to run checks first based on the reminder)
  4. Claude sees the reminder and can make an informed decision

Currently, I can only:

  • Block the command entirely (exit 2) - but this requires re-running the command after Claude acknowledges
  • Show a message to the user only (exit 0/1) - but Claude doesn't see it and can't act on it

Proposed Solution

One of these approaches:

  1. A new exit code or JSON field that means "allow execution but inject this message to Claude's context"
  2. Extend hookSpecificOutput to support a claudeMessage field that gets injected to Claude regardless of permission decision
  3. Allow permissionDecisionReason to optionally be shown to Claude with a flag like showToClaude: true

Environment

  • Claude Code CLI
  • macOS

View original on GitHub ↗

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