Feature Request: Allow hooks to replace prompt and transform response for non-English token optimization
Problem
Non-English users (e.g., Korean, Japanese, Chinese) consume significantly more tokens than English users for the same conversation, because these languages require 1.5-2x more tokens than English for equivalent meaning.
Current Limitation
- Input: The
UserPromptSubmithook can only add context viaadditionalContextfield, but cannot replace the original user prompt. - Output: There is no hook to intercept and transform Claude's response before displaying to the user.
This means even if we translate the input to English via hook, the original non-English text is still sent to Claude, providing no token savings. And for output, we must rely on Claude calling a translation tool, which adds overhead and isn't guaranteed.
Proposed Solution
1. Input: Add replacePrompt field to UserPromptSubmit hook
{
"hookSpecificOutput": {
"hookEventName": "UserPromptSubmit",
"replacePrompt": "translated English text here"
}
}
2. Output: Add new ResponseTransform or PreResponseDisplay hook
A new hook that intercepts Claude's response before displaying to the user:
{
"hooks": {
"PreResponseDisplay": [
{
"hooks": [
{
"type": "command",
"command": "python3 translate-response.py"
}
]
}
]
}
}
The hook would receive Claude's response via stdin and output the transformed (translated) response.
Use Case
With these features, non-English users could build a complete translation pipeline:
- Write in their native language
- UserPromptSubmit hook translates input to English
- Claude processes English input (fewer input tokens)
- Claude responds in English (fewer output tokens)
- PreResponseDisplay hook translates response back to native language
This would provide significant token savings on both input and output without requiring an external wrapper script, while preserving all CLI features.
Alternatives Considered
- External wrapper script: Works but loses interactive CLI features (streaming, tool approval, etc.)
- MCP + current hook: Only partially saves output tokens, adds tool call overhead, not guaranteed
- CLAUDE.md instructions: Relies on Claude following instructions, not deterministic
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗