# 言語設定：Claude Code と Codex を自分の言語で動かす

**ゲートウェイ側に「言語スイッチ」はありません**：`cr_` Key が決めるのは到達できるモデルだけで、返答の
言語ではありません。言語は**ツールに何を指示するか**で決まり、代表的な 2 つのエージェントにはどちらも
公式ドキュメントに指示の書き込み場所が定義されています。

> このページは*言語*の話だけです。指示ファイルそのものの構造は
> [CLAUDE.md 設定ガイド](/docs/usage/claude-md) と [AGENTS.md 設定ガイド](/docs/usage/agents-md) に。

## 1. セッションの中で頼む

一番速いのは口に出すこと：自分の言語でプロンプトを書く、もしくは「ポルトガル語で回答して」と明示する。
すぐ効き、設定も不要ですが、その会話にしか残りません。次回以降も生かしたい内容は下のファイルへ書きます。

## 2. CLAUDE.md に書き込む（Claude Code）

公式の表現：*“CLAUDE.md files are markdown files that give Claude persistent instructions for a project,
your personal workflow, or your entire organization.”* 言語ルールはまさにこの永続指示です。

| スコープ | ファイル |
|---|---|
| 組織 | macOS: `/Library/Application Support/ClaudeCode/CLAUDE.md` · Linux and WSL: `/etc/claude-code/CLAUDE.md` · Windows: `C:\Program Files\ClaudeCode/CLAUDE.md` |
| ユーザー | `~/.claude/CLAUDE.md` |
| プロジェクト | `./CLAUDE.md` または `./.claude/CLAUDE.md` |
| ローカル | `./CLAUDE.local.md` |

ルールは 1 ブロックに短くまとめます：

```markdown
## Response language
- Reply in the language of my message unless I say otherwise.
- If I name a language explicitly (for example: "reply in 日本語"), use it for the whole session.
- Keep code, identifiers, file paths, shell commands and log output exactly as they are.
- Do not translate English comments, commit messages or API names inside files.
```

役立つ公式記述 3 つ：

- *“Run /init to generate a starting CLAUDE.md automatically.”* —— 自動で分かることを書いてくれるので、
  言語ルールは自分で足します。
- *“The /memory command lists your CLAUDE.md, CLAUDE.local.md, and other memory file locations across
  user and project scopes”* —— 編集したファイルが本当に読み込まれるか確認できます。
- *“CLAUDE.md files can import additional files using @path/to/import syntax.”* —— 言語ルールを複数リポジトリ
  共用の別ファイルに置きたいときに便利です。

Claude Code は `AGENTS.md` も読めます：*“Claude Code can read AGENTS.md as project instructions, allowing
compatibility with other coding agents without adding CLAUDE.md.”*、そして *“CLAUDE.md takes precedence over
AGENTS.md by default.”* ですから 1 つのリポジトリを両ツールで使うなら、ルールは `AGENTS.md` に 1 回だけ書き、
Claude Code 用の追加事項があるときだけ `CLAUDE.md` を足すのが自然です。

## 3. AGENTS.md に書き込む（Codex）

*“Codex reads AGENTS.md files before doing any work.”* Codex は起動時に指示チェーンを組み立てるので、発見
順序が言語ルールに効きます：

1. **グローバル スコープ** —— Codex のホーム（既定は `~/.codex`、`CODEX_HOME` を設定していなければ）で
   *“Codex reads `AGENTS.override.md` if it exists. Otherwise, Codex reads `AGENTS.md`.”* この層では空では
   ない最初の 1 ファイルだけ使われます。
2. **プロジェクト スコープ** —— *“Starting at the project root (typically the Git root), Codex walks down to
   your current working directory.”* 各ディレクトリ高々 1 ファイル：`AGENTS.override.md` → `AGENTS.md` →
   `project_doc_fallback_filenames` に並べた名前。
3. **マージ順** —— *“Codex concatenates files from the root down […] Files closer to your current directory
   override earlier guidance because they appear later in the combined prompt.”*

```markdown
## Response language
- Reply in the language of my message unless I say otherwise.
- Keep code, identifiers, file paths, shell commands and log output exactly as they are.
- Refer to files by their real names, including non-ASCII characters.
```

数字付きの注意も：*“Codex skips empty files and stops adding files once the combined size reaches the limit
defined by `project_doc_max_bytes` (32 KiB by default).”* 言語ルールは 2 行 —— ファイル前方に置けば打ち切り
でも残ります。長いチェーンの末尾に置くのは避けましょう。

私たちのチーム向けアドバイス（[AGENTS.md 設定ガイド](/docs/usage/agents-md)）：ファイル自体は自分の言語でも
英語でも書けます。個人プロジェクトは好きなほうで、共有リポジトリはコードと揃って英語が推奨。よくある組み合わせは
**ルールは英語で書き、回答は別の言語を要求する**という形です。

## 4. どのファイルを編集するか

| 目的 | ここに書く |
|---|---|
| 自分のマシンの全プロジェクト | `~/.claude/CLAUDE.md` **と** `~/.codex/AGENTS.md` |
| 1 プロジェクト、チーム共有 | リポジトリにコミットした `./AGENTS.md`（両ツールが読みます） |
| 1 プロジェクト、自分だけ | Claude Code は `./CLAUDE.local.md`、Codex は自分のサブディレクトリに深い位置の `AGENTS.md` |

## 5. 非英語プロンプト：期待すること

- **プロンプトもトークンを消費します。** 自分の言語で書いても課金は同じ。中国語は
  *“1 character typically corresponds to 1-2 tokens”*（[課金説明](/docs/reference/billing)）なので、ルールを
  メモリファイルに 1 回書くほうが、毎メッセージ繰り返すより割安です。
- **依頼するのは回答の言語であってコードの言語ではありません。** 識別子・CLI フラグ・エラー文・ファイルパスを
  翻訳すると回答は使えなくなるので、上の例はコードを原文のまま保つ指示にしています。
- **回答がまた英語へ滑ったら**、ルールが遅く読まれるか上書きされている可能性が高い —— `/memory` や
  `/context` で読まれたファイルを確認し、より深い位置の `AGENTS.md` や `AGENTS.override.md` が勝っていないか
  見てください（第 3 節のマージ順）。

## 6. ファイルエンコーディング、アクセント文字、非 ASCII パス

言語設定はバイトレベルの問題でもあります。どこでも通用する 3 原則：

**ファイルは UTF-8。** *“UTF-8 is the universal code page for internationalization and is able to encode the
entire Unicode character set. It is used extensively on the web and is the default encoding for both XML and
\*nix-based platforms.”* `CLAUDE.md` / `AGENTS.md` はエディタで UTF-8 保存を。文字化けしたメモリファイルは
文字化けのまま読まれます。

**Windows ではコンソールの手前にコードページがあります。** *“Changes the active console code page. If used
without parameters, chcp displays the number of the active console code page.”* —— 一覧には中国語の `936` も
あります。非 ASCII 出力がコンソールで奇妙に見えるなら、まずこのページを確認。プロセスを UTF-8 で動かす
マイクロソフトの推奨は `activeCodePage` プロパティ
（*“As of Windows Version 1903 (May 2019 Update), you can specify the activeCodePage property…”*）、または
システム全体の *“Beta: Use Unicode UTF-8 for worldwide language support”* オプションです。

```powershell
chcp
chcp 936
```

**アクセント付きや CJK のファイル名は「見た目は同じ・バイトは違う」ことがあります。** Unicode 標準は
*canonical equivalence* を *“characters or sequences of characters which represent the same abstract character
[…] when correctly displayed should always have the same visual appearance and behavior.”* と定義します。画面で
完全に同じ 2 つのファイル名でもバイト列が違う可能性がある、つまり：

- エージェントには一覧からパスを**コピー**させる（例のルールにある
  *“Refer to files by their real names, including non-ASCII characters”* はこの意味）；
- 空白や CJK を含むパスは、どんな shell コマンドでもクォートする；
- Git のエスケープを切って、`git status` と `git diff` にファイル名をそのまま出させる：
  *“When this configuration option is set to false, git will not quote pathnames in the output of commands like
  `git status` and `git diff` […] The default value is `true`.”*

```bash
git config --global core.quotepath false
```

## 7. チェックリスト

- [ ] ツールが実際に読むファイルにルールがある（`/memory`、`/context`、または Codex チェーンの前半）。
- [ ] 回答言語を指定し、コード・パス・コマンドの翻訳を禁止している。
- [ ] ファイルを UTF-8 で保存している。
- [ ] 非 ASCII パスはツール出力からコピーし、手打ちしていない。
- [ ] 両ツール利用のリポジトリではルールが `AGENTS.md` にある（意図的に 2 重化しているなら別）。

## 関連ページ

- [CLAUDE.md 設定ガイド](/docs/usage/claude-md)
- [AGENTS.md 設定ガイド](/docs/usage/agents-md)
- [Claude Code 完全チュートリアル](/docs/getting-started/claude-code-tutorial)
- [Codex 完全チュートリアル](/docs/ide/codex)
- [出力形式：json / text / stream-json](/docs/usage/output-formats)
- [CLI のコツ](/docs/usage/cli-tips)
- [中国本土以外ユーザーのはじめ方](/docs/getting-started/international-users)