Claude Code hook

Claude Code Japanese Guard

Claude Code の応答が英語に切り替わったら、日本語で書き直させる Stop hook

75 stars 4 forksHooks Source

Install

From source
git clone https://github.com/minorun365/claude-code-japanese-guard.git

From the README

claude-code-japanese-guard

Claude Code の応答が、いつの間にか英語に切り替わるのを止める Stop hook です。

日本語で指示していても、ツールを何度も呼ぶ長い作業のあとや、英語のツール出力を読んだ直後に、途中報告や最終報告が英語で返ってくることがあります。CLAUDE.md に「日本語で応答する」と書いても、この切り替わりは止まりませんでした。そこで、ターンの終わりに本文を機械で検査し、英語だったら日本語で書き直させる hook を作りました。

動き

1. Claude がターンを終えようとすると、Stop hook が最後の応答の本文(hook の入力 last_assistant_message)と会話の記録(transcript)を読みます
2. そのターンの本文を取り出し、英字と日本語の文字数を数えます
3. 英語主体の本文があれば、終了を止めて「日本語で書き直して」と差し戻します
4. Claude が同じターンのうちに日本語で出し直します

検査するのは次の3つです。

- 最終回答:最後のツール呼び出しより後に Claude が書いた本文
- ツール呼び出しの間の途中報告のうち、複数行で英字が60文字以上あるものと、1行でも英字が250文字以上ある長い段落。数行の途中報告は本文と同じ大きさで画面に出るためです。ツールを呼ぶ前の1行の前置きは画面で小さく出るだけなので見ません(差し戻すと、日本語の最終回答のあとに前置きだけを書き直す応答がもう1通出てしまいます)。thinking の表示を updates にしている場合、途中報告は thinking ブロックとして記録されるので、そちらも見ます
- デスクトップアプリの「次の一手」の箱(wrap_up ツール)に出る、まとめ・質問・ボタンの文言。箱が最終回答の代わりになるターンでは、本文がほとんど残らないためです

ツールを呼ぶ前の短い一言は検査しません。画面では実行ログの間に小さく出るだけで、英語が混ざっても読む側は困らないからです。

「次の一手」の箱は、PreToolUse hook としても登録すると、英語の箱が画面に出る前に止めて書き直させます。

差し戻しは1ターンに1回だけです。書き直しがまた英語でも、そこで終了させるので、差し戻しが続くことはありません。

次のものは数えません。英語のコマンドや英文の下書きを見せるのは正当な使い方だからです。

- コードブロック( bash
   mkdir -p ~/.claude/hooks
   curl -fsSL https://raw.githubusercontent.com/minorun365/claude-code-japanese-guard/main/hooks/japanese-guard.py -o ~/.claude/hooks/japanese-guard.py
   chmod +x ~/.claude/hooks/japanese-guard.py
   json
   { "hooks": [ { "type": "command", "command": "~/.claude/hooks/japanese-guard.py" } ] }
   json
   { "matcher": "mcp.*wrap_up", "hooks": [ { "type": "command", "command": "~/.claude/hooks/japanese-guard.py" } ] }
   bash
   python3 -c "import json,os;json.load(open(os.path.expanduser('~/.claude/settings.json')));print('OK')"
   bash
   echo '{}' | ~/.claude/hooks/japanese-guard.py && echo OK
   bash
python3 ~/.claude/hooks/japanese-guard.py --check…
Read the full README on GitHub

How hooks work

  • Hooks are shell commands Claude Code runs at fixed points: before or after a tool call, when you submit a prompt, when Claude stops, on notifications and at session start.
  • They are set in the hooks section of ~/.claude/settings.json (or .claude/settings.json for a project), or come bundled in a plugin.
  • A hook can block a tool call, add context, or run a formatter or test. Read the scripts before you install them: they run on your machine with your permissions.
Claude Code docs

Details

Type
Hooks
Language
Python
License
Apache-2.0
Last updated
24 October 2026

FAQ

What is Claude Code Japanese Guard?

Claude Code の応答が英語に切り替わったら、日本語で書き直させる Stop hook It is a hook for Claude Code, from minorun365/claude-code-japanese-guard on GitHub.

How do I install Claude Code Japanese Guard?

Clone minorun365/claude-code-japanese-guard from GitHub and follow the setup steps in its README.

Is Claude Code Japanese Guard popular?

minorun365/claude-code-japanese-guard has 75 GitHub stars and 4 forks. It was last updated on 24 October 2026.

More hooks

Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.