codex

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Codex

Codex

Profiles

预设配置

  • (no profile) — read-only analysis (no compilation, no tests)
  • --profile edit
    — local edits, build, or test (
    workspace-write
    , full-auto)
  • --profile full
    — network or broad filesystem access (
    danger-full-access
    , full-auto)
Use
--profile edit
whenever the task involves
go test
,
go build
, or any command that writes build artifacts. The default read-only sandbox blocks all writes including compiler temp dirs.
For complex tasks, add
--config model_reasoning_effort="xhigh"
.
  • (无配置) — 只读分析(不编译、不测试)
  • --profile edit
    — 本地编辑、构建或测试(
    workspace-write
    ,全自动)
  • --profile full
    — 网络或广泛文件系统访问(
    danger-full-access
    ,全自动)
当任务涉及
go test
、
go build
或任何写入构建产物的命令时,请使用
--profile edit
。默认的只读沙箱会阻止所有写入操作,包括编译器临时目录的写入。
对于复杂任务,添加
--config model_reasoning_effort="xhigh"
参数。

Model Selection

模型选择

Default to the project model in
.codex/config.toml
(
gpt-5.4
).
Use
--model gpt-5.3-codex-spark
for speed-first interactive work:
  • tight back-and-forth iteration
  • quick bug fixes and targeted edits
  • small-to-medium refactors or UI tweaks
  • rapid prototyping where frequent redirect/interrupt is expected
Stay on default
gpt-5.4
for depth-first work:
  • long autonomous runs
  • broad multi-file changes with heavy reasoning
  • test-heavy or verification-heavy tasks
  • higher correctness/risk surfaces where deeper reasoning is worth the extra latency
If the user explicitly requests a model, follow the user's request.
默认使用
.codex/config.toml
中配置的项目模型(
gpt-5.4
)。
对于优先考虑速度的交互式工作,请使用
--model gpt-5.3-codex-spark
:
  • 紧密的来回迭代
  • 快速修复bug和定向编辑
  • 中小型重构或UI调整
  • 需要频繁重定向/中断的快速原型开发
对于深度优先的工作,请保持使用默认的
gpt-5.4
:
  • 长时间自主运行
  • 需要大量推理的广泛多文件更改
  • 重测试或重验证的任务
  • 高正确性要求/高风险场景,此时深度推理值得付出额外的延迟成本
如果用户明确指定了模型,请遵循用户的要求。

Commands

命令

Project defaults in
.codex/config.toml
. Always include
--skip-git-repo-check
and
2>/dev/null
. Only override model when the user explicitly requests it, or when the task clearly fits the Spark speed-first criteria above.
Use caseCommand
Read-only analysis
codex exec --skip-git-repo-check -o "$CODEX_OUT" "prompt" 2>/dev/null
Speed-first interactive loop (Spark)add
--model gpt-5.3-codex-spark
Apply local editsadd
--profile edit
Network / broad accessadd
--profile full
Resume session
echo "prompt" | codex exec --skip-git-repo-check -o "$CODEX_OUT" resume --last 2>/dev/null
Create a temp file for output before running:
CODEX_OUT=$(mktemp /tmp/codex-out.XXXXXX)
. Read the result from
$CODEX_OUT
after completion.
Run with Bash
run_in_background: true
. Monitor via
TaskOutput
with
block: true, timeout: 600000
— do NOT use
sleep
commands to poll. Read the
-o
file for the final answer.
项目默认配置在
.codex/config.toml
中。始终包含
--skip-git-repo-check
和
2>/dev/null
参数。仅当用户明确要求,或任务明显符合上述Spark速度优先标准时,才覆盖模型配置。
使用场景命令
只读分析
codex exec --skip-git-repo-check -o "$CODEX_OUT" "prompt" 2>/dev/null
速度优先交互式循环(Spark)添加
--model gpt-5.3-codex-spark
应用本地编辑添加
--profile edit
网络/广泛访问添加
--profile full
恢复会话
echo "prompt" | codex exec --skip-git-repo-check -o "$CODEX_OUT" resume --last 2>/dev/null
运行前创建一个临时文件用于输出:
CODEX_OUT=$(mktemp /tmp/codex-out.XXXXXX)
。运行完成后从
$CODEX_OUT
中读取结果。
使用Bash运行,设置
run_in_background: true
。通过
TaskOutput
进行监控,设置
block: true, timeout: 600000
— 请勿使用
sleep
命令轮询。读取
-o
参数指定的文件获取最终结果。

Resuming

恢复会话

Don't pass model/effort/sandbox flags when resuming — original session settings carry over.
-o
is safe to include.
恢复会话时不要传递模型/推理强度/沙箱相关参数 — 原始会话的设置会自动沿用。包含
-o
参数是安全的。

Conventions

约定

This is a Go project. Use
go test
,
go build
,
go vet
in prompts. Codex workers don't receive CLAUDE.md or hooks, so project conventions must be explicit.
这是一个Go项目。在提示词中使用
go test
、
go build
、
go vet
命令。Codex worker不会接收CLAUDE.md或hooks,因此项目约定必须明确。

Post-Execution Verification

执行后验证

Always verify Codex output via
git diff --stat
— never trust the worker's self-reported file list. Codex workers may make out-of-scope changes (deleting files, reverting unrelated code, removing test functions). The completion promise may list only intended files while omitting destructive side effects.
When other work exists in the same codebase, include explicit "DO NOT modify or delete" file lists in the prompt. The positive instruction ("only touch these files") is insufficient — Codex interprets "clean up" broadly.
Per [[principles/prove-it-works]]: trust artifacts, not self-reports.
始终通过
git diff --stat
验证Codex的输出
— 切勿信任worker自行报告的文件列表。Codex worker可能会做出超出范围的更改(删除文件、还原不相关的代码、移除测试函数)。完成承诺可能仅列出预期修改的文件,而遗漏破坏性的副作用。
当同一代码库中存在其他工作时,请在提示词中包含明确的“请勿修改或删除”的文件列表。正向指令(“仅修改这些文件”)是不够的 — Codex会宽泛地解释“清理”的含义。
根据[[principles/prove-it-works]]:信任产物,而非自我报告。

Worktree Usage

工作树使用

With
-C <worktree-dir>
, the worktree has its own git index.
.claude/
may symlink to
.agents/
— use
.agents/
paths for git operations.
使用
-C <worktree-dir>
时,工作树有自己的git索引。
.claude/
可能符号链接到
.agents/
— 执行git操作时请使用
.agents/
路径。