Customization 是让 Codex 按照你的团队工作方式运行的方法。
Project guidance(AGENTS.md)用于 persistent instructions。
Memories 用于保存从 prior work 中学到的有用 context。
Skills 用于 reusable workflows 和 domain expertise。
MCP 用于访问 external tools 和 shared systems。
Subagents 用于把工作委派给 specialized subagents。
这些 layers 是互补的,而不是彼此竞争。AGENTS.md 塑造 behavior,memories 把 local context 继续带到后续工作中,skills 打包可重复 processes, MCP 则把 Codex 连接到 local workspace 之外的 systems。
AGENTS Guidance
AGENTS.md 为 Codex 提供 durable project guidance,这些 guidance 会随 repository 一起存在,并在 agent 开始工作前生效。请保持精简。
把它用于你希望 Codex 在 repo 中每次都遵守的 rules,例如:
Build and test commands。
Review expectations。
Repo-specific conventions。
Directory-specific instructions。
当 agent 对你的 codebase 作出错误假设时,请在 AGENTS.md 中纠正,并要求 agent 更新 AGENTS.md,让修复持久化。把它当作一个 feedback loop。
更新 AGENTS.md:只从真正重要的 instructions 开始。把反复出现的 review feedback 固化下来,把 guidance 放在最接近其适用范围的 directory 中,并在你纠正某件事时告诉 agent 更新 AGENTS.md,让未来 sessions 继承这个修复。
何时更新 AGENTS.md
Repeated mistakes:如果 agent 反复犯同一个错误,请添加一条 rule。
Too much reading:如果它找到了正确文件,却读取了太多 documents,请添加 routing guidance(应优先查看哪些 directories/files)。
Recurring PR feedback:如果你留下过不止一次相同反馈,请把它 codify。
在 GitHub 中:在 pull request comment 里用 request tag @codex(例如 @codex add this to AGENTS.md),把更新委派给 cloud task。
Automate drift checks:使用 automations 运行 recurring checks(例如 daily),查找 guidance gaps,并建议应该添加到 AGENTS.md 的内容。
把 AGENTS.md 与强制执行这些 rules 的 infrastructure 配合使用:pre-commit hooks、linters 和 type checkers 会在你看到问题前捕获它们,让系统更擅长预防 recurring mistakes。
Codex 可以从多个位置加载 guidance:你 Codex home directory 中的 global file(面向你这个 developer),以及 teams 可以 check in 的 repo-specific files。距离 working directory 更近的 files 优先级更高。使用 global file 来塑造 Codex 如何与你沟通(例如 review style、verbosity 和 defaults),并让 repo files 专注于 team 与 codebase rules。
~/.codex/
AGENTS.md Global (for you as a developer)
repo-root/
AGENTS.md repo-specific (for your team) Skills
Skills 为 Codex 提供面向 repeatable workflows 的 reusable capabilities。Skills 通常最适合 reusable workflows,因为它们支持更丰富的 instructions、scripts 和 references,同时可跨 tasks 复用。Skills 会被加载并对 agent 可见(至少 metadata 可见),因此 Codex 可以发现并隐式选择它们。这让 rich workflows 保持可用,又不会一开始就膨胀 context。
使用 skill folders 在本地 author 和 iterate workflows。如果某个 workflow 已经有 plugin ,请先安装它以复用成熟 setup。当你想跨 teams 分发自己的 workflow,或把它与 app integrations 打包时,请把它封装为 plugin 。Skills 仍是 authoring format; plugin s 是 installable distribution unit。
一个 skill 通常是一个 SKILL.md file,加上可选的 scripts、references 和 assets。
my-skill/
SKILL.md Required: instructions + metadata
scripts/ Optional: executable code
references/ Optional: documentation
assets/ Optional: templates, resources Skill directory 可以包含 scripts/ folder,其中有 Codex 作为 workflow 一部分调用的 CLI scripts(例如 seed data 或 run validations)。当 workflow 需要 external systems(issue trackers、design tools、docs servers)时,请把 skill 与 MCP 配合使用。
Example SKILL.md:
---
name: commit
description: Stage and commit changes in semantic groups. Use when the user wants to commit, organize commits, or clean up a branch before pushing.
---
1. Do not run `git add .`. Stage files in logical groups by purpose.
2. Group into separate commits: feat -> test -> docs -> refactor -> chore.
3. Write concise commit messages that match the change scope.
4. Keep each commit focused and reviewable. Use skills for:
Repeatable workflows(release steps、review routines、docs updates)。
Team-specific expertise。
需要 examples、references 或 helper scripts 的 procedures。
Skills 可以是 global(位于你的 user directory,面向你这个 developer),也可以是 repo-specific(check into .agents/skills,面向你的 team)。当 workflow 适用于某个 project 时,把 repo skills 放在 .agents/skills;当你希望某个 skill 跨所有 repos 使用时,使用你的 user directory。
| Layer | Global | Repo |
|---|---|---|
| AGENTS | ~/.codex/AGENTS.md | AGENTS.md in repo root or nested directories |
| Skills | $HOME/.agents/skills | .agents/skills in repo |
Codex 对 skills 使用 progressive disclosure:
它从用于 discovery 的 metadata(name、description)开始。
只有当某个 skill 被选中时,才加载 SKILL.md。
只有在需要时,才读取 references 或运行 scripts。
Skills 可以被显式 invoked,Codex 也可以在 task 与 skill description 匹配时隐式选择它们。清晰的 skill descriptions 会提升 triggering reliability。
MCP
MCP(Model Context Protocol)是把 Codex 连接到 external tools 和 context providers 的标准方式。它特别适合 remotely hosted systems,例如 Figma、Linear、GitHub,或你的 team 依赖的 internal knowledge services。
当 Codex 需要 local repo 之外的 capabilities 时使用 MCP,例如 issue trackers、design tools、browsers 或 shared documentation systems。
一种理解方式是:
Host:Codex。
Client:Codex 内部的 MCP connection。
Server:external tool 或 context provider。
MCP servers 可以暴露:
Tools(actions)。
Resources(readable data)。
Prompts(reusable prompt templates)。
这种分离有助于你推理 trust 和 capability boundaries。有些 servers 主要提供 context,另一些则暴露 powerful actions。
在实践中,MCP 与 skills 配合时通常最有用:
Skill 定义 workflow,并命名要使用的 MCP tools。
Subagents
你可以创建具有不同 roles 的 agents,并 prompt 它们以不同方式使用 tools。例如,一个 agent 可能运行特定 testing commands 和 configurations,而另一个 agent 具有用于获取 production logs 以 debugging 的 MCP servers。每个 subagent 都保持聚焦,并使用适合其工作的 tools。
Skills + MCP together
Skills plus MCP 是这些能力汇合的地方:skills 定义 repeatable workflows,MCP 把它们连接到 external tools 和 systems。如果某个 skill 依赖 MCP,请在 agents/openai.yaml 中声明该 dependency,让 Codex 可以自动 install 并 wire 它(参见 Agent Skills )。
Next step
Custom instructions with AGENTS.md ,让 Codex 遵循你的 repo conventions。添加 pre-commit hooks 和 linters 来强制执行这些 rules。
当 workflows 需要 external systems(Linear、GitHub、docs servers、design tools)时使用 MCP 。
当你准备把 noisy 或 specialized tasks 委派给 subagents 时使用 Subagents 。