claude-code - 💡(How to fix) Fix [FEATURE] Allow UserPromptSubmit hook to transform message content [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48554Fetched 2026-04-16 06:56:54
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
labeled ×2commented ×1

Fix Action

Fix / Workaround

Current Workaround additionalContext can inject supplementary instructions, but it cannot alter the original message. This limits use cases where the message itself needs to be rewritten before the model sees it.

RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

Problem Statement

Summary Currently, the UserPromptSubmit hook can only allow/block a message and inject additionalContext. It would be very useful if this hook could also modify the user's message content before it reaches the model.

Use Case Prompt preprocessing: Automatically expand abbreviations, inject templates, or rewrite prompts based on project-specific rules Translation/normalization: Transform shorthand commands into full instructions (e.g., expanding "fix ts" into "fix all TypeScript type errors in the current file") Context enrichment: Dynamically rewrite prompts to include relevant file paths or context that the user would otherwise have to type manually

Environment Claude Code CLI Hooks system (settings.json)

Proposed Solution

Proposed Behavior The UserPromptSubmit hook output could support an optional transformedPrompt field:

{ "hookSpecificOutput": { "transformedPrompt": "the modified message to send to the model" } } If transformedPrompt is present, Claude Code would use it in place of the original user message. If absent, behavior remains unchanged (backward compatible).

Current Workaround additionalContext can inject supplementary instructions, but it cannot alter the original message. This limits use cases where the message itself needs to be rewritten before the model sees it.

Alternative Solutions

No response

Priority

Critical - Blocking my work

Feature Category

CLI commands and flags

Use Case Example

No response

Additional Context

No response

extent analysis

TL;DR

Modify the UserPromptSubmit hook to support an optional transformedPrompt field in its output to allow rewriting the user's message content before it reaches the model.

Guidance

  • Review the proposed solution and consider implementing the transformedPrompt field in the UserPromptSubmit hook output to enable message modification.
  • Verify that the existing additionalContext field cannot meet the required use cases, such as prompt preprocessing, translation, and context enrichment.
  • Investigate the feasibility of adding the transformedPrompt field while maintaining backward compatibility.
  • Evaluate the potential impact of this change on the overall system, including the CLI and hooks system.

Example

No code snippet is provided as the issue does not contain sufficient technical details.

Notes

The proposed solution seems to address the limitation of the current UserPromptSubmit hook, but its implementation details and potential side effects are unclear.

Recommendation

Apply workaround: Modify the UserPromptSubmit hook to support the transformedPrompt field, as it appears to be a critical feature for the user's workflow.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING