Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,12 @@ pnpm build

本仓库优先引用官方资料,并会在关键页面标注“最后核对日期”。当前骨架参考:

- [OpenAI Codex 产品页](https://openai.com/codex/)
- [Codex in ChatGPT Help Center](https://help.openai.com/en/articles/11369540-codex-in-chatgpt)
- [OpenAI Codex CLI Getting Started](https://help.openai.com/en/articles/11096431-openai-codex-cli-getting-started)
- [Codex cloud docs](https://platform.openai.com/docs/codex)
- [openai/codex GitHub repository](https://github.com/openai/codex)
- [Codex 产品介绍](https://openai.com/codex/)
- [Codex 与 ChatGPT 套餐](https://help.openai.com/en/articles/11369540-using-codex-with-your-chatgpt-plan)
- [Codex 官方文档](https://learn.chatgpt.com/docs)
- [Codex CLI 官方文档](https://learn.chatgpt.com/docs/codex/cli)
- [Codex Cloud 官方文档](https://learn.chatgpt.com/docs/cloud)
- [openai/codex 源代码仓库](https://github.com/openai/codex)

## 参与贡献

Expand Down
11 changes: 6 additions & 5 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,12 @@ The CodexGuide WeChat community has a one-time CNY 9.9 entry fee. The small thre

This repository prioritizes official sources and marks important pages with review dates where possible. The current structure references:

- [OpenAI Codex product page](https://openai.com/codex/)
- [Codex in ChatGPT Help Center](https://help.openai.com/en/articles/11369540-codex-in-chatgpt)
- [OpenAI Codex CLI Getting Started](https://help.openai.com/en/articles/11096431-openai-codex-cli-getting-started)
- [Codex cloud docs](https://platform.openai.com/docs/codex)
- [openai/codex GitHub repository](https://github.com/openai/codex)
- [Codex product overview](https://openai.com/codex/)
- [Codex and ChatGPT plans](https://help.openai.com/en/articles/11369540-codex-in-chatgpt)
- [Official Codex documentation](https://developers.openai.com/codex/)
- [Official Codex CLI documentation](https://developers.openai.com/codex/cli/)
- [Official Codex Cloud documentation](https://developers.openai.com/codex/cloud/)
- [openai/codex source repository](https://github.com/openai/codex)

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/seo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const pageDescriptions: Record<string, string> = {
"/start/08-task-execution.html": "Codex 任务执行与验证闭环教程,说明如何观察执行过程、检查 diff、验证结果并处理失败。",
"/start/09-mobile-control.html": "手机端跟进桌面 Codex 任务教程,说明 ChatGPT App 入口、跨设备连接、任务查看和协同边界。",

"/start/10-cli-installation.html": "Codex CLI 安装教程,覆盖 Node 环境、安装命令、版本检查、登录流程和第一次运行准备。",
"/start/10-cli-installation.html": "Codex CLI 安装教程,覆盖安装命令、版本检查、登录流程和第一次运行准备。",
"/start/11-cli-first-run.html": "第一次让 Codex CLI 改代码的教程,说明如何选择低风险任务、让 Codex 读仓库、修改文件并运行验证。",
"/start/12-cli-options.html": "Codex CLI 选项与命令指南,覆盖交互模式、非交互执行、恢复会话、Slash Commands 和常用启动参数。",
"/start/13-ide-vscode.html": "在 VS Code 中使用 Codex 的教程,介绍插件入口、文件上下文、局部修改、解释代码和编辑器内协作方式。",
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced/00-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ permalink: /advanced/
---

::: tip 最后核对
官方资料最后核对日期:2026-06-29。本页是进阶教程索引,涉及费用、上下文、AGENTS.md、Skills、Plugins、权限、自动化、Hooks、沙盒、线程管理、配置和团队实践的细节,请以 [Codex 文档入口](https://developers.openai.com/codex/) 与各章节引用的官方资料为准。
官方资料最后核对日期:2026-09-03。本页是进阶教程索引,涉及费用、上下文、AGENTS.md、Skills、Plugins、权限、自动化、Hooks、沙盒、线程管理、配置和团队实践的细节,请以 [Codex 官方文档总览](https://learn.chatgpt.com/docs) 与各章节引用的官方资料为准。
:::

# 进阶教程

相信你已经能通过 [快速上手](../start/00-index.md) 完成了你到第一个任务
相信你已经能通过 [快速上手](../start/00-index.md) 完成了你的第一个任务

如果你仍有好奇心,你可以按照下面的顺序深入了解 Codex 的各个方面。你将会学到一些很通用的 Agent 使用技巧。这意味着不少内容你都可以迁移到 Claude Code、KimiCode 等其他Agent上。

Expand Down
4 changes: 2 additions & 2 deletions docs/advanced/01-cost-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Codex 费用与 Token 入门说明,解释 ChatGPT 计划额度
---

::: tip 最后核对
官方资料最后核对日期:2026-06-27。本文参考 [OpenAI Token 说明](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-do-i-count-them)、[OpenAI API Pricing](https://openai.com/api/pricing/) 与 [Prompt Caching](https://platform.openai.com/docs/guides/prompt-caching)。价格、额度和可用模型会变化,真正下单或部署前请回到官方页面核对。
官方资料最后核对日期:2026-09-04。本文参考 [OpenAI Token 帮助中心](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-track-them)、[ChatGPT 定价页](https://chatgpt.com/pricing/)、[OpenAI API 定价页](https://developers.openai.com/api/docs/pricing) 与 [Prompt Caching 官方文档](https://developers.openai.com/api/docs/guides/prompt-caching)。价格、额度和可用模型会变化,真正下单或部署前请回到官方页面核对。
:::

# 理解费用与上下文
Expand Down Expand Up @@ -44,7 +44,7 @@ Token 是模型读写文本时的基本“小块”。它不等于字数,也

Prompt caching 可以理解为:模型服务端会记住你最近用过的一段长前缀。当后续请求的开头部分和之前足够相似时,这部分输入会按 cached input tokens 计费。缓存输入通常比普通输入便宜,响应也可能更快。

![Prompt caching 稳定前缀示例](https://cdn.canghecode.com/codexguide/docs/images/prompt-caching-stable-prefix-watermarked-small.png)
![OpenAI 模型 Prompt caching 价格示例](../images/openai-model-prompt-caching-pricing.png)

| 类型 | 含义 | 费用 |
| --- | --- | --- |
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/02-agents-md.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "AGENTS.md 项目规则指南,说明如何写入项目命令、
---

::: tip 最后核对
官方资料最后核对日期:2026-06-19。`AGENTS.md` 机制请以 [Codex AGENTS.md 官方文档](https://developers.openai.com/codex/guides/agents-md)、[AGENTS.md 标准网站](https://agents.md/) 和 [openai/codex GitHub repository](https://github.com/openai/codex) 为准。
官方资料最后核对日期:2026-06-19。`AGENTS.md` 机制请以 [Codex AGENTS.md 官方文档](https://learn.chatgpt.com/docs/agent-configuration/agents-md)、[AGENTS.md 标准网站](https://agents.md/) 和 [openai/codex 源代码仓库](https://github.com/openai/codex) 为准。
:::

# AGENTS.md
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/03-skills-plugins-mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Codex Skills 和 Plugins 入门说明,介绍技能、插件、MC
---

::: tip 最后核对
官方资料最后核对日期:2026-06-20。本文参考 [Agent Skills 标准](https://agentskills.io/)、[Codex Skills](https://developers.openai.com/codex/skills)、[Codex Plugins](https://developers.openai.com/codex/plugins) 与 [Build plugins](https://developers.openai.com/codex/plugins/build)。如果你的界面与本文截图不完全一致,请优先以当前客户端和工作区可用功能为准。
官方资料最后核对日期:2026-09-04。本文参考 [Agent Skills 标准](https://agentskills.io/)、[Codex Skills 官方文档](https://learn.chatgpt.com/docs/build-skills)、[Codex Plugins 官方文档](https://learn.chatgpt.com/docs/plugins) 与 [构建 Plugins 官方文档](https://learn.chatgpt.com/docs/build-plugins)。如果你的界面与本文截图不完全一致,请优先以当前客户端和工作区可用功能为准。
:::

# Skills 和 Plugins
Expand Down
6 changes: 3 additions & 3 deletions docs/advanced/04-permissions-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Codex 权限管理指南,说明文件访问、命令审批、网
---

::: tip 最后核对
官方资料最后核对日期:2026-06-15。本文参考 [Codex app settings](https://developers.openai.com/codex/app/settings)、[Sandboxing](https://developers.openai.com/codex/concepts/sandboxing#how-you-control-it)、[Permissions](https://developers.openai.com/codex/permissions) 与 [Agent approvals & security](https://developers.openai.com/codex/agent-approvals-security)。不同版本的界面具体名称、入口和可用选项会有所不同,请以你当前使用的客户端界面为准。
官方资料最后核对日期:2026-09-04。本文参考 [Codex App 设置](https://learn.chatgpt.com/docs/reference/settings)、[沙盒](https://learn.chatgpt.com/docs/sandboxing)、[权限](https://learn.chatgpt.com/docs/permissions) 与 [智能体审批与安全](https://learn.chatgpt.com/docs/agent-approvals-security)。不同版本的界面具体名称、入口和可用选项会有所不同,请以你当前使用的客户端界面为准。
:::

# 权限管理
Expand All @@ -12,7 +12,7 @@ description: "Codex 权限管理指南,说明文件访问、命令审批、网
1. 聊天框下方的权限选择
2. 设置里的“配置”项

权限管理和**沙盒**(Sandbox)本质上是同一个概念。想深入可以看 [OpenAI 官方文档](https://developers.openai.com/codex/concepts/sandboxing#how-you-control-it) 或者 [沙盒与审批](./07-sandbox-approvals.html) 以了解更多。
权限管理和**沙盒**(Sandbox)本质上是同一个概念。想深入可以看 [沙盒](https://learn.chatgpt.com/docs/sandboxing) 或者 [沙盒与审批](./07-sandbox-approvals.html) 以了解更多。

## 聊天框里的权限选项

Expand Down Expand Up @@ -90,7 +90,7 @@ description: "Codex 权限管理指南,说明文件访问、命令审批、网

![Codex App config.toml 配置示例](https://cdn.canghecode.com/codexguide/docs/images/codex-app-config-toml-settings-watermarked-small.png)

上表仅展示部分常见配置选项,更多请查看[OpenAI Premission](https://developers.openai.com/codex/permissions)。
上表仅展示部分常见配置选项,更多请查看[权限](https://learn.chatgpt.com/docs/permissions)。

## 推荐

Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/05-automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Codex 自动化指南,说明定时任务、提醒、监控、后
---

::: tip 最后核对
官方资料最后核对日期:2026-05-27。本文参考 [Using Codex with your ChatGPT plan](https://help.openai.com/en/articles/11369540-using-codex-with-your-chatgpt-plan) 与 [Codex use cases](https://developers.openai.com/codex/use-cases/)。不同客户端、工作区套餐和权限设置下,自动化入口和可选项可能会有所不同。
官方资料最后核对日期:2026-09-04。本文参考 [Codex ChatGPT 套餐帮助中心](https://help.openai.com/en/articles/11369540-codex-in-chatgpt) 与 [已安排任务](https://learn.chatgpt.com/docs/automations)。不同客户端、工作区套餐和权限设置下,自动化入口和可选项可能会有所不同。
:::

# Automation
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/06-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Codex Hooks 入门指南,说明 Hooks 的用途、配置位置
---

::: tip 最后核对
官方资料最后核对日期:2026-06-19。本文依据 [Codex Hooks 官方文档](https://developers.openai.com/codex/hooks) 和 [Codex Configuration Reference](https://developers.openai.com/codex/config-reference) 整理。
官方资料最后核对日期:2026-09-04。本文依据 [Codex Hooks 官方文档](https://learn.chatgpt.com/docs/hooks) 和 [Codex 配置参考资料](https://learn.chatgpt.com/docs/config-file/config-reference) 整理。
:::

# Hooks
Expand Down
8 changes: 4 additions & 4 deletions docs/advanced/07-sandbox-approvals.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Codex 沙盒与审批指南:面向新手解释为什么 Codex
---

::: tip 最后核对
官方资料最后核对日期:2026-06-18。本文依据 [Codex Sandboxing](https://developers.openai.com/codex/concepts/sandboxing)、[Agent approvals & security](https://developers.openai.com/codex/agent-approvals-security)、[Permissions](https://developers.openai.com/codex/permissions)、[Rules](https://developers.openai.com/codex/rules)、[Windows](https://developers.openai.com/codex/windows) 和 [Auto-review](https://developers.openai.com/codex/concepts/sandboxing/auto-review) 整理。
官方资料最后核对日期:2026-09-04。本文依据 [沙盒](https://learn.chatgpt.com/docs/sandboxing)、[智能体审批与安全](https://learn.chatgpt.com/docs/agent-approvals-security)、[权限](https://learn.chatgpt.com/docs/permissions)、[规则](https://learn.chatgpt.com/docs/agent-configuration/rules)、[Windows 沙盒](https://learn.chatgpt.com/docs/windows/windows-sandbox) 和 [自动审核](https://learn.chatgpt.com/docs/sandboxing/auto-review) 整理。
:::

# 沙盒与审批
Expand All @@ -12,7 +12,7 @@ Codex 能读取代码、修改文件、执行命令。这些操作需要受控

沙盒和审批就是这套边界。

对于绝大多数人而言,只需要把 `Auto-Reivew` 模式打开就够了。本文章旨在让你更好地理解 Codex 的沙盒机制和审批策略,同时补充一些进阶用法。
对于绝大多数人而言,只需要把 `Auto-review` 模式打开就够了。本文章旨在让你更好地理解 Codex 的沙盒机制和审批策略,同时补充一些进阶用法。

当你在利用沙盒和权限机制来约束 Codex 行为的时候,你已经在实践 `Harness Engineering `,即“约束工程” 。

Expand Down Expand Up @@ -149,7 +149,7 @@ approval_policy = "on-request"
approvals_reviewer = "auto_review"
```

更多阅读:[Agent approvals & security:Automatic approval reviews](https://developers.openai.com/codex/agent-approvals-security#run-without-approval-prompts)。
更多阅读:[自动审核](https://learn.chatgpt.com/docs/sandboxing/auto-review)。

## 网络权限

Expand Down Expand Up @@ -266,7 +266,7 @@ approval_policy = { granular = {

这里的 `true` 表示该类请求保持交互审批;`false` 表示自动拒绝。它是 `on-request` 的进阶替代,不是 UI 选项。

更多详情请阅读:[Agent approvals & security:granular approval policy](https://developers.openai.com/codex/agent-approvals-security#run-without-approval-prompts)。
更多详情请阅读:[智能体审批与安全](https://learn.chatgpt.com/docs/agent-approvals-security#run-without-approval-prompts)。

## 平台差异

Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/08-thread-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Codex 自动线程管理指南:解释 thread、resume、fork、w
---

::: tip 最后核对
官方资料最后核对日期:2026-06-25。本文参考 [Kimi Code Agents and Sub-Agents](https://moonshotai.github.io/kimi-code/en/customization/agents)、[OpenAI Codex Subagents](https://developers.openai.com/codex/subagents)、[Codex CLI features](https://developers.openai.com/codex/cli/features) 和 [Codex App Worktrees](https://developers.openai.com/codex/app/worktrees) 整理。不同版本的 App、CLI 和移动端界面可能会变化,请以当前客户端为准。
官方资料最后核对日期:2026-09-04。本文参考 [Kimi Code Agents and Sub-Agents](https://moonshotai.github.io/kimi-code/en/customization/agents)、[Codex Subagents 官方文档](https://learn.chatgpt.com/docs/agent-configuration/subagents)、[Codex CLI 官方文档](https://learn.chatgpt.com/docs/codex/cli) 和 [Codex Worktrees 官方文档](https://learn.chatgpt.com/docs/environments/git-worktrees) 整理。不同版本的 App、CLI 和移动端界面可能会变化,请以当前客户端为准。
:::

# 自动线程管理
Expand Down
32 changes: 12 additions & 20 deletions docs/advanced/09-config-toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Codex config.toml 配置指南,说明模型、沙盒、审批、
---

::: tip 最后核对
官方资料最后核对日期:2026-05-27。本文参考 [Codex config basic](https://developers.openai.com/codex/config-basic)、[Codex config advanced](https://developers.openai.com/codex/config-advanced)、[Codex config reference](https://developers.openai.com/codex/config-reference) 与 [openai/codex config docs](https://github.com/openai/codex/blob/main/docs/config.md)。
官方资料最后核对日期:2026-09-04。本文参考 [Codex 配置基础](https://learn.chatgpt.com/docs/config-file/config-basic)、[Codex 高级配置](https://learn.chatgpt.com/docs/config-file/config-advanced)、[Codex 配置参考资料](https://learn.chatgpt.com/docs/config-file/config-reference) 与 [openai/codex 配置文档](https://github.com/openai/codex/blob/main/docs/config.md)。
:::

# 配置文件 config.toml
Expand All @@ -25,7 +25,7 @@ description: "Codex config.toml 配置指南,说明模型、沙盒、审批、

`config.toml` 保存 Codex 的持久配置,例如模型、沙盒、审批、profiles 和 MCP server。`~/.codex/.env` 更适合放 Desktop app 或 IDE extension 启动时需要读取的环境变量,例如 provider 需要的区域变量,或排障时临时验证过的代理变量。

OpenAI [Amazon Bedrock provider 文档](https://developers.openai.com/codex/amazon-bedrock)提醒:Desktop app 和 VS Code extension 可能不会继承当前 shell 里的环境变量;如果这些入口需要某些变量,可以把值放进 `~/.codex/.env`,然后重启 app 或 extension。
OpenAI [Amazon Bedrock 官方文档](https://learn.chatgpt.com/docs/amazon-bedrock)提醒:Desktop app 和 VS Code extension 可能不会继承当前 shell 里的环境变量;如果这些入口需要某些变量,可以把值放进 `~/.codex/.env`,然后重启 app 或 extension。

写入前先确认两件事:

Expand All @@ -52,21 +52,13 @@ export NO_PROXY="localhost,127.0.0.1,::1,*.local"
model = "gpt-5.1-codex-max"
approval_policy = "on-request"
sandbox_mode = "workspace-write"

[profiles.readonly]
approval_policy = "on-request"
sandbox_mode = "read-only"

[profiles.build]
approval_policy = "on-request"
sandbox_mode = "workspace-write"
```

这个示例表达三件事:

- 默认允许在当前工作区写文件。
- 高风险命令仍需要审批。
- 额外保留一个只读 profile,适合新仓库分析。
- 额外的只读 profile 写成独立文件 `~/.codex/readonly.config.toml`,适合新仓库分析。不要再使用 `[profiles.*]`

## 常见配置项按用途理解

Expand All @@ -86,7 +78,7 @@ sandbox_mode = "workspace-write"
适合打开陌生仓库、生成项目地图、梳理测试命令。

```toml
[profiles.readonly]
# ~/.codex/readonly.config.toml
sandbox_mode = "read-only"
approval_policy = "on-request"
```
Expand All @@ -106,7 +98,7 @@ codex --profile readonly
适合修测试、补文档、小范围实现。

```toml
[profiles.coding]
# ~/.codex/coding.config.toml
sandbox_mode = "workspace-write"
approval_policy = "on-request"
```
Expand All @@ -122,7 +114,7 @@ approval_policy = "on-request"
适合 PR review、发布前风险扫描、diff 总结。

```toml
[profiles.review]
# ~/.codex/review.config.toml
sandbox_mode = "read-only"
approval_policy = "on-request"
```
Expand Down Expand Up @@ -257,12 +249,12 @@ codex-provider restore <backup-dir>

## 官方资料延伸

- [Config basic](https://developers.openai.com/codex/config-basic)
- [Config advanced](https://developers.openai.com/codex/config-advanced)
- [Config reference](https://developers.openai.com/codex/config-reference)
- [Environment variables](https://developers.openai.com/codex/environment-variables)
- [Use Codex with Amazon Bedrock](https://developers.openai.com/codex/amazon-bedrock)
- [openai/codex config docs](https://github.com/openai/codex/blob/main/docs/config.md)
- [Codex 配置基础](https://learn.chatgpt.com/docs/config-file/config-basic)
- [Codex 高级配置](https://learn.chatgpt.com/docs/config-file/config-advanced)
- [Codex 配置参考资料](https://learn.chatgpt.com/docs/config-file/config-reference)
- [环境变量](https://learn.chatgpt.com/docs/config-file/environment-variables)
- [Amazon Bedrock 官方文档](https://learn.chatgpt.com/docs/amazon-bedrock)
- [openai/codex 配置文档](https://github.com/openai/codex/blob/main/docs/config.md)

## 下一步

Expand Down
Loading