原文核对:2026-10-13 · 中文正文 · 英文提示词与演示
场景定位
当任务需要 Codex 跨多个对话轮次持续工作,直到达到可验证的停止条件时,使用 /goal。
- 难度
- 高级
- 时间跨度
- 长时间运行
适合用于
- 具有明确成功条件和验证循环的长时间编程任务。
- 代码迁移、大型重构、部署重试循环、实验、游戏和个人项目;Codex 可以持续在明确范围内推进。
- 需要按明确成功标准进行长时间实验的团队。
起步提示词
英文原文 · 可复制后按实际材料修改
/goal Complete [objective] without stopping until [verifiable end state].简介
如果希望 Codex 持续推进一个目标,而不是在普通的一轮对话后停下,可以使用 /goal。它适合目标明确、有验证循环,并且允许 Codex 自主推进而不必每一步都由你指导的工作。使用 /goal 时,Codex 可以独立工作数小时,无需你继续输入。
通过 /goal <objective> 设置目标;使用 /goal 查看当前目标;需要控制运行时,使用 /goal pause、/goal resume 或 /goal clear。
如果斜杠命令列表中没有 /goal,请在 config.toml 中启用 features.goals:
[features]
goals = true也可以在 CLI 中运行 codex features enable goals,或让 Codex 帮你运行。
选择合适的任务
合适的目标通常比一条提示词的任务更大,但小于一个没有边界的待办列表。它应说明 Codex 要实现什么、哪些内容不应改动、如何验证进度,以及何时停止。
以下任务比较适合:
- 目标技术栈、功能一致性检查和约束都很清楚的代码迁移。
- 每完成一个检查点都能运行测试的大型重构。
- 可以持续改进可运行成果的实验、游戏或原型。
不要把一组松散且互不相关的工作混在同一个目标中。
建立工作循环
- 明确一个目标和一个停止条件。
- 指出必须先阅读的文件、文档、issue、日志或计划。
- 定义哪些命令或产物能够证明进展。
- 要求按检查点推进,并保留简短的进度记录。
- 运行期间使用 /goal 查看状态。
- 当任务完成、受阻或需要改变方向时,暂停、恢复或清除目标。
关键是事先约定验收标准。Codex 开始前就应知道什么算“完成”。迁移任务的完成标准可以是新路径通过契约测试,同时旧路径仍有回滚方案;游戏或原型的标准可以是应用能构建、启动,并符合参考材料或预期行为。
也可以请 Codex 协助制定目标:先讨论你想构建什么,再让它直接设置目标并开始工作。
让 Codex 独立推进
执行目标期间,可以要求提供简短的进度报告。有效的报告应说明当前检查点、已经验证的内容、剩余工作,以及是否遇到阻碍。如果状态描述变得模糊,应把目标写得更明确:说明下一个重要检查点、用哪个命令验证,以及什么情况需要暂停。
持续执行目标时,Codex 可以独立工作数小时,不需要你不断跟进。它确信达到停止条件后会结束运行,因此可以把 /goal 当作不必持续盯着的后台任务。
目标示例
迁移
无论是将游戏迁移到新技术栈、将移动应用迁移到新平台,还是让代码库采用新框架,都可以通过 /goal 让 Codex 执行迁移:
官方提示词
英文原文 · 可复制后按实际材料修改
/goal Migrate this project from [legacy stack or system] to [target stack or system]. Make sure all screens stay exactly the same visually, using playwright interactive to verify the output.创建原型
从零构建应用、游戏或新功能时,可以用 /goal 让 Codex 完成经过打磨的首个版本。用 PLAN.md 精确描述要构建的内容,可以指导首版实现。
官方提示词
英文原文 · 可复制后按实际材料修改
/goal Implement PLAN.md, creating tests for each milestone and verifying the output with playwright interactive. [include reference screens as needed]优化提示词
如果已有评测集,可以通过 /goal 根据评测结果优化提示词。Codex 能检查失败案例、调整提示词、重新运行评测,并持续迭代,直到分数改善或达到你设定的停止条件。
官方提示词
英文原文 · 可复制后按实际材料修改
/goal Optimize the prompts in [prompt file or directory] until the eval suite reaches [target score or pass rate]. After each change, run [eval command], inspect the failing cases, and keep the prompt edits minimal and targeted. Stop when the target is met or when further prompt changes would need product or policy guidance.展开英文原文对照
Use /goal when a task needs Codex to keep working across turns toward a verifiable stopping condition.
Introduction
Use /goal when you want Codex to keep working toward one durable objective instead of stopping after one normal turn. It’s useful for work that has a clear target, a validation loop, and enough room for Codex to make progress without asking you to steer every step. When you use /goal, Codex can work independently for multiple hours without needing your input.
Set a goal with /goal <objective>, check the current goal with /goal, and use /goal pause, /goal resume, or /goal clear when you need to control the run.
If /goal doesn’t appear in the slash command list, enable features.goals in config.toml:
[features]
goals = trueYou can also run codex features enable goals from the CLI or ask Codex to run it.
Choose the right work
A good goal is bigger than one prompt but smaller than an open-ended backlog. It should define what Codex should achieve, what it shouldn’t change, how it should validate progress, and when it should stop.
This works well for:
- code migration where the target stack, parity checks, and constraints are clear
- large refactors where Codex can run tests after each checkpoint
- experiments, games, or prototypes where Codex can keep improving a working artifact
Avoid using a goal for a loose list of unrelated work.
Set up the loop
- Name one objective and one stopping condition.
- Point Codex at the files, docs, issue, logs, or plan it must read first.
- Define the commands or artifacts that prove progress.
- Tell Codex to work in checkpoints and keep a short progress log.
- Use /goal to inspect status while it runs.
- Pause, resume, or clear the goal when the run is done, blocked, or changing direction.
The important part is the contract. Codex should know what “done” means before it starts. If the goal is a migration, “done” might mean the new path passes contract tests and the legacy path still has a rollback. If the goal is a game or prototype, “done” might mean the app builds, launches, and matches the input reference or expected behavior.
Ask Codex to help: start by having a conversation about what you want to build, then ask it to directly set a goal and start working.
Let Codex work independently
During a goal, ask for compact progress reports that make the run easier to trust. A useful status update names the current checkpoint, what was verified, what remains, and whether Codex is blocked. If the status becomes vague, tighten the goal rather than adding more one-off instructions. Tell Codex exactly which checkpoint matters next, which command proves it, and what should cause it to pause.
When Codex follows a goal, it can work independently for many hours without you having to check in. It will stop running when it’s confident it has reached the stopping condition, so you should think of /goal as a background task you don’t need to monitor.
Example goals
Migrations
Whether you’re migrating games to a new stack, mobile apps to a new platform, or a codebase to a new framework, you can use /goal to have Codex run the migration:
官方提示词
英文原文 · 可复制后按实际材料修改
/goal Migrate this project from [legacy stack or system] to [target stack or system]. Make sure all screens stay exactly the same visually, using playwright interactive to verify the output.Prototype creation
Whether you’re creating a new app from scratch, a new game, or a new feature, you can use /goal to have Codex complete a polished first version. You can use a PLAN.md file to guide the creation of the first version, describing precisely what you want to build.
官方提示词
英文原文 · 可复制后按实际材料修改
/goal Implement PLAN.md, creating tests for each milestone and verifying the output with playwright interactive. [include reference screens as needed]Prompt optimization
When you have an eval suite, you can use /goal to optimize prompts against the eval results. Codex can inspect failures, update the prompt, rerun the evals, and keep iterating until the score improves or it reaches your stopping condition.
官方提示词
英文原文 · 可复制后按实际材料修改
/goal Optimize the prompts in [prompt file or directory] until the eval suite reaches [target score or pass rate]. After each change, run [eval command], inspect the failing cases, and keep the prompt edits minimal and targeted. Stop when the target is met or when further prompt changes would need product or policy guidance.