← Back to learning path
Chapter · Published

Codex task execution and verification loop

Use a repeatable loop to plan a Codex task, inspect the diff, run verification, and handle failures without claiming success too early.

Source: start/08-task-execution.md快速上手 (original language)
Chapter progress 0%Learning path progress 0% · 0/46 chapters completedContinue learning path →

Tip · Last checked

The workflow was checked on 2026-09-02. For current CLI behavior, permissions, and approvals, use the Codex CLI documentation, permissions, and agent approvals and security.

Codex task execution and verification loop

A reliable task has six stages: state the goal, map the repository, make a small change, inspect the diff, run verification, and record the result.

State the goal -> map the work -> make a small change -> inspect the diff -> run checks -> record the result

1. State the task clearly

Name the expected result, relevant context, allowed scope, constraints, verification command, and delivery format. A request such as “fix it” leaves too many decisions implicit.

2. Ask for a read-only map

For a multi-file change, ask Codex to identify the project purpose, key directories, affected interfaces, risks, and a minimal sequence before editing. This makes the boundary reviewable.

3. Work in small steps

Separate a file move, navigation change, implementation, and verification when possible. A small diff is easier to review and easier to roll back.

4. Inspect the diff

Check that unrelated files were not changed, links still resolve, headings remain ordered, and the patch matches the requested scope.

5. Run verification

Use the narrowest useful test first, then typecheck or build when the change crosses a shared boundary. Record the exact command and result rather than inferring success from a page that happens to render.

6. Handle failures honestly

Keep the error output, decide whether it came from the change or the environment, and fix only the relevant cause. Re-run the same check after the fix and list anything that remains unverified.

Completion checklist

  • The requested files and behavior changed.
  • The diff contains no unrelated work.
  • Tests, type checks, or browser checks have evidence.
  • Rollback and remaining risks are clear.

Next step

Continue with the Codex CLI installation guide.

Code examples

说明目标 -> 让它建图 -> 小步执行 -> 检查 diff -> 运行验证 -> 记录结果
请只读分析当前项目的文档结构,不要修改文件。
请指出首页、学习路线和侧边栏之间不一致的地方。
输出:问题列表、涉及文件、建议调整顺序。
请更新 docs/start/06-first-task.md 中的下一步链接。
只修改这个文件。
完成后说明改了哪里,不需要运行构建。
请按文件说明这次 diff 的目的。
指出哪些是移动文件,哪些是链接更新,哪些是正文修改。
构建失败了。请判断这是本次改动导致,还是环境依赖问题。
不要修改文件,先给出证据和下一步建议。

Reference tables

任务类型常见验证
文档链接搜索旧路径、检查相对链接
前端页面运行构建、打开页面截图
代码修改跑单元测试、类型检查、lint
配置修改查询当前状态、启动一次最小任务
发布任务检查访问地址、日志、状态码

Further reading

KnowledgeDesigning Reliable AI Automation WorkflowsKnowledgeAI Agents: From Core Concepts to ProductionKnowledgeStructured Outputs and Tool Contracts for Safe Agents
Product Hub Demo · V0.3