AIToday
AI Coding AssistantsZenn AI/MLPublished: Nov 17, 2026, 16:00 JST

Claude Code hook forces Japanese replies via Stop

Send on LINE
Claude Code hook forces Japanese replies via Stop

3 Key Points

  1. What happened

    A Zenn post shares an install script that adds a Stop hook to Claude Code; it reads last_assistant_message, strips code blocks, inline code, links and URLs, then flags a reply as English when Latin letters reach 40 and kana fall below 10% of them.

  2. Why it matters

    The hook gives users a way to automatically bounce a reply back for rewriting instead of manually prompting again, according to the post's test showing a flagged message exits with code 2.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

By signing up you agree to the Terms of Service and Privacy Policy.

Context & Analysis

The post addresses a common friction point for Japanese-speaking users of Claude Code: the assistant sometimes replies in English, forcing a manual re-prompt. The hook automates that correction by running after each response and checking the last_assistant_message field.

The detection logic deliberately ignores code, links and URLs so that technical content does not skew the language judgment. With thresholds set at 40 Latin characters and a 10% kana ratio, short replies like "Done." are excluded, while Japanese sentences with English identifiers still pass because kana particles remain present.

The post also provides a test command showing a flagged reply exits with code 2 and surfaces the rewrite instruction, plus an uninstall script for clean removal.

FAQ
How does the hook decide a reply is English?
It strips code blocks, inline code, links and URLs from last_assistant_message, then flags English when Latin letters reach 40 and kana are below 10% of that count.
What happens when the hook detects English?
It prints a reason to standard error and exits with code 2, which sends the feedback back to the model to rewrite the reply in Japanese.
Can I remove the hook later?
Yes, the post includes an uninstall script that removes the hook from settings.json and deletes the hook file.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

By signing up you agree to the Terms of Service and Privacy Policy.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleApple narrows macOS full disk access to selected folders in macOS 27.3 update