语言设置:让 Claude Code 和 Codex 用你的语言工作

用 CLAUDE.md 和 AGENTS.md 设定 Claude Code 与 Codex 的回复语言,用非英语提示词又不弄坏代码,以及 UTF-8 文件、变音字符和中文路径的注意事项

更新于 2026-10-01
本页目录

网关这一侧没有“语言开关”:你的 cr_ key 只决定你能连到哪些模型,不决定回答用什么语言。语言由 你告诉工具做什么来决定,而两个主流 agent 各自都有官方文档写明该把这条要求记在哪里。

本页只讲语言。指令文件本身的结构请看 CLAUDE.md 配置指南 和 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

把规则集中成一小块,别写长:

## 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.

三个有用的官方说明:

  • “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.” 所以一个仓库同时供两个工具用时,规则只写一遍放在 AGENTS.md,只有当 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.” 这一层只用第一个 非空文件。
  2. 项目作用域 —— “Starting at the project root (typically the Git root), Codex walks down to your current working directory.” 每个目录最多贡献一个文件:先看 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.”
## 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).” 语言规则只有两行——把它放在文件 靠前的位置,不要塞在长链条的最后,以免被截断。

我们自己的团队建议(见 AGENTS.md 配置指南):文件可以用你的母语写,也可以用 英文写;个人项目随你,团队共享的仓库建议用英文,好和代码保持一致。于是最常见的组合是:规则用英文写, 要求用另一种语言回答。

4. 该改哪个文件

目标 写在这里
自己机器上的所有项目 ~/.claude/CLAUDE.md 和 ~/.codex/AGENTS.md
单个项目、和队友共享 提交进仓库的 ./AGENTS.md(两个工具都会读)
单个项目、只影响你自己 Claude Code 用 ./CLAUDE.local.md;Codex 在你自己的子目录放更深层的 AGENTS.md

5. 用非英语写提示词:会是什么样

  • 提示词同样消耗 token。 用你母语写的提示词照常用量计费;中文 “1 character typically corresponds to 1-2 tokens”(见计费说明),所以把规则写进记忆文件一次,比每条消息都 重复一遍更省。

  • 要求的是回答语言,不是代码语言。 把标识符、命令行参数、报错字符串、文件路径翻译一遍,回答就 没法用了——这正是上面示例块里保留代码原样的原因。

  • 如果回答又滑回英文,多半是规则被读得太晚或被覆盖了——用 /memory、/context 确认加载了哪些 文件,并检查是否有更深层的 AGENTS.md 或 AGENTS.override.md 赢了(见第 3 节的合并顺序)。

6. 文件编码、变音字符与非 ASCII 路径

语言设置也是个字节层面的问题。三条到处都成立的规则:

文件保持 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” 选项。

chcp
chcp 936

带变音符和中文的文件名可能“看着一样、字节不同”。 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.” 因此屏幕上完全相同的两个文件名, 字节序列可以不同,所以:

  • 让 agent 从目录列表里复制路径,而不是手打(示例规则里的 “Refer to files by their real names, including non-ASCII characters” 就是这个意思);

  • 含空格或中文的路径,在任何 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.”
git config --global core.quotepath false

7. 检查清单

  • [ ] 规则放在工具确实会加载的文件里(/memory、/context,或 Codex 链条靠前的段落)。
  • [ ] 既写明回答语言,也禁止翻译代码、路径和命令。
  • [ ] 文件以 UTF-8 保存。
  • [ ] 非 ASCII 路径来自工具输出复制,不是手打。
  • [ ] 同一仓库两个工具都用时,规则放在 AGENTS.md(或是有意复制两份)。

相关页面

相关文档

9router 接入 QCode
把 QCode.cc 作为自定义 provider 接入 9router 本地多供应商路由,做多供应商兜底与统一管理
gpt-image-2 图像生成与编辑
OpenAI 兼容的 gpt-image-2 文生图 + 图像编辑 API:base_url 切换即用,多入口节点就近接入,与现有 QCode API Key 共享计费
图像输入(视觉)
给 Claude Code 喂图:粘贴、拖拽、引用文件路径,让模型看懂截图、设计稿、架构图与图表。基于 QCode.cc 的视觉模型,所有接入域共用一份 API Key。
🚀
开始使用 QCode — Claude Code & Codex
一份套餐同时加速 Claude Code 和 Codex,亚太低延迟
查看套餐定价 → 注册账号
团队 3 人以上?
企业团队版:独立域名 + 子Key管理 + 封号保障,人均低至 ¥250/月
了解企业版 →