AI Learn
OpenAI · Codex Tutorial

Use Codex CLI for one complete repository task

Launch Codex from the correct repository, inspect before editing, set permissions, make one bounded change, run checks and review the result.

Reviewed September 20, 2026Independent tutorialFeatures may vary
Not official support. AI Learn is an independent education site and is not affiliated with OpenAI. Check the provider’s current documentation for plan-specific limits, pricing and feature availability.
Before you start

Codex CLI works directly in your terminal and can inspect files, edit code and run local tools. Start from a clean Git state and use the permission profile appropriate to the repository.

1. Start in the intended repository

cd into the repository, inspect git status, then run codex. Confirm the displayed working directory before giving a task.

2. Ask for inspection first

For an unfamiliar project, ask Codex to explain structure, relevant commands and likely files. Do not start with “rewrite this app.”

3. Set the permission boundary

Use /permissions or the configured profile to decide when Codex can edit, execute commands or access other resources. Keep the first run conservative.

4. Make one bounded change

Describe the expected behavior, files that may change and acceptance checks. Let Codex edit only after the plan makes sense.

5. Review and run checks

Use /review or inspect the diff, run relevant tests/lint/typecheck, and compare behavior with the acceptance criteria before committing.

Try this prompt

Inspect this repository first. Tell me the files and checks relevant to [task]. Propose a minimal plan. Do not edit until the plan is clear; after editing, run the existing checks and summarize the diff and remaining risks.

Common mistakes

Starting Codex from the wrong directory; granting broad permissions before understanding the repo; mixing unrelated fixes; accepting edits without tests or review.

Finish check

The change is limited to the intended behavior, repository checks are run, and every important diff is understandable before commit.

开始之前

Codex CLI 直接在终端中工作,可以检查文件、编辑代码并运行本地工具。开始前保持 Git 状态清楚,并为这个仓库选择合适权限。

1. 在目标仓库里启动

cd 到正确仓库,先看 git status,再运行 codex。给任务之前确认界面显示的 working directory 没错。

2. 先让它检查项目

面对不熟悉的项目,先让 Codex 解释结构、常用命令和可能相关文件,不要第一句话就说“重写这个应用”。

3. 设置权限边界

通过 /permissions 或已有权限配置决定它什么时候能编辑、执行命令或访问其他资源,第一次运行保持保守。

4. 只做一个有边界的改动

明确期望行为、允许修改的文件和验收检查。方案合理之后再让 Codex 真正动代码。

5. 审查并运行检查

使用 /review 或自己看 diff,运行相关测试、lint、类型检查,并与验收标准对照后再提交。

可以直接套用的提示词

先检查这个仓库,告诉我与【任务】相关的文件和检查,并提出最小改动计划。方案清楚前不要编辑;完成后运行现有检查,总结 diff 和剩余风险。

常见错误

从错误目录启动 Codex;还不了解仓库就给过宽权限;顺手混入无关修复;没有测试和审查就接受改动。

完成检查

完成后,改动只影响预期行为,仓库检查已经运行,而且提交前你能解释每一处重要 diff。

開始之前

Codex CLI 直接在終端中工作,可以檢查檔案、編輯代碼並運行本地工具。開始前保持 Git 狀態清楚,並為這個倉庫選擇合適權限。

1. 在目標倉庫里啓動

cd 到正確倉庫,先看 git status,再運行 codex。給任務之前確認界面顯示的 working directory 沒錯。

2. 先讓它檢查專案

面對不熟悉的專案,先讓 Codex 解釋結構、常用指令和可能相關檔案,不要第一句話就說“重寫這個應用”。

3. 設置權限邊界

通過 /permissions 或已有權限配置決定它甚麼時候能編輯、執行指令或訪問其他資來源,第一次運行保持保守。

4. 只做一個有邊界的改動

明確期望行為、允許修改的檔案和驗收檢查。方案合理之後再讓 Codex 真正動代碼。

5. 審查並運行檢查

使用 /review 或自己看 diff,運行相關測試、lint、類型檢查,並與驗收標準對照後再提交。

可以直接套用的提示詞

先檢查這個倉庫,告訴我與【任務】相關的檔案和檢查,並提出最小改動計劃。方案清楚前不要編輯;完成後運行現有檢查,總結 diff 和剩餘風險。

常見錯誤

從錯誤目錄啓動 Codex;還不瞭解倉庫就給過寬權限;順手混入無關修復;沒有測試和審查就接受改動。

完成檢查

完成後,改動只影響預期行為,倉庫檢查已經運行,而且提交前你能解釋每一處重要 diff。

Official references

Check current product details at the source

Related practical tutorials

Continue with another single-task workflow.

All tutorials →