claudeers.
// Other

claude-code-japanese-guard

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

// Other[ cli ][ desktop ][ claude ]#claude#other◷ Apache-2.0$open-sourceupdated 11 days ago

Install with your AI

Paste into Claude Code, Cursor, or any agent — it reads the repo and wires the tool into your project.

Install and set up claude-code-japanese-guard (git-clone project) into my current project.
Found on https://claudeers.com/claude-code-japanese-guard
Repo: https://github.com/minorun365/claude-code-japanese-guard
Homepage/docs: —
Detected install method: git-clone → git clone https://github.com/minorun365/claude-code-japanese-guard
Category: other. Platforms: cli, desktop.
Read the repo's README for exact setup and env vars, then install it and wire it into my project.

Claudeers Health Verdict:
unknown; community-verified: false. Confirm the source before running anything.
// or clone
git clone https://github.com/minorun365/claude-code-japanese-guard

// compatibility

Platformscli, desktop
Operating systems—
AI compatibilityclaude
LicenseApache-2.0
Pricingopen-source
LanguagePython

Get your FREE $2.50 API credits to access TickAtlas financial data ↗

claude-code-japanese-guard

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

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

動き

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

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

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

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

  • コードブロック(```)とインラインコード
  • URL・メールアドレス・Markdown のリンク
  • 英字が25文字未満の短い本文(「OK」程度の返事)

入れ方

Claude Desktop(Claude Code)に、このリポジトリの URL を渡して頼むだけです。

https://github.com/minorun365/claude-code-japanese-guard これ設定しといて

あとは Claude Code が下の手順で入れてくれます。

Claude Code 向けの設定手順

ユーザーからこのリポジトリの設定を頼まれた Claude Code は、次の手順で入れてください。CLI で自分で入れる人も、同じ手順で入れられます。

  1. hook を置く。 hooks/japanese-guard.py を ~/.claude/hooks/japanese-guard.py に保存し、実行権限を付ける。

    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
    
  2. ~/.claude/settings.json に Stop hook を登録する。 既存の設定は消さず、hooks.Stop の配列に次の1件を足す。hooks や Stop が無ければ作る。同じ command がすでに登録されていれば、何もしない。

    { "hooks": [ { "type": "command", "command": "~/.claude/hooks/japanese-guard.py" } ] }
    

    書き換えたあと、ファイルが JSON として読めることを確かめる。

    python3 -c "import json,os;json.load(open(os.path.expanduser('~/.claude/settings.json')));print('OK')"
    

    自分の設定ファイルの書き換えが権限の都合で止められた場合は、無理に回避しない。足す内容をユーザーに示し、ユーザー自身で settings.json に足してもらう。

  3. 動くことを確かめる。 何も渡さずに実行してエラーにならないこと(何も出力されなければ正常)を確かめる。

    echo '{}' | ~/.claude/hooks/japanese-guard.py && echo OK
    
  4. ユーザーに伝える。 入れたことと、設定が確実に読み込まれるのは新しく開いたセッションからであることを伝える。応答が英語になると、ターンの終わりに「日本語で書き直して」と差し戻されるようになる。

Python 3 だけで動きます。追加のパッケージは要りません。

判定の調整

環境変数で閾値を変えられます。

変数既定意味
JAPANESE_GUARD_MIN_LATIN25英字がこれ未満の本文は判定しない
JAPANESE_GUARD_RATIO3英字の数が日本語の文字数のこの倍を超えたら英語主体とみなす

手元の記録で試す

過去のセッションの記録に当てると、最後のターンで英語主体だった本文を表示します。

python3 ~/.claude/hooks/japanese-guard.py --check ~/.claude/projects/<プロジェクト>/<セッションID>.jsonl

テスト

python3 tests/test_japanese_guard.py

ライセンス

Apache License 2.0

// faq

What is claude-code-japanese-guard?

Claude Code の応答が英語に切り替わったら、日本語で書き直させる Stop hook. It is open-source on GitHub.

Is claude-code-japanese-guard free to use?

claude-code-japanese-guard is open-source under the Apache-2.0 license, so it is free to use.

What category does claude-code-japanese-guard belong to?

claude-code-japanese-guard is listed under other in the Claudeers registry of Claude-compatible tools.

6 views
★ 11 stars
unclaimed
updated 11 days ago

// embed badge

claude-code-japanese-guard on Claudeers
[![Claudeers](https://claudeers.com/api/badge/claude-code-japanese-guard.svg)](https://claudeers.com/claude-code-japanese-guard)

// retro hit counter

claude-code-japanese-guard hit counter
[![Hits](https://claudeers.com/api/counter/claude-code-japanese-guard.svg)](https://claudeers.com/claude-code-japanese-guard)

// reviews

// guestbook

0/500

// related in Other

🔓

符合nature论文学术表达和科研绘图的Skill

// otherYuan1z0825/⟨Python⟩★ 45,880◷ Apache-2.0[ claude ]
🔓

Anti-AI-slop design skill for Claude Code, Cursor, and Codex.

// otherNutlope/⟨CSS⟩★ 29,187◷ MIT[ claude ]
🔓

Open source Ghostty-based macOS terminal with vertical tabs and notifications for AI coding agents. Built for multitasking, organization, and programmability.

// othermanaflow-ai/⟨Swift⟩★ 27,679◷ NOASSERTION[ claude ]
🔓

Huashu Design · HTML-native design skill for Claude Code · Claude Code 里 HTML 原生的设计 skill · 高保真原型 / 幻灯片 / 动画 + 20 设计哲学 + 5 维评审 + MP4 导出 · Agent-agnostic

// otheralchaincyf/⟨HTML⟩★ 24,472◷ MIT[ claude ]
→ see how claude-code-japanese-guard connects across the ecosystem