Feature Request: Add `updatedPrompt` support to `UserPromptSubmit` hook

Open 💬 13 comments Opened Feb 21, 2026 by movingChurch

Summary

PreToolUse hooks support updatedInput to modify tool arguments before execution, but UserPromptSubmit hooks have no equivalent mechanism to modify the user's prompt text before it reaches Claude. This creates an asymmetry in the hook system.

Current Behavior

UserPromptSubmit hooks can:

  • ✅ Read the user's prompt (prompt field in stdin JSON)
  • ✅ Block the prompt entirely (exit code 2)
  • ✅ Add supplementary context (stdout text is appended)
  • ❌ Modify/replace the prompt text itself

Meanwhile, PreToolUse hooks can modify tool inputs via updatedInput:

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "allow",
    "updatedInput": { "command": "modified command here" }
  }
}

Proposed Behavior

Add an updatedPrompt field to UserPromptSubmit hook output, following the same pattern as PreToolUse's updatedInput:

{
  "hookSpecificOutput": {
    "hookEventName": "UserPromptSubmit",
    "updatedPrompt": "transformed prompt text here"
  }
}

Use Cases

  • Automatic context injection: Prepend project-specific context to every prompt
  • Abbreviation/alias expansion: Expand shorthand commands into full instructions
  • Prompt templating: Transform template syntax into full prompts
  • Sensitive data masking: Strip or mask secrets before they reach the LLM
  • Localization/translation: Auto-translate prompts for better model performance
  • Prompt enhancement: Add structured formatting or constraints automatically

Example

#!/bin/bash
INPUT=$(cat)
PROMPT=$(echo "$INPUT" | jq -r '.prompt')

# Expand project-specific aliases and add context
TRANSFORMED="[Project: Node.js/TypeScript, DB: PostgreSQL] $PROMPT"

jq -n --arg p "$TRANSFORMED" '{
  hookSpecificOutput: {
    hookEventName: "UserPromptSubmit",
    updatedPrompt: $p
  }
}'

Rationale

Both PreToolUse and UserPromptSubmit follow the same "intercept before execution" pattern. Since PreToolUse already supports input modification via updatedInput, extending this pattern to UserPromptSubmit with updatedPrompt would be a natural and consistent addition to the hook system.

This is a capability that other AI coding tools (e.g., OpenCode) already support through their plugin systems (chat.message hook, chat.messages.transform), and it would significantly expand what users can build with Claude Code hooks.

View original on GitHub ↗

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