Feature Request: Allow hooks to replace prompt and transform response for non-English token optimization

Resolved 💬 2 comments Opened Jan 20, 2026 by iceflower Closed Feb 27, 2026

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

  1. Input: The UserPromptSubmit hook can only add context via additionalContext field, but cannot replace the original user prompt.
  2. 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:

  1. Write in their native language
  2. UserPromptSubmit hook translates input to English
  3. Claude processes English input (fewer input tokens)
  4. Claude responds in English (fewer output tokens)
  5. 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

View original on GitHub ↗

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