[FEATURE] Support additionalContext in PreToolUse hooks

Status Fixed / completed
Maintainer reply None cached
Activity 7 comments · opened Dec 25, 2025 · closed Jan 16, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

PostToolUse hooks support additionalContext to inject information into Claude's context after a tool runs. However, PostToolUse only fires when a tool completes successfully - it doesn't run when commands fail.

This is problematic for "first-use documentation injection" patterns where you want to show Claude the docs for a CLI tool the first time it's used. If the user runs mytool hello and hello isn't a valid subcommand (exit code 2), the PostToolUse hook never fires and Claude never sees the documentation that would help it understand the correct usage.

Proposed Solution

Add additionalContext support to PreToolUse hooks, matching the PostToolUse behavior:

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "additionalContext": "Documentation or context to inject for Claude"
  }
}

This would allow hooks to inject context before the tool runs, ensuring Claude sees the information regardless of whether the command succeeds or fails.

Alternative Solutions

  1. Make PostToolUse fire on failure too - Could add a config option like "runOnFailure": true, but this changes existing behavior
  2. Have CLI tools print docs on error - Requires per-tool changes and clutters stderr
  3. Accept the limitation - But this defeats the purpose of first-use documentation injection

Priority

Medium - Enables important hook use cases

Feature Category

Hooks

Use Case Example

I have a hook that detects first-time use of CLI tools and injects their documentation (via clocki command structure + quick guide). Currently:

# First call - command fails, PostToolUse doesn't run, no docs injected
$ saffi hello
Error: No such command 'hello'.
# Claude doesn't see the saffi documentation

# Second call - command succeeds, but first-use already "spent"
$ saffi --help
# Now PostToolUse fires, but it's not first-use anymore

With PreToolUse additionalContext support:

# First call - PreToolUse injects docs BEFORE command runs
$ saffi hello
# Claude already has saffi docs, can suggest correct usage
Error: No such command 'hello'.

Additional Context

Current PreToolUse output options per documentation:

  • permissionDecision: allow/deny/ask
  • permissionDecisionReason: shown to user only, NOT to Claude
  • updatedInput: modify tool input

The permissionDecisionReason explicitly does NOT get shown to Claude, so there's currently no way to inject context in PreToolUse.

View original on GitHub ↗

7 Comments

github-actions[bot] · 8 months ago

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/6965

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

cool-RR · 8 months ago

The bot flagged #6965 as a duplicate, but that issue was auto-closed due to inactivity and is now locked. Keeping this open as the feature was never implemented or addressed.

tinyrah · 8 months ago

Hopefully this gets added. Just ran into this. I wanted to inject relevant context whenever CC is editing files in specific directories, and for now am trying to do it with a PostToolHook that triggers after reads. Would be way cleaner if PreTool supported additional context.

coygeek · 7 months ago

Feature was implemented in v2.1.9.
-Added support for PreToolUse hooks to return additionalContext to the model

👍

cool-RR · 7 months ago

Woohoo! Thank you Claude Code team!

coygeek · 7 months ago

Indeed.
I requested this feature as well (above).
I also tweeted to Anthropic employees as well...which I hope helped to push it to the top of the list.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.