Codex CLI:權威技術參考指南
# Codex v0.130(2026年5月8日)新增codex remote-control進入點、多環境view_image解析、透過AWS console-login憑證進行Bedrock身分驗證、app-server執行緒分頁、具備可探索性控制的plugin-bundled hook可見性、即時設定重新整理、可設定的OpenTelemetry追蹤中繼資料,以及Linux與Windows上的沙盒強化。
Codex v0.130(2026年5月8日)新增codex remote-control進入點、多環境view_image解析、透過AWS console-login憑證進行Bedrock身分驗證、app-server執行緒分頁、具備可探索性控制的plugin-bundled hook可見性、即時設定重新整理、可設定的OpenTelemetry追蹤中繼資料,以及Linux與Windows上的沙盒強化。
重點摘要: Codex是多介面程式編寫代理,可讀取您的程式碼庫、在作業系統層級的沙箱中執行命令、修補檔案,並將任務委派給雲端。掌握五大核心系統(config.toml、沙箱/核准模型、AGENTS.md、MCP與skills),Codex便能成為效能倍增器。利用設定檔切換上下文、用
/compact管理上下文預算、用/goal保存工作目標,並透過AGENTS.md建立跨工具專案指令,可同時在Codex、Cursor、Amp等多種工具中運作。GPT-5.5(2026年4月23日推出)是Codex中建議的預設模型 — 在Codex中提供400K上下文視窗(在API中達1M),每MTok費用為$5/$30,並締造82.7%的Terminal-Bench 2.0 SOTA紀錄。83 截至CLI v0.130.0(2026年5月8日),Codex新增最上層的codex remote-control命令以實現無介面app-server控制、多環境view_image解析、透過AWSaws login主控台登入憑證進行Bedrock驗證、app-server執行緒分頁、為內建hooks提供帶share-link詮釋資料及可探索性控制的plugin詳細資訊可見性、執行中執行緒的即時設定重新整理、可設定的OpenTelemetry追蹤詮釋資料,以及Linux和Windows上持續強化的沙箱。v0.129.0(2026年5月7日)加入了模態Vim編輯(/vim)、重新設計的工作流程選擇器、TUI內建的/hooks瀏覽器、感知主題的狀態列、含marketplace操作的plugin工作區共享,以及/goal生命週期的變更。請繼續優先使用明確的沙箱/核准旗標或權限設定檔,而非舊版的--full-auto;js_repl仍維持移除狀態。86878991
Codex作為多介面程式編寫代理運作,並非僅是會寫程式的聊天機器人。CLI可讀取您的程式碼庫、在沙箱中執行命令、修補檔案、透過MCP連接外部服務,並將長時間執行的任務委派至雲端。它在本機執行但思維涵蓋全域;同一套智慧依您的工作方式驅動五種不同的介面,包括能在瀏覽器中執行Codex而不接管瀏覽器的全新Chrome擴充功能。90
隨意使用與有效運用Codex的差別,歸結於五大核心系統。 掌握這些,Codex便能成為效能倍增器:
- 設定系統:透過
config.toml控制行為 - 沙箱與核准模型:管控Codex能執行的操作
- AGENTS.md:定義專案層級的運作契約
- MCP協定:將能力延伸至外部服務
- Skills系統:封裝可重複使用的領域專業知識
我花了數月時間,在生產程式碼庫、CI/CD管線及團隊工作流程中將Codex與Claude Code並行運作。本指南將該經驗提煉成我當初入門時所期盼的完整參考資料。每項功能都包含實際語法、真實設定範例,以及連資深使用者也容易踩到的邊界情況。
穩定性說明:標示為
[EXPERIMENTAL]或under development的功能在版本之間可能會有變動。截至v0.130.0(2026年5月8日),Codex Cloud與code mode仍為實驗性或開發中,而核心CLI、沙箱機制、AGENTS.md、config.toml、Skills、hooks、多代理工具及plugins皆為穩定介面。v0.130.0新增了codex remote-control最上層命令(為無介面、可遠端控制的app-server提供更簡單的進入點)、多環境view_image解析、透過AWSaws login主控台登入憑證進行Bedrock驗證、含未載入/摘要/完整輪次檢視的app-server執行緒分頁、為內建hooks提供plugin詳細資訊可見性以及share-link詮釋資料與可探索性控制、即時app-server設定重新整理(執行中執行緒無須重啟即可採用設定變更)、從codex exec啟動橫幅中移除「research preview」字樣、可設定的OpenTelemetry追蹤詮釋資料、Linux沙箱啟動強化,以及為桌面執行階段二進位快取提供Windows沙箱授權。91 v0.129.0(2026年5月7日)為輸入區加入了模態Vim編輯(/vim與可設定的預設模式)、重新設計的TUI工作流程選擇器(更容易恢復/分支、原始捲動歷史)、/hooks瀏覽器、含選用PR與分支摘要的感知主題狀態列、plugin工作區共享與marketplace操作與共享存取控制與來源篩選、/goal生命週期變更(實驗性目標在恢復時保持暫停狀態,除非主動重新啟用)、Linux沙箱啟動強化、Windows沙箱可靠性改善,以及將Bubblewrap升級至0.11.2並套用上游安全性修補。89 v0.128.0(2026年4月30日)導入了持久化的/goal工作流程、codex update、可設定的TUI鍵盤對應,以及擴充的權限設定檔;舊版的--full-auto仍維持棄用狀態,且js_repl仍維持移除狀態。8687
重點摘要
- 五個介面,同一個大腦:CLI、桌面應用程式、IDE 擴充功能、雲端任務以及全新的 Chrome 擴充功能皆共享同一套 GPT-5.x-Codex 智慧核心,因此請挑選最適合您工作流程的介面。90
- 作業系統層級沙箱:Codex 在核心層級(macOS 上的 Seatbelt、Linux 上的 Landlock + seccomp)強制執行檔案系統與網路限制,而非在容器內。
- AGENTS.md 跨工具通用:您的專案指令可在 Codex、Cursor、Copilot、Amp、Jules、Gemini CLI、Windsurf、Cline、Aider、Zed 以及 60,000 多個開源專案中運作。寫一次,到處可用。
- Profiles 節省切換情境的負擔:定義具名的設定預設組合(
fast、careful、auto),並透過--profile在它們之間切換。 - 情境管理至關重要:GPT-5.4 提供 1M 情境;GPT-5.4 mini 為子代理工作提供 400K;GPT-5.3-Codex 提供 272K 輸入。請善用
/compact、聚焦的提示與@file參考來主動管理 token 預算。
如何使用本指南
這是一份超過 2,500 行的參考文件——請從符合您經驗等級的地方開始:
| 經驗等級 | 從這裡開始 | 接著探索 |
|---|---|---|
| Codex 新手 | 安裝 → 快速入門 → 思維模型 | 設定、沙箱 |
| 日常使用者 | AGENTS.md、Skills、Plan Mode | MCP、Hooks |
| 團隊主管 / 企業 | 企業部署 → 最佳實務與反模式 | 決策框架、工作流程食譜 |
| 從其他工具遷移 | 遷移指南 | 決策框架 |
文末的 快速參考卡 提供所有主要指令的可掃讀摘要。
Codex 如何運作:思維模型
在深入功能之前,請先理解 Codex 的架構如何形塑您使用它的每一個環節。整個系統橫跨四個介面,並由共享的智慧層支撐:
┌─────────────────────────────────────────────────────────┐
│ CODEX SURFACES │
├─────────────────────────────────────────────────────────┤
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────┐ │
│ │ CLI │ │ Desktop │ │ IDE │ │ Cloud │ │
│ │ Terminal │ │ App │ │Extension │ │ Tasks │ │
│ └──────────┘ └──────────┘ └──────────┘ └────────┘ │
│ Local exec Multi-task Editor-native Async │
│ + scripting + worktrees + inline edits detached │
├─────────────────────────────────────────────────────────┤
│ EXTENSION LAYER │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ MCP │ │ Skills │ │ Apps │ │ Search │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ External tools, reusable expertise, ChatGPT │
│ connectors, web search (cached + live) │
├─────────────────────────────────────────────────────────┤
│ SECURITY LAYER │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Sandbox (Seatbelt / Landlock / seccomp) │ │
│ │ + Approval Policy (untrusted → never) │ │
│ └─────────────────────────────────────────────────┘ │
│ OS-level filesystem + network restrictions │
├─────────────────────────────────────────────────────────┤
│ CORE LAYER │
│ ┌─────────────────────────────────────────────────┐ │
│ │ GPT-5.x-Codex Intelligence │ │
│ │ Tools: Shell, Patch, Read, Web Search │ │
│ │ (legacy artifact, read_file, grep_files │ │
│ │ removed in v0.117.0) │ │
│ └─────────────────────────────────────────────────┘ │
│ Shared model across all surfaces; costs tokens │
└─────────────────────────────────────────────────────────┘
核心層:GPT-5.x 模型家族驅動一切。截至 2026 年 4 月 23 日,只要可用,gpt-5.5 即為建議模型——在 Codex 中提供 400K 情境(API 中為 1M),Terminal-Bench 2.0 達到 82.7% SOTA。gpt-5.4 在推出期間仍為備援預設值(1M 情境、原生電腦使用能力)。8364 它讀取檔案、撰寫修補檔、執行 shell 指令並對您的程式碼庫進行推理。當情境填滿時,Codex 會壓縮對話以釋出空間。此層會消耗 token。
安全層:Codex 執行的每一個指令都會通過作業系統層級的沙箱。在 macOS 上,Apple 的 Seatbelt 框架強制執行核心層級的限制。在 Linux 上,Landlock + seccomp 過濾檔案系統與系統呼叫存取。沙箱在核心層級運作,而非在容器內。接著由核可政策決定何時要求人類確認。
擴充層:MCP 連接外部服務(GitHub、Figma、Sentry)。Skills 封裝可重複使用的工作流程,讓 Codex 視需要載入。Apps 連接到 ChatGPT 連接器。網路搜尋從網際網路加入即時情境。
介面層:CLI 適合終端機高手與自動化。桌面應用程式適合多執行緒專案管理。IDE 擴充功能適合「編輯-編譯-測試」迴圈。雲端則適合獨立執行的非同步任務。
關鍵洞察:多數使用者只用其中一個介面。進階使用者則四個全用:用雲端處理長時間任務、用 CLI 進行可預測的儲存庫操作、用 IDE 擴充功能維持緊密的程式設計迴圈,並用桌面應用程式進行規劃與協調。
目錄
- 我該如何安裝 Codex?
- 快速入門:您的第一個工作階段
- 核心互動介面
- 設定系統深度剖析
- 我該選擇哪個模型?
- Codex 的成本是多少?
- 決策框架
- 沙箱與核可系統如何運作?
- AGENTS.md 如何運作?
- Hooks
- 什麼是 MCP(Model Context Protocol)?
- Code Mode
- JavaScript REPL 執行環境
- 什麼是 Skills?
- Plugins
- Plan Mode 與協作
- 記憶系統
- 工作階段管理
- 非互動模式(codex exec)
- Codex Cloud 與背景任務
- Codex 桌面應用程式
- GitHub Action 與 CI/CD
- Codex SDK
- 效能最佳化
- 我該如何除錯?
- 企業部署
- 最佳實務與反模式
- 工作流程食譜
- 遷移指南
- 快速參考卡
- 變更記錄
- 參考資料
如何安裝 Codex?
套件管理工具
# npm (recommended)
npm install -g @openai/codex
# Homebrew (macOS)
brew install --cask codex
# winget (Windows)
winget install OpenAI.Codex
# Upgrade to latest
npm install -g @openai/codex@latest
直接安裝指令碼(v0.106.0+)
在 macOS 與 Linux 上,可使用單行安裝指令碼,作為 GitHub release 資產提供:60
curl -fsSL https://github.com/openai/codex/releases/latest/download/install.sh | sh
此指令碼會自動偵測平台與架構,下載正確的二進位檔,並將其放入您的 PATH。
二進位檔下載
若環境中沒有 npm 或 Homebrew,請從 GitHub Releases 下載平台專用的二進位檔:1
| 平台 | 二進位檔 |
|---|---|
| macOS Apple Silicon | codex-aarch64-apple-darwin.tar.gz |
| macOS x86_64 | codex-x86_64-apple-darwin.tar.gz |
| Linux x86_64 | codex-x86_64-unknown-linux-musl.tar.gz |
| Linux arm64 | codex-aarch64-unknown-linux-musl.tar.gz |
系統需求
- macOS:Apple Silicon 或 Intel(透過 Seatbelt 提供完整沙盒支援)
- Linux:x86_64 或 arm64(透過 Landlock + seccomp 提供沙盒)
- Windows:具備受限制權杖的原生沙盒(已在 v0.100.0 從實驗性功能升級)。也支援 WSL2
驗證
codex login # Interactive OAuth (recommended)
codex login --device-auth # OAuth device code flow (headless)
codex login --with-api-key # API key from stdin
codex login status # Check auth state (exit 0 = logged in)
codex logout # Clear stored credentials
兩種驗證方式:
- ChatGPT帳戶(建議):使用現有的 Plus、Pro、Team、Business、Edu 或 Enterprise 訂閱登入。可完整使用包含雲端工作在內的功能。
- API Key:透過
CODEX_API_KEY環境變數或codex login --with-api-key設定。部分功能(雲端 threads)可能無法使用。
專家提示:憑證儲存可透過
config.toml中的cli_auth_credentials_store設定。選項包含:file(預設)、keyring(作業系統鑰匙圈)或auto(若可用則使用 keyring,否則退回 file)。
Shell 補全
# Generate completions for your shell
codex completion bash > /etc/bash_completion.d/codex
codex completion zsh > ~/.zsh/completions/_codex
codex completion fish > ~/.config/fish/completions/codex.fish
驗證安裝
codex --version
# codex-cli 0.130.0
快速開始:您的第一次 Session
從零開始,在 5 分鐘內進入可產出的狀態。
1. 安裝並驗證:
npm i -g @openai/codex # Install
codex login # Log in with your OpenAI account
2. 前往專案:
cd ~/my-project # Any git repo works
3. 啟動 Codex:
codex
您會看到互動式 TUI。Codex 會自動讀取專案結構。
4. 提出問題:
> What does this project do? Summarize the architecture.
Codex 會讀取關鍵檔案並說明程式碼庫。在預設的 suggest 模式下不會進行任何變更。
5. 進行變更:
> Add input validation to the login endpoint
Codex 會以 diff 形式提出編輯建議。檢閱後用 y 核准,或用 n 拒絕。
6. 使用 slash command:
> /plan Refactor the database layer to use connection pooling
Codex 會建立計畫但不執行。請先檢閱計畫,再核准開始執行。
7. 檢查您的工作:
> /diff
查看 Codex 在目前 session 中所做的所有變更。
下一步:
- 設定含專案指示的 AGENTS.md(請參閱 AGENTS.md 如何運作?)
- 為您的工作流程設定 profile(請參閱 Profiles)
- 嘗試使用 codex exec 進行非互動式自動化(請參閱 Non-Interactive Mode)
核心互動介面
Codex 提供四種不同的介面,背後皆由相同的智能驅動。每種介面針對不同的工作流程模式進行最佳化。
1. 互動式 CLI(Terminal UI)
codex # Launch TUI
codex "fix the failing tests" # Launch with initial prompt
codex -m gpt-5.5 # Specify model
codex --sandbox workspace-write --ask-for-approval on-request
終端機 UI 是一個全螢幕應用程式,包含:
- Composer:輸入提示、以
@附加檔案、以!前綴執行 shell 命令 - 輸出窗格:串流模型回應、工具呼叫與命令輸出
- 狀態列:模型、token 用量、git 分支、sandbox 模式
主要 TUI 快捷鍵:
| 快捷鍵 | 動作 |
|---|---|
@ |
模糊檔案搜尋(附加至內容) |
!command |
直接執行 shell 命令 |
Ctrl+G |
開啟外部編輯器($VISUAL / $EDITOR) |
Ctrl+R |
反向歷史搜尋(v0.121.0+)——以 readline 風格搜尋先前的提示,包含先前回合中發出的斜線命令82 |
Enter(執行中時) |
在回合進行中插入新指令 |
Esc 兩次 |
編輯先前的訊息 |
| 方向鍵 | 瀏覽草稿歷史 |
狀態列變更(v0.121.0): 狀態列中舊有的內容視窗計量器已替換為 context-percent indicator,顯示您的內容視窗使用了多少。如果您有腳本或 hooks 在解析狀態列,請檢查此格式變更。82 當有新版本可用時,Codex 也會顯示 CLI 更新通知。
TUI 中可用的 Slash 命令:
| 命令 | 描述 |
|---|---|
/quit 或 /exit |
退出 CLI |
/new |
在同一工作階段中開始新對話 |
/resume |
恢復已儲存的對話 |
/fork |
將目前對話分支為新執行緒 |
/model |
切換模型與推理強度 |
/compact |
摘要對話以釋放 tokens |
/diff |
顯示包含未追蹤檔案的 git diff |
/review |
工作樹的程式碼審查 |
/plan |
進入 plan 模式 |
/goal |
建立、暫停、恢復或清除持久化的工作目標(v0.128.0+)。v0.129.0 的生命週期變更: 實驗性目標現在會在 resume 後維持暫停狀態,除非明確重新啟用。 |
/vim |
在 composer 中切換模態 Vim 編輯(v0.129.0+)。 透過 TUI keymap 設定將 Vim 設為預設編輯模式。89 |
/hooks |
從 TUI 瀏覽並切換生命週期 hooks(v0.129.0+)。 探索可用的 hooks、查看哪些處於啟用狀態,並可在不離開工作階段的情況下切換個別 hooks。89 |
/mention |
將檔案附加至對話 |
/init |
產生 AGENTS.md 鷹架 |
/status |
工作階段設定與 token 用量 |
/permissions |
設定核准策略 |
/personality |
溝通風格(friendly/pragmatic/none) |
/mcp |
列出已設定的 MCP 工具 |
/apps |
瀏覽 ChatGPT connectors |
/ps |
顯示背景終端機 |
/skills |
存取並呼叫 skills |
/plugins |
瀏覽並管理已安裝的 plugins(v0.117.0+);v0.129.0 加入工作區共享與 marketplace 操作。89 |
/title |
設定終端機視窗標題(v0.117.0+) |
/config |
列印有效的設定值與來源 |
/statusline |
設定 TUI 頁尾;v0.129.0 加入可選的主題感知狀態列,顯示 PR 與分支變更摘要。89 |
/feedback |
將日誌傳送給 Codex 維護者 |
/logout |
登出 |
工作流程選擇器重新設計(v0.129.0): Resume 與 fork 在重新設計的選擇器中更易於存取,而新的 raw scrollback mode 讓您可在需要逐字複製命令或模型輸出時,捲動瀏覽未渲染的轉錄內容。在分流冗長的除錯工作階段或將輸出導向其他工具時非常實用。89
2. Codex Desktop App(macOS + Windows)
codex app # Launch desktop app (auto-installs if missing)
桌面應用程式提供 CLI 所沒有的功能:
- 多工處理:跨不同專案同時執行多個平行代理
- Git worktree 隔離:每個執行緒都在 repo 的隔離副本上運作
- 內嵌 diff 審查:暫存、還原並提交變更,無需離開應用程式
- 整合終端機:每個執行緒專屬的終端機可執行命令
- 對話分支:分支對話以探索替代方案
- 浮動彈出視窗:將對話分離為可攜式視窗
- 自動化:排程定期任務(issue triage、CI monitoring、alert response)
何時使用應用程式 vs CLI:當您協調多個工作流程或需要視覺化 diff 審查時,請使用桌面應用程式。當您需要終端機可組合性、腳本撰寫或 CI/CD 整合時,請使用 CLI。
3. IDE 擴充功能(VS Code、Cursor、Windsurf)
Codex IDE 擴充功能直接整合進您的編輯器:
- 預設代理模式:讀取檔案、進行編輯、執行命令
- 內嵌編輯:在您的活動檔案中提供情境感知建議
- 共享工作階段:工作階段在 CLI 與 IDE 擴充功能之間同步
- 相同的驗證:以 ChatGPT 帳號或 API key 登入
請從 VS Code Marketplace 或 Cursor/Windsurf 擴充功能商店安裝。3
4. Codex Cloud [EXPERIMENTAL]
雲端任務在 OpenAI 託管的環境中非同步執行:
- 發送即忘:將任務排入佇列,獨立於您的本機運作
- 平行執行:同時執行多個雲端任務
- PR 建立:Codex 從已完成的工作建立 pull requests
- 本機套用:以
codex apply <TASK_ID>將雲端結果拉取至本機 repo
codex cloud list # List recent cloud tasks
codex apply <TASK_ID> # Apply diff from a specific cloud task
雲端任務也可從 chatgpt.com/codex 存取。4
5. Codex for Chrome [NEW]
Codex 以瀏覽器擴充功能的形式在 Chrome 上推出,成為繼 CLI、桌面應用程式、IDE 擴充功能與雲端之後的第五個介面。此擴充功能的設計理念是與您的日常瀏覽並肩運作,而非取而代之:Codex 在背景跨分頁平行運作,您始終掌控它能存取哪些網站。90
- 平行分頁執行:Codex 同時在多個分頁上運作,不會鎖定前景分頁。
- 逐站控制:您以白名單方式允許 Codex 互動的網站;預設無存取權。
- 以瀏覽器為工作台:此擴充功能最適合以頁面為真實來源的應用程式與網站工作——管理控制台、內部儀表板、內容管理 UI、工單系統——並非要取代 CLI 在本機 repo 上的角色。
- 相同的大腦:Codex for Chrome 運行與其他介面相同的 GPT-5.x-Codex 智能,因此能在 CLI 中運作的 AGENTS.md 或 skills 設定,會將相同的慣例帶入瀏覽器驅動的工作中。
請從 Codex Chrome extension docs 安裝。90
設定系統深度解析
Codex 使用 TOML 進行設定。理解優先順序階層至關重要,因為它決定了當設定發生衝突時哪個會勝出。
優先順序(由高至低)
- 工作階段覆寫(最高):CLI 旗標(
--model、--sandbox、--ask-for-approval、--search、--enable/--disable、--profile)以及-c key=value覆寫 - 專案設定(
.codex/config.toml,從 CWD 向上探索至專案根目錄;最近的目錄勝出) - 使用者設定(
$CODEX_HOME/config.toml,預設為~/.codex/config.toml) - 系統設定(Unix 上的
/etc/codex/config.toml) - 內建預設值(最低)
requirements.toml作為政策約束層,在一般設定合併之後限制使用者可選擇的值。請參閱 Enterprise Deployment。
設定檔位置
| 範圍 | 路徑 | 用途 |
|---|---|---|
| 使用者 | ~/.codex/config.toml |
個人預設值 |
| 專案 | .codex/config.toml |
各儲存庫覆寫 |
| 系統 | /etc/codex/config.toml |
機器全域預設值 |
| 託管 | /etc/codex/requirements.toml |
管理員強制執行的政策約束 |
專家提示:
CODEX_HOME環境變數會覆寫預設的~/.codex目錄。對於 CI/CD 或多帳號設定相當實用。
完整設定參考
# ~/.codex/config.toml — annotated reference
# ─── Model Selection ───────────────────────────────────
model = "gpt-5.5" # Recommended model when available
model_provider = "openai" # Provider (openai, oss, or custom provider id)
model_context_window = 272000 # Token count available to active model (override)
model_auto_compact_token_limit = 200000 # Threshold triggering automatic history compaction
model_reasoning_effort = "medium" # minimal|low|medium|high|xhigh (model-dependent)
model_reasoning_summary = "auto" # auto|concise|detailed|none
model_verbosity = "medium" # low|medium|high
personality = "pragmatic" # none|friendly|pragmatic
review_model = "gpt-5.5" # Optional model for /review command
oss_provider = "lmstudio" # lmstudio|ollama (used with --oss)
# ─── Sandbox & Approval ───────────────────────────────
sandbox_mode = "workspace-write" # read-only|workspace-write|danger-full-access
approval_policy = "on-request" # untrusted|on-request|never
[sandbox_workspace_write]
writable_roots = [] # Additional writable paths
network_access = false # Allow outbound network
exclude_tmpdir_env_var = false # Exclude $TMPDIR from sandbox
exclude_slash_tmp = false # Exclude /tmp from sandbox
# ─── Web Search ────────────────────────────────────────
web_search = "live" # Web search mode (constrained by allowed modes)
# ─── Instructions ──────────────────────────────────────
developer_instructions = "" # Additional injected instructions
model_instructions_file = "" # Custom instructions file path
compact_prompt = "" # Custom history compaction prompt
# ─── Shell Environment ─────────────────────────────────
allow_login_shell = false # Allow login shell semantics (loads .profile/.zprofile)
[shell_environment_policy]
inherit = "all" # all|core|none
ignore_default_excludes = false # Set true to keep KEY/SECRET/TOKEN vars
exclude = [] # Glob patterns to exclude
set = {} # Explicit overrides
include_only = [] # Whitelist patterns
# ─── Authentication ────────────────────────────────────
cli_auth_credentials_store = "file" # file|keyring|auto
forced_login_method = "chatgpt" # chatgpt|api
mcp_oauth_callback_port = 0 # Fixed port for MCP OAuth callback (0 = random)
mcp_oauth_credentials_store = "auto" # auto|file|keyring
# ─── History & Storage ─────────────────────────────────
[history]
persistence = "save-all" # save-all|none
max_bytes = 0 # Cap size (0 = unlimited)
tool_output_token_limit = 10000 # Max tokens per tool output
log_dir = "" # Custom log directory
# ─── UI & Display ──────────────────────────────────────
file_opener = "vscode" # vscode|vscode-insiders|windsurf|cursor|none
hide_agent_reasoning = false
show_raw_agent_reasoning = false
check_for_update_on_startup = true
[tui]
notifications = false # Enable notifications
notification_method = "auto" # auto|osc9|bel
animations = true
show_tooltips = true
alternate_screen = "auto" # auto|always|never
status_line = ["model", "context-remaining", "git-branch"]
# ─── Project Trust ─────────────────────────────────────
project_doc_max_bytes = 32768 # Max AGENTS.md size (32 KiB)
project_doc_fallback_filenames = [] # Alternative instruction filenames
project_root_markers = [".git"] # Project root detection
# ─── Feature Flags ─────────────────────────────────────
# Use `codex features list` for current names/stages/defaults.
[features]
shell_tool = true # Shell command execution (stable)
collaboration_modes = true # Plan mode (stable)
personality = true # Personality selection (stable)
request_rule = true # Smart approvals (stable)
unified_exec = true # PTY-backed exec (stable)
shell_snapshot = true # Shell env snapshots (stable)
command_attribution = true # Codex co-author in commits (v0.103.0+)
request_user_input = true # Allow agent to ask clarifying questions in Default mode (v0.106.0+)
multi_agent = false # Enable multi-agent collaboration tools (v0.102.0+)
apply_patch_freeform = false # Expose freeform apply_patch tool
apps = false # ChatGPT Apps/connectors (experimental)
child_agents_md = false # AGENTS.md guidance (experimental)
runtime_metrics = false # Runtime summary in turns
search_tool = false # Enable search_tool_bm25 for Apps discovery
# ─── Multi-Agent Roles (v0.102.0+) ───────────────────
[agents]
max_threads = 4 # Maximum concurrent agent threads
[agents.explorer]
description = "Read-only codebase navigator"
config_file = "~/.codex/profiles/explorer.toml"
# ─── Notifications ────────────────────────────────────
notify = ["terminal-notifier", "-title", "Codex"] # Command for notifications
# ─── Per-Project Overrides ────────────────────────────
[projects."/absolute/path/to/repo"]
trust_level = "trusted" # Per-project trust override
設定檔(Profiles)
針對不同工作模式的具名設定預設組:
# Define profiles in ~/.codex/config.toml
[profiles.fast]
model = "gpt-5.1-codex-mini"
model_reasoning_effort = "low"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
personality = "pragmatic"
[profiles.careful]
model = "gpt-5.4"
model_reasoning_effort = "xhigh"
approval_policy = "untrusted"
sandbox_mode = "read-only"
[profiles.auto]
model = "gpt-5.4"
model_reasoning_effort = "medium"
approval_policy = "never"
sandbox_mode = "workspace-write"
啟用設定檔:
codex --profile fast "quick refactor"
codex --profile careful "security audit"
codex -p auto "fix CI"
專家提示:在設定的最上層加入
profile = "fast"來指定預設設定檔。可使用--profile在各工作階段中覆寫。
自訂模型提供者
連接 Azure、AWS Bedrock、本機模型或代理服務:
[model_providers.azure]
name = "Azure OpenAI"
base_url = "https://YOUR_PROJECT.openai.azure.com/openai"
wire_api = "responses"
query_params = { api-version = "2025-04-01-preview" }
env_key = "AZURE_OPENAI_API_KEY"
# Built-in amazon-bedrock provider (v0.123.0+, first-class in v0.124.0+)
# AWS SigV4 signing + credential-based auth; AWS profile selectable via the
# nested `aws.profile` field (NOT a top-level `aws_profile` key).
# v0.130.0+ also accepts credentials from `aws login` (the AWS console-login
# flow) — Codex resolves the cached console-login session for the chosen
# profile if static keys are absent.
[model_providers.amazon-bedrock]
name = "Amazon Bedrock"
[model_providers.amazon-bedrock.aws]
profile = "default" # any profile from ~/.aws/credentials
# Region/credential resolution otherwise follows the standard AWS chain;
# v0.130.0 added support for `aws login` console-login profiles in addition
# to static access keys and IAM role assumption.[^168]
[model_providers.ollama]
name = "Ollama (Local)"
base_url = "http://localhost:11434/v1"
wire_api = "chat"
警告:
chat/completionswire API(wire_api = "chat")針對 OpenAI 託管模型已被棄用,OpenAI 宣布將於 2026 年 2 月移除。34 本機提供者(Ollama、LM Studio)可能仍接受此格式。對於 OpenAI 端點,請改用wire_api = "responses"。
使用 --oss 旗標執行本機模型:
codex --oss "explain this function" # Uses default OSS provider
codex --oss --local-provider lmstudio "explain" # Explicit LM Studio
codex --oss --local-provider ollama "explain" # Explicit Ollama
或在設定中指定:
model_provider = "oss"
oss_provider = "lmstudio" # or "ollama"
行內設定覆寫
從命令列覆寫任何設定值:
codex -c model="gpt-5.5" "refactor the API"
codex -c 'sandbox_workspace_write.network_access=true' "install dependencies"
codex -c model_reasoning_effort="xhigh" "debug the race condition"
我該選擇哪個模型?
可用模型(2026 年 4 月)
| 模型 | 輸入 / 總上下文 | 預設推理層級 | 最適用途 |
|---|---|---|---|
| gpt-5.5(Codex) | 400K / 400K | medium |
新旗艦(2026 年 4 月 23 日)——82.7% Terminal-Bench 2.0 SOTA;建議作為大多數 Codex 任務的預設模型。在 API 中:1M 上下文視窗。83 |
| gpt-5.5-pro | 1M / 1M | high |
GPT-5.5 上的最高推理層級(2026 年 4 月 24 日,API 可用)83 |
| gpt-5.4 | 1M / 1M | medium |
前一代旗艦;在 GPT-5.5 於各介面陸續推出期間,仍維持為預設模型 |
| gpt-5.4-mini | 400K / 400K | medium |
子代理工作、較簡單任務——僅佔 GPT-5.4 配額的 30%,速度快 2 倍76 |
| gpt-5.3-codex | 272K / 400K | medium |
編碼專家:複雜的軟體工程任務 |
| gpt-5.3-codex-spark | 128K / 128K | high |
近乎即時的迭代,僅文字(Pro 用戶,Cerebras 合作)67 |
| gpt-5.2-codex | 272K / 400K | medium |
舊版模型;OpenAI 將 gpt-5.4 列為 2026 年 7 月 23 日停用後的替代方案88 |
| gpt-5.1-codex-mini | 272K / 400K | medium |
舊版成本敏感型模型;OpenAI 將 gpt-5.4-mini 列為 2026 年 7 月 23 日停用後的替代方案88 |
GPT-5.5(2026 年 4 月 23 日) 是 OpenAI 為大多數 Codex 任務推薦的選擇:複雜編碼、電腦使用、知識工作與研究流程。4 月 23 日於 Codex CLI / 網頁 / 桌面版開放給 ChatGPT Plus / Pro / Business / Enterprise / Edu / Go;4 月 24 日於 OpenAI API 開放。上下文視窗:Codex 中為 400K,API 中為 1M——Codex 將視窗上限設為 400K,以在訂閱層級之間平衡吞吐量與成本;API 則開放完整的 1M。定價(API):每百萬 token 輸入 $5 / 輸出 $30(為 GPT-5.4 費率的 2 倍;OpenAI 表示在 token 效率改善後,實際漲幅約 20%)。基準測試:82.7% Terminal-Bench 2.0(目前所有公開模型中的 SOTA)、84.9% GDPval(44 種職業)、78.7% OSWorld-Verified、98.0% Tau2-bench Telecom(無提示調校)。OpenAI 在發布前內部使用 GPT-5.5 + Codex 重寫服務基礎設施——使 token 生成速度提升了 20%。83
GPT-5.4 在所有 Codex 介面(CLI、應用程式、IDE 擴充功能、雲端)中仍持續可用。64 確切的模型清單會因帳號與推出進度而異。請查看本地快取:
~/.codex/models_cache.json。棄用說明(2026 年 3 月 11 日):GPT-5.1 模型已不再於 ChatGPT 中提供。現有對話會自動轉移至 GPT-5.3 Instant、GPT-5.4 Thinking 或 GPT-5.4 Pro 繼續進行。GPT-5.1-Codex-Mini 仍可透過 API 與 CLI 用於成本敏感的工作負載。71
免費層說明(2026 年 5 月 5 日):GPT-5.5 Instant 已於 2026 年 5 月 5 日推出至 ChatGPT 免費層。此舉將 GPT-5.5 系列的受眾擴展至付費方案以外,不過 Codex CLI 的存取仍需有效的 Plus / Pro / Business / Enterprise / Edu / Go 訂閱或 API 金鑰。92
GPT-5.4 mini(2026 年 3 月 17 日):GPT-5.4 的較小、較快變體,擁有 400K 上下文,定價為每百萬 token $0.75/$4.50——僅佔 GPT-5.4 配額的 30%。非常適合子代理委派:讓 GPT-5.4 處理規劃與協調,GPT-5.4 mini 子代理則並行處理較窄的子任務(程式碼庫搜尋、檔案審查、文件處理)。76
模型選擇流程圖
Is this a quick fix or simple question?
├─ Yes → gpt-5.1-codex-mini (fastest, cheapest)
└─ No
├─ Do you need real-time pairing speed?
│ ├─ Yes → gpt-5.3-codex-spark (near-instant, Pro only)
│ └─ No
│ ├─ Subagent or parallel subtask (search, review, processing)?
│ │ ├─ Yes → gpt-5.4-mini (30% of GPT-5.4 quota, 2x faster)
│ │ └─ No
│ │ ├─ Pure coding task (refactor, migration, feature build)?
│ │ │ ├─ Yes → gpt-5.3-codex (coding specialist, 272K context)
│ │ │ └─ No → gpt-5.5 (new flagship: 400K context in Codex / 1M in API, 82.7% Terminal-Bench 2.0 SOTA)
└─ Still unsure? → gpt-5.5
推理層級
控制模型在回應前「思考」的程度:
| 層級 | 行為 | 使用時機 |
|---|---|---|
minimal |
最低限度的推理(僅限 GPT-5 模型) | 瑣碎任務、快速查詢 |
low |
簡短推理 | 標準編碼任務、格式化 |
medium |
平衡(預設) | 大多數開發工作 |
high |
延伸推理 | 複雜錯誤、架構設計 |
xhigh |
最大推理 | 安全稽核、深度分析 |
支援的層級因模型而異。
minimal僅適用於 GPT-5 模型。並非所有模型都支援每個層級。
codex -c model_reasoning_effort="xhigh" "find the race condition"
專家提示:相同提示下,
xhigh推理消耗的 token 可能是medium的 3-5 倍。請保留給確實困難、值得多花心力思考的問題。
TUI 快捷推理控制(v0.124.0+)。85 在互動式 TUI 工作階段中,Alt+, 將推理降低一級,Alt+. 則提高一級——當工作階段中遇到困難問題,需要臨時將 medium → high → xhigh 提升,卻不想動用 /effort 或 -c 時,這非常實用。當您在工作階段中接受模型升級時,推理層級會重設為新模型的預設值,而不會延續先前的層級。
模型切換
使用 /model 斜線命令在工作階段中切換模型,或透過 --model / -m 為單次執行設定:
codex -m gpt-5.3-codex-spark "pair with me on this component"
## Codex 的費用是多少?
另請參閱[模型選擇](#which-model-should-i-choose)了解各模型能力,以及[決策框架](#decision-frameworks)了解如何依任務挑選合適的模型。
### 透過 ChatGPT 方案存取
Codex 的可用性取決於您的 ChatGPT 方案與組織設定:[^61]
| 方案 | 價格 | Codex 存取權 | 速率限制(5 小時區間) |
|------|-------|-------------|----------------------------|
| **Free / Go** | $0 / $5 | 限時推廣存取 | 低 |
| **Plus** | $20/月 | 本機 CLI + 雲端任務(2 倍速率限制) | 本機 45-225 則訊息、雲端 10-60 個任務 |
| **Pro** | $200/月 | 優先處理、GPT-5.3-Codex-Spark(2 倍速率限制) | 本機 300-1500 則訊息、雲端 50-400 個任務 |
| **Business** | $25/使用者/月(年繳 $20) | 標準席次包含 Codex 與 ChatGPT、SAML SSO | 依方案限制速率 |
| **Business(僅 Codex 席次)** | 用多少付多少 | 以 Token 計費,無固定席次費用,無速率限制 | 以 Token 計費 |
| **Enterprise / Edu** | 聯絡業務 | 自訂配額、管理員控制、稽核日誌,提供僅 Codex 席次 | 隨合約規模調整 |
| **API Key** | 依用量計費 | CLI、SDK、僅限 IDE(無雲端功能) | 以 Token 計費 |
> **2026 年 4 月定價更新:** Business 年繳價格由 $25 調降為每席次每月 $20。Business 與 Enterprise 工作空間現可選用「僅 Codex 席次」並採用多少付多少的計費方式——無固定席次費用,依 Token 用量計費。[^84] 付費方案的 2 倍速率限制推廣(自 2026 年 2 月 Desktop App 推出時開始)持續有效。[^17]
>
> **2026 年 5 月用量上限提升(至 2026 年 5 月 31 日止):** Plus 方案上的 Codex 以 **25 倍 5 小時上限**運作(標準提升為 20 倍),且**每月 $100 級距加倍**,皆適用於同一期間。請善用這段期間執行更長的雲端任務批次,或進行更高吞吐量的 Agent 執行,而不會撞上平常的 5 小時上限。[^166]
### 點數費用
Codex 操作會從方案配額中扣除點數:
| 操作 | 約略點數 | 備註 |
|-----------|----------------|-------|
| 本機訊息(GPT-5.3-Codex) | ~5 | 標準旗艦模型 |
| 本機訊息(GPT-5.1-Codex-Mini) | ~1 | 相同點數預算下訊息量為 4 倍 |
| 雲端任務 | ~25 | 在 OpenAI 託管環境中執行 |
| 程式碼審查(每個 PR) | ~25 | 透過 `/review` 或雲端審查 |
> Enterprise 與 Edu 方案的點數隨合約配額而定。請於 TUI 中執行 `/status` 查看目前用量。
### API 計費
透過 API 使用 Codex 時,OpenAI 會依所選模型套用標準 OpenAI API 定價,按 Token 計費(並適用任何相關的 prompt 快取折扣)。最新費率請參閱[官方 API 定價頁面](https://openai.com/api/pricing/)。[^21]
### 成本最佳化策略
1. **善用 profiles**:為例行任務建立 `fast` profile,搭配 `gpt-5.1-codex-mini` 與 `model_reasoning_effort = "low"`
2. **保留高推理層級**:僅在面對真正困難的問題時才使用 `xhigh`,因其消耗的 Token 是 3-5 倍
3. **使用 `--ephemeral`**:在 CI/CD 中跳過 session 持久化以降低額外負擔
4. **盡量精簡推理摘要**:當不需要解釋時,將 `model_reasoning_summary` 設為 `"none"`
5. **以 exec 模式批次執行**:`codex exec` 可避免 TUI 在自動化流程中產生的負擔
6. **監控用量**:於 TUI 中執行 `/status` 並查看組織計費儀表板
### 實際成本範例
常見任務的代表性 API 成本(gpt-5.3-codex 採標準定價、中等推理層級):
| 任務 | 輸入 Token | 輸出 Token | 約略費用 |
|------|-------------|---------------|-------------|
| 解釋一個 500 行的模組 | ~15K | ~2K | ~$0.25 |
| 修復失敗的測試(1-2 個檔案) | ~30K | ~5K | ~$0.50 |
| 新增一個附帶測試的 API endpoint | ~60K | ~15K | ~$1.10 |
| 重構驗證模組(10 個檔案) | ~120K | ~30K | ~$2.25 |
| 透過 `codex exec` 進行完整 repo 稽核 | ~200K | ~20K | ~$3.00 |
| 雲端任務:分類 20 個開放議題 | ~250K | ~40K | ~$4.50 |
> 費用會因推理層級、快取與對話長度而有所不同。例行任務使用 `gpt-5.1-codex-mini` 可降低約 40-60% 的成本。已快取的輸入 Token 將以折扣價計費。
### 隱性 Token 負擔
每次工具呼叫都會在您可見的 prompt 之外增加額外 Token:
| 負擔來源 | 約略成本 |
|-----------------|-------------|
| 系統 prompt + AGENTS.md | 每輪 ~2-5K Token(首次載入後即會被快取) |
| 工具定義 | 每個已註冊工具 ~500 Token |
| 檔案讀取(`@file`) | 完整檔案內容的 Token 數 |
| MCP 工具定義 | 每個已連線的 server ~200-500 Token |
| 推理軌跡 | 不固定;`xhigh` 可能增加 3-5 倍負擔 |
> **專家提示:** 透過 TUI 的 `/status` 監控實際用量。Token 計數涵蓋所有額外負擔,而非僅是您可見的訊息。若費用出乎意料,請檢查連接了多少個 MCP servers——每一個都會在每次 API 呼叫中加入工具定義。
### 團隊成本管理
| 團隊規模 | 建議設定 | 預期每月成本 |
|-----------|-------------------|----------------------|
| 獨立開發者 | 預設模型、`medium` 推理層級 | $20-80 |
| 小型團隊(3-5 人) | 使用 profiles(`fast`/`careful`)、透過 `codex exec` 進行程式碼審查 | $200-500 |
| 中型團隊(10-20 人) | Enterprise 方案、`requirements.toml` 限制、CI 整合 | $1,000-3,000 |
| 大型組織(50 人以上) | 含管理員控制、稽核日誌與配置預算的 Enterprise | 客製化定價 |
團隊成本控制策略:
- **設定 `requirements.toml`** 以在組織內全面強制模型與推理層級上限
- **CI/CD 採用 `gpt-5.1-codex-mini`**——自動化管線鮮少需要最高推理層級
- **以 profile 為基礎進行預算控管**——分別定義 `ci`、`review` 與 `dev` profiles,並設定合適的成本上限
- **透過 OpenTelemetry 監控**——企業部署可將用量遙測資料匯出至既有的可觀測性平台
## 決策框架
### 何時使用各介面
| 情境 | 最佳介面 | 原因 |
|----------|-------------|-----|
| 快速修復 bug | CLI | 快速、聚焦、可指令稿化 |
| 多檔案重構 | CLI 或 App | CLI 提供確定性的 patch;App 提供視覺化 diff 檢視 |
| 探索陌生程式碼 | CLI | 終端機可組合性、grep/find 整合 |
| 平行工作流 | Desktop App | Worktree 隔離、多任務管理 |
| 主動編輯檔案 | IDE Extension | 行內編輯、緊湊的編譯測試循環 |
| 長時間執行的遷移 | Cloud | 獨立執行,完成後建立 PR |
| CI/CD 自動化 | `codex exec` | 非互動式、JSON 輸出、可指令稿化 |
| 程式碼審查 | CLI 或 App | `/review` 指令搭配預設組態 |
| 團隊上手 | Desktop App | 視覺化、引導式、較少需要終端機知識 |
### 何時使用各 Sandbox 模式
| 情境 | 模式 | 核准 | 原因 |
|----------|------|----------|-----|
| 探索未知程式碼 | `read-only` | `untrusted` | 最高安全性,不會破壞任何東西 |
| 日常開發 | `workspace-write` | `on-request` | 速度與安全性的良好平衡 |
| 受信任的自動化 | `workspace-write` | `never` | 快速、不中斷、有 sandbox 隔離 |
| 系統管理 | `danger-full-access` | `on-request` | 需要完整存取權但仍需人工核准 |
| CI/CD 流程 | `workspace-write` | `never` | 自動化,並隔離至工作區範圍 |
### 何時使用各推理層級
| 任務類型 | 推理層級 | 模型 | Profile |
|-----------|-----------|-------|---------|
| 格式化、lint | `low` | `gpt-5.1-codex-mini` | `fast` |
| 標準編碼 | `low`-`medium` | `gpt-5.3-codex` | 預設 |
| 複雜除錯 | `high` | `gpt-5.3-codex` | `careful` |
| 安全稽核 | `xhigh` | `gpt-5.3-codex` | `careful` |
| 快速原型開發 | `low` | `gpt-5.3-codex-spark` | `fast` |
| 遷移/重構 | `medium`-`high` | `gpt-5.5` 或 `gpt-5.4` | 預設 |
### Plan Mode 與直接執行
```text
Will Codex need to change more than 3 files?
│
├── YES → Use Plan Mode (/plan)
│ Codex designs the approach BEFORE making changes.
│ You review and approve the plan.
│ Best for: refactors, new features, migrations
│
└── NO → Is the change well-defined?
│
├── YES → Direct execution
│ Just describe the task. Codex executes immediately.
│ Best for: bug fixes, small features, test additions
│
└── NO → Use Plan Mode (/plan)
Let Codex explore and propose an approach first.
Best for: unfamiliar codebases, ambiguous requirements
Steer Mode:Enter 與 Tab
| 情況 | 使用 Enter | 使用 Tab |
|---|---|---|
| Codex 即將犯錯 | 立即傳送修正 | |
| 您有後續任務 | 排入目前工作之後執行 | |
| Codex 選錯檔案 | 立即傳送重新導向 | |
| 您想擴增工作範圍 | 排入新增項目 | |
| 緊急優先順序變更 | 立即傳送新優先順序 | |
| 非關鍵性脈絡 | 排入佇列——不急 |
經驗法則:Enter = 「停下來,現在聽這個。」Tab = 「您忙完之後,也做這個。」
Desktop App 與 CLI
How do you prefer to work?
│
├── Terminal-first → Use CLI
│ │
│ ├── Single focused task → codex (interactive TUI)
│ ├── Scripted automation → codex exec (non-interactive)
│ └── Quick one-shot → codex exec "prompt" -o result.txt
│
└── Visual/multi-project → Use Desktop App
│
├── Multiple parallel tasks → Multi-thread with worktree isolation
├── Visual diff review → Built-in Git diff viewer
├── Scheduled automation → Automations tab
└── Voice-driven → Ctrl+M for voice dictation
| 功能 | CLI | Desktop App |
|---|---|---|
| 互動式工作階段 | 支援 | 支援 |
| 平行 agent | 手動(多個終端機) | 內建(worktree 隔離) |
| Diff 檢視 | /diff(文字) |
視覺化行內 diff |
| 自動化 | Cron + codex exec |
GUI 排程器 |
| 語音輸入 | 不支援 | 支援(Ctrl+M) |
| CI/CD 整合 | codex exec + GitHub Action |
不支援 |
| 工作階段同步 | 支援 | 支援(與 CLI 共用) |
該選哪個 Profile?
依任務挑選預先設定好的 profile:
| 任務類型 | Profile | 主要設定 |
|---|---|---|
| 快速問答、格式化 | fast |
model = "gpt-5.1-codex-mini"、model_reasoning_effort = "low" |
| 日常開發 | (預設) | model = "gpt-5.3-codex"、model_reasoning_effort = "medium" |
| 架構、安全 | careful |
model = "gpt-5.3-codex"、model_reasoning_effort = "xhigh" |
| 即時結對 | pair |
model = "gpt-5.3-codex-spark"、model_reasoning_effort = "high" |
| CI/CD 自動化 | ci |
model = "gpt-5.1-codex-mini"、model_reasoning_effort = "low"、sandbox_mode = "workspace-write" |
config.toml 設定範例:
# Default profile
profile = "default"
[profiles.fast]
model = "gpt-5.1-codex-mini"
model_reasoning_effort = "low"
[profiles.careful]
model = "gpt-5.3-codex"
model_reasoning_effort = "xhigh"
[profiles.pair]
model = "gpt-5.3-codex-spark"
model_reasoning_effort = "high"
[profiles.ci]
model = "gpt-5.1-codex-mini"
model_reasoning_effort = "low"
sandbox_mode = "workspace-write"
依工作階段切換 profile:codex --profile careful
沙箱與審批系統如何運作?
Codex 採用雙層安全模型,將技術上可行的操作與Codex 何時請求人工審批分開處理。此方法與 Claude Code 的權限系統有根本差異——Codex 在作業系統核心層級執行限制。5 另請參閱Enterprise Deployment,了解管理員在組織範圍內透過 requirements.toml 強制執行的限制。
Layer 1:Sandbox(可行範圍)
沙箱使用作業系統原生機制控制檔案系統與網路存取:
| 模式 | 檔案存取 | 網路 | 實作方式 |
|---|---|---|---|
read-only |
全環境僅可讀取 | 封鎖 | 最嚴格;變更操作需明確審批 |
workspace-write |
工作區與 /tmp 可讀寫 |
預設封鎖 | 一般開發;安全的預設值 |
danger-full-access |
完整機器存取 | 啟用 | 最大權限;請謹慎使用(僅 denylist 變體已於 v0.121.0 移除——現為二元開關)82 |
平台專屬執行方式:
- macOS:透過
sandbox-exec使用 Apple 的 Seatbelt 框架,搭配執行階段編譯並由核心強制執行的模式專屬設定檔6。自 v0.121.0 起,macOS 沙箱設定檔可允許特定的 Unix sockets(例如docker.sock、編輯器 IPC sockets),且預設不再封鎖私有 DNS 解析。82 - Linux:使用 Landlock 進行檔案系統限制,並以 seccomp 進行系統呼叫過濾。獨立的輔助程序(
codex-linux-sandbox)提供深度防禦隔離。5 Bubblewrap(bwrap)已內建並編譯為 Linux 建置的一部分(自 v0.100.0 起從選用提升為標配)7。v0.117.0 改善了在較舊發行版與舊核心設定上的沙箱可靠性。75 v0.129.0 強化 Linux 上的沙箱啟動,並將內建的 Bubblewrap 升級至 0.11.2,套用上游安全修補;v0.130.0 再進一步強化啟動流程。8991 - Windows:採用受限 token 的原生沙箱(自 v0.100.0 起從實驗性提升為正式功能)。亦支援 WSL(繼承 Linux Landlock 與 seccomp)。v0.117.0 包含受限 token 沙箱改進,提供更佳的程序隔離。75 v0.130.0 授予沙箱使用者存取桌面執行階段二進位快取的權限,讓 Windows 沙箱能為 workspace-sandbox 使用者可靠地解析執行階段二進位檔。91
為何這很重要:與容器型沙箱(Docker)不同,作業系統層級沙箱更快、更輕量,也更難脫逃。核心會在 Codex 看到系統呼叫之前就強制執行限制。
安全修復:
- zsh-fork 沙箱繞過(v0.106.0): 修復了透過 zsh fork 執行 shell 可繞過沙箱限制的漏洞。60 若您使用較早版本,請立即升級。
- 輸入大小上限(v0.106.0): Codex 現在強制約 100 萬字元的輸入上限,以防止過大的酬載造成停滯。60
- 安全 devcontainer 設定檔(v0.121.0): 為 Docker devcontainers 提供新的強化客戶設定檔,在容器內使用 Bubblewrap 進行沙箱化。支援 WSL2;WSL1 明確被拒絕(Bubblewrap 與 WSL1 的核心墊片不相容)。82
- Guardian 審查與 hooks(v0.121.0): 在 Guardian 審查工作階段期間 hooks 會被停用,使 pre/post-tool hooks 無法干擾 Guardian subagent 的決策。82 若您依賴 hooks 進行記錄或驗證,請注意 Guardian 審查會略過這些 hooks——若需要完整稽核軌跡,請改以 app-server 可觀測性作為備案。
- Linux /dev 檔案系統(v0.105.0): Linux 上的沙箱命令現在會獲得最小化的 /dev 檔案系統,改善與預期需要裝置節點工具的相容性。61
ReadOnlyAccess 政策(v0.100.0+): 提供可設定的政策結構,用於精細的讀取存取控制。即使在 workspace-write 模式下,也可用它來限制 Codex 能讀取的目錄:
[sandbox_workspace_write]
read_only_access = ["/etc", "/usr/local/share"] # Only these paths readable outside workspace
Layer 2:審批政策(何時詢問)
審批政策決定 Codex 何時暫停以請求人工確認:
| 政策 | 行為 | 適用情境 |
|---|---|---|
untrusted |
自動執行安全的讀取;其他都會詢問 | 信任門檻最高;不熟悉的儲存庫 |
on-request |
在沙箱內自動核准;超出邊界時詢問 | 預設值;平衡良好 |
never |
完全不詢問 | CI/CD、可信任的自動化 |
on-failure 仍出現在部分較舊範例與相容性路徑中,但目前 OpenAI 設定文件已將其標記為已淘汰。互動式執行請優先使用 on-request,已具備外部安全邊界的非互動式執行則使用 never。87
獨立的審批 ID(v0.104.0+)
Codex 現在會為多步驟 shell 執行中的每個命令分配獨立的審批 ID。這代表審批是精細化的——核准某個序列中的一個命令並不會自動核准同一 shell 呼叫中的後續命令。49
彈性審批控制(v0.105.0+)
審批流程現在支援額外沙箱權限與精細化拒絕:61
- 額外沙箱權限:當命令需要超出當前沙箱模式的存取權限時,Codex 可以請求特定的額外權限,而不必要求完整切換模式
- 精細化拒絕:拒絕個別工具呼叫並提供回饋,讓 Codex 可以調整方法,而不只是重複嘗試相同的命令
執行階段權限請求(v0.113.0+)
Codex 現在內建 request_permissions 工具,讓模型可以在執行階段請求額外權限。69 當模型遇到需要更高權限的任務時,可以透過 TUI 審批流程正式請求特定權限(檔案系統路徑、網路存取等),而不會默默失敗或要求使用者以不同旗標重新啟動。
權限設定檔(v0.113.0+,於 v0.128.0 擴充)
權限設定檔將檔案系統與網路沙箱政策拆分為命名且可重複使用的區段。將 default_permissions 設定為內建設定檔,例如 :read-only、:workspace 或 :danger-no-sandbox,或指向自訂的 [permissions.<name>] 表格。87
default_permissions = "project-safe"
[permissions.project-safe.filesystem]
"/usr/local" = "read"
glob_scan_max_depth = 3
[permissions.project-safe.filesystem.":project_roots"]
"." = "write"
"**/*.env" = "none"
[permissions.project-safe.network]
enabled = true
mode = "limited"
[permissions.project-safe.network.domains]
"api.github.com" = "allow"
"registry.npmjs.org" = "allow"
對於即使在專案根目錄可寫時仍應無法讀取的敏感檔案與 globs,請使用 none。對於一次性的命令例外,建議使用規則而非大幅擴充設定檔。87
舊版 --full-auto 指引
舊版指南將 --full-auto 描述為以下命令的便利別名:
codex --sandbox workspace-write --ask-for-approval on-request
在 v0.128.0 中,發行說明將 --full-auto 標記為已淘汰,且目前的 CLI 說明文件不再為互動式執行列出此選項。請改用上述明確旗標或具名的權限設定檔。86
沙箱可靠性(v0.129.0): Linux 沙箱啟動強化減少了在慢速檔案系統或符號連結 checkout 上的競態條件;Windows 沙箱可靠性改進解決了長時間執行期間多個邊界案例的當機問題;內建的 Bubblewrap 升級至 0.11.2,套用上游安全修補。無需變更設定。執行
codex update即可取得這些更新。89
建議設定
日常開發(安全預設值):
sandbox_mode = "workspace-write"
approval_policy = "on-request"
進階使用者(完整存取,人工介入):
sandbox_mode = "danger-full-access"
approval_policy = "untrusted"
此組合是社群推薦的「最佳平衡點」:擁有最大權限,但每個命令都需要審批。8
CI/CD 自動化:
sandbox_mode = "workspace-write"
approval_policy = "never"
透過 Guardian Subagent 進行智慧審批(v0.115.0+)
Smart Approvals 可以將審查請求路由至 guardian subagent,而非要求每個動作都經人工審批。Guardian 工作階段會在審批之間持續存在,以重複使用 prompt cache 並避免啟動開銷。每次審查都會獲得乾淨的歷史紀錄(先前的決策不會洩漏到後續審查中)。73
在 config.toml 中設定審查者:
approvals_reviewer = "guardian_subagent" # "user" (default) or "guardian_subagent"
對於希望以推理進行自動化審查、而非全面採用 approval_policy = "never" 的 CI/CD 工作流程,此功能特別實用。
啟用網路存取
Codex 在 workspace-write 模式下預設封鎖網路存取。需要時可啟用:
# Per-run
codex -c 'sandbox_workspace_write.network_access=true' "install the packages"
# In config.toml
[sandbox_workspace_write]
network_access = true
writable_roots = ["/path/to/extra/dir"] # Additional writable directories
exclude_slash_tmp = false # Prevent /tmp from being writable
exclude_tmpdir_env_var = false # Prevent $TMPDIR from being writable
WebSocket Proxy 支援(v0.104.0+)
對於需要透過代理伺服器路由 WebSocket 流量的企業環境,Codex 現在支援 WS_PROXY 與 WSS_PROXY 環境變數:49
export WSS_PROXY="https://proxy.corp.example.com:8443"
codex "update the README"
這些環境變數補強了既有的 HTTPS_PROXY 與 SOCKS5 代理支援(v0.93.0+),涵蓋所有傳輸層。
測試沙箱
在信任沙箱之前,請先驗證其行為:
codex sandbox macos --permissions-profile :workspace -- ls /etc/passwd # macOS test
codex sandbox linux --permissions-profile :workspace -- cat /etc/shadow # Linux test
若沙箱運作正常,這兩個命令在 workspace 範圍的設定檔下都應因權限被拒而失敗。若任一命令成功執行,您的沙箱設定就需要進一步檢查。
AGENTS.md 如何運作?
AGENTS.md 是 Codex 的專案指令系統,也是一項開放標準9,目前由 Linux Foundation 的 Agentic AI Foundation 治理。Codex、Cursor、Copilot、Amp、Jules(Google)、Gemini CLI、Windsurf、Cline、Aider、Zed、Factory、RooCode,以及 60,000 多個開放原始碼專案皆支援此標準。它定義 Codex 在特定儲存庫或目錄中的行為方式。可重複使用的專業能力套件,請參閱 Skills;它們可與 AGENTS.md 互補。
探索階層
Codex 會在工作階段開始時走訪目錄樹,建立指令鏈:
- 全域(
~/.codex/):AGENTS.override.md>AGENTS.md - 專案(從 git 根目錄到目前目錄):每一層都會檢查
AGENTS.override.md>AGENTS.md> 備援檔名 - 合併:檔案會從根目錄往下串接;距離目前位置越近的檔案,會越晚出現在 prompt 中,並覆寫較早的指引
~/.codex/AGENTS.md ← Global defaults
└─ /repo/AGENTS.md ← Project-wide rules
└─ /repo/services/AGENTS.md ← Service-specific rules
└─ /repo/services/payments/
AGENTS.override.md ← Overrides everything above for this dir
優秀 AGENTS.md 的要件
根據 Codex 本身的直接指引與社群模式10:
建議:
- 具體明確:"Use rg --files for discovery" 勝過 "search efficiently"
- 定義完成條件:什麼才算「完成」?(測試通過、lint 乾淨等)
- 納入命令:建置、測試、lint、格式化(精確呼叫方式)
- 依任務組織:程式撰寫、review、release、incident/debug 區段
- 定義升級處理:受阻或遇到非預期狀態時該怎麼做
避免: - 傾倒整份風格指南,卻沒有可執行規則 - 使用含糊指令(「小心處理」、「最佳化」) - 混合彼此衝突的優先順序(速度 + 完整驗證 + 沒有執行時間預算) - 撰寫散文式文件(AGENTS.md 是操作政策,不是 README)
範例:Production AGENTS.md
# Repository Guidelines
## Build, Test, and Development Commands
- Run API (dev): `python3 -m uvicorn main:app --reload`
- Install deps: `pip install -r requirements.txt`
- Lint: `python3 -m ruff check .` (auto-fix: `--fix`)
- Format: `python3 -m ruff format .`
- Tests: `python3 -m pytest -v`
- Coverage: `python3 -m pytest --cov=app --cov-report=term-missing`
## Coding Style & Naming Conventions
- Python 3.11+. Type hints on all functions.
- Ruff enforced: 88-char lines, double quotes, spaces for indent.
- Naming: modules `snake_case.py`, classes `PascalCase`, functions `snake_case`.
## Commit & Pull Request Guidelines
- Conventional Commits: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:`, `test:`
- Commits should be small and focused.
- PRs must include: description, test plan, and screenshots for UI changes.
## Security
- Never commit secrets. Use `.env` for local config.
- Validate all external API calls with proper error handling.
Agent 工作階段中的秘密處理
請將 Codex 可見的歷史紀錄視為安全攻擊面,而不只是原始程式碼。Codex release notes 記載了 shell 快照與環境變數遮蔽的相關工作,memory 系統也會掃描 memory 寫入中的秘密;但這些防護並不代表命令輸出、工作階段逐字稿、shell 快照、本機日誌或輔助指令碼就是列印憑證的安全位置。375595
操作規則很簡單:不要列印秘密讓模型檢視;將輔助憑證保留在需要環境變數的設定中;稽核時,區分可執行原始碼、文件、產生的快取、工作階段逐字稿、shell 快照、日誌,以及刻意設置的秘密儲存區;當出現高信心的秘密格式時,遮蔽本機歷史紀錄;並且只有在手動衛生流程已經證實可靠後,才提升預防性 hooks。公開可分享的教訓是攻擊面地圖與驗收標準,而不是私人 token 值、精確路徑或偵測器內部細節。95
Override 機制
任何目錄層級的 AGENTS.override.md 都會取代該作用範圍的一般 AGENTS.md。適用於:
- Release 凍結:「不新增功能,只修正問題」
- Incident 模式:「所有變更都必須由 on-call review」
- 暫時性強化:「本 sprint 不更新相依套件」
設定
# Custom fallback filenames (in addition to AGENTS.md)
project_doc_fallback_filenames = ["TEAM_GUIDE.md", ".agents.md"]
# Increase max size for large instruction files
project_doc_max_bytes = 65536 # 64 KiB (default: 32 KiB)
Scaffold 產生
codex # Launch TUI
/init # Generate AGENTS.md scaffold
或驗證您的指令鏈:
codex --ask-for-approval never "Summarize your current instructions"
Hooks
Codex 在 v0.99.0(AfterAgent)與 v0.100.0(AfterToolUse)導入 hooks,接著在 v0.114.0 加入實驗性 hooks engine,提供 SessionStart 與 Stop events。70 截至 v0.124.0(2026年4月23日),hooks 已穩定。85 現在可直接在 config.toml 與 requirements.toml 內嵌設定,不再需要獨立的 hook scripts 檔案;它們也會觀察 MCP tools,以及 apply_patch 和長時間執行的 Bash 工作階段。此系統如今涵蓋工作階段生命週期與 tool 層級自動化,補上了與 Claude Code hook model 之間的差距。
可用的 Hook Events
| Event | 觸發時機 | 新增版本 |
|---|---|---|
SessionStart |
每個工作階段開始時觸發一次;hook stdout 會在第一輪之前注入為啟動 context | v0.114.0 [EXPERIMENTAL] |
Stop |
工作階段結束時 | v0.114.0 [EXPERIMENTAL] |
AfterAgent |
agent 完成一個完整回合後 | v0.99.0 |
AfterToolUse |
每次個別 tool call 完成後 | v0.100.0 |
UserPromptSubmit |
使用者 prompt 執行前;可在其進入歷史紀錄前封鎖或補充 prompt | v0.116.0 [EXPERIMENTAL] |
Hook 設定
Hooks 設定於 .codex/config.toml:
[[hooks]]
event = "AfterToolUse"
command = "echo 'Tool completed' >> /tmp/codex-log.txt"
[[hooks]]
event = "SessionStart"
command = "echo 'Current date: $(date +%Y-%m-%d)'"
SessionStart hook 的 stdout 會送入模型 context,因此很適合在工作階段開始時注入動態資訊(日期、branch 名稱、環境變數)。
複製 Claude Code Hook 模式
若從 Claude Code 遷移,可用以下方式達成類似自動化:
| Claude Code Pattern | Codex Alternative |
|---|---|
PreToolUse 檔案封鎖 |
AGENTS.md 指令 + sandbox read-only mode |
PostToolUse linting |
執行 linter 的 AfterToolUse hook |
SessionStart context 注入 |
搭配 stdout 注入的 SessionStart hook(v0.114.0) |
Stop 通知 |
搭配通知命令的 Stop hook(v0.114.0) |
SubagentStop 通知 |
搭配通知 script 的 AfterAgent hook |
| 非同步 hooks | 尚未支援;背景工作請使用 Cloud tasks |
專家提示:截至 v0.124.0(2026年4月23日),hooks engine 已穩定。新的 hook events 仍會隨 release 推出,請查看 Codex changelog。
TUI 內建 hook 瀏覽器(v0.129.0):在 TUI 中執行
/hooks,即可探索可用 hooks、查看目前啟用項目,並在不編輯config.toml的情況下切換個別 hooks。當您排查行為異常的 plugin-bundled hook,或需要在專注編輯工作階段暫時停用AfterToolUselinter 時,這會很有幫助。89
什麼是MCP(Model Context Protocol)?[EXPERIMENTAL]
MCP透過連接外部工具與服務來擴充Codex的能力。codex mcp命令群組目前標記為實驗性,命令與設定格式可能會在不同版本之間變更。Codex支援2種傳輸類型:STDIO(本機程序)與Streamable HTTP(遠端伺服器)。11
v0.121.0 MCP變更:工具現在會以namespace註冊,因此清單中的工具名稱會顯示為
<server>:<tool>,而不是單獨名稱——若有任何 scripts 或 prompts 會針對未限定的工具名稱執行 grep,請一併更新。新的supports_parallel_tool_calls旗標已串接至包含的MCP,讓宣告支援的伺服器能夠平行執行。sandbox狀態中繼資料現在會透過MCP工具中繼資料傳遞,讓伺服器能調整行為(例如:在 read-only sandbox 下執行時發出警告)。自訂的codex/sandbox-state請求已移除——請改用中繼資料路徑。MCP Apps推出的第3階段在此落地,加入工具呼叫支援;使用 deferred-call pattern 的伺服器現在也支援扁平化的 deferred tool calls。82
設定MCP伺服器
STDIO伺服器(本機程序):
# In ~/.codex/config.toml or .codex/config.toml
[mcp_servers.context7]
enabled = true
required = true # Fail startup if unavailable
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
env = { "MY_VAR" = "value" } # Static env vars
env_vars = ["PATH", "HOME"] # Forward host env vars
cwd = "/path/to/project" # Optional working directory
startup_timeout_sec = 10
tool_timeout_sec = 60
enabled_tools = ["search", "summarize"] # Tool allowlist
disabled_tools = ["slow-tool"] # Tool denylist
HTTP伺服器(遠端):
[mcp_servers.figma]
enabled = true
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"
http_headers = { "X-Figma-Region" = "us-east-1" }
env_http_headers = { "X-Org-Id" = "FIGMA_ORG_ID" } # Headers from env vars
startup_timeout_sec = 10
tool_timeout_sec = 60
CLI管理
codex mcp add context7 -- npx -y @upstash/context7-mcp
codex mcp add context7 --env API_KEY=... -- npx -y @upstash/context7-mcp # With env vars
codex mcp add figma --url https://mcp.figma.com/mcp --bearer-token-env-var FIGMA_OAUTH_TOKEN
codex mcp list # List all configured servers
codex mcp list --json # JSON output
codex mcp get context7 # Show server config
codex mcp get context7 --json # JSON output
codex mcp login <server> # OAuth flow for HTTP servers
codex mcp logout <server> # Remove OAuth credentials
codex mcp remove <server> # Delete server definition
工作階段內:/mcp會顯示作用中的伺服器與可用工具。/mcp verbose(v0.123.0+)84會回傳完整的伺服器診斷、資源與資源範本——在伺服器載入失敗,或工具沒有出現在預期位置時很有用。一般的/mcp則維持快速。
Plugin MCP載入(v0.123.0+)同時接受標準mcpServersschema與.mcp.json中的頂層伺服器對應表,因此依任一慣例撰寫的 plugins 都能順利載入。84
以MCP伺服器身分執行Codex
Codex可以將自身公開為MCP伺服器,用於多代理協作:12
codex mcp-server # Start as MCP server (stdio transport)
伺服器公開2個工具:
1. codex():使用 prompt、sandbox、model 與 approval 參數啟動新的工作階段
2. codex-reply():使用threadId與 prompt 繼續既有工作階段
搭配Agents SDK(Python)使用:
from agents import Agent, Runner
from agents.mcp import MCPServerStdio
async with MCPServerStdio(
name="Codex CLI",
params={"command": "npx", "args": ["-y", "codex", "mcp-server"]},
client_session_timeout_seconds=360000,
) as codex_mcp_server:
agent = Agent(name="Developer", mcp_servers=[codex_mcp_server])
result = await Runner.run(agent, "Fix the failing tests")
值得注意的MCP伺服器
| 伺服器 | 用途 | 安裝 |
|---|---|---|
| Context7 | 最新程式庫文件 | npx -y @upstash/context7-mcp |
| Figma | 設計檔案存取 | HTTP: https://mcp.figma.com/mcp |
| Playwright | 瀏覽器自動化 | npx -y @anthropic/mcp-playwright |
| Sentry | 錯誤監控 | HTTP: https://mcp.sentry.dev/mcp |
| GitHub | 儲存庫操作 | npx -y @anthropic/mcp-github |
實務模式
模式1:具備脈絡感知的開發——將Context7與您的框架文件搭配使用,讓Codex永遠具備最新的API參考資料:
[mcp_servers.context7]
enabled = true
required = true
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
模式2:輸出限制——MCP工具回應預設會在約25K字元處截斷。對於會回傳大型 payload 的工具(資料庫查詢、log 擷取),請使用enabled_tools限制到特定工具,讓回應保持聚焦。
模式2a:多模態工具輸出(v0.107.0)——自訂工具現在可以在文字旁一併回傳多模態輸出(圖片、豐富內容)。這讓會產生視覺成品的工具——截圖、圖表、chart renders——能直接傳給模型分析。62
模式3:企業MCP治理——透過requirements.toml鎖定開發者可以使用哪些MCP伺服器:
# In /etc/codex/requirements.toml — only approved servers allowed
[mcp_servers.approved-internal]
identity = { command = "npx @company/internal-mcp" }
任何不符合requirements.toml中 identity 的伺服器,都會在啟動時被封鎖。完整政策設定請參閱企業部署。
Code Mode [EXPERIMENTAL]
Code mode(v0.114.0)透過將代理範圍限制在以程式碼為主的操作,提供更隔離的 coding workflow。70啟用後,代理會專注於讀取、撰寫與測試程式碼,不會進行更廣泛的系統互動。
此功能為實驗性功能。請查看 release notes 以取得更新。
JavaScript REPL Runtime [REMOVED]
Codex v0.100.0新增了實驗性的JavaScript REPL runtime(js_repl),v0.106.0則透過/experimental介面將其提升。60該指引現在已屬歷史資訊。在v0.128.0中,release changelog 包含「Remove js_repl feature」,目前的功能清單也將js_repl與js_repl_tools_only標示為已移除。86
請勿在新設定中加入features.js_repl = true。需要可重複執行的邏輯時,請使用 shell commands、已提交至版本控制的 scripts、MCP工具,或搭配scripts/資料夾的Codex skill。
什麼是 Skills?
Skills 是 Codex 依需求載入的可重複使用、任務專用能力套件。它們遵循開放式 agent skills 標準。13
Skill 結構
my-skill/
SKILL.md (required: instructions)
scripts/ (optional: executable scripts)
references/ (optional: reference docs)
assets/ (optional: images, icons)
agents/openai.yaml (optional: metadata, UI, dependencies)
探索位置
Codex 會將使用者安裝的 skills 儲存在 $CODEX_HOME/skills(預設值:~/.codex/skills),其中包含 .system/ 底下的內建系統 skills。Codex 支援以符號連結建立的 skill 資料夾。
| 範圍 | 路徑 |
|---|---|
| 專案/團隊 | Repository skill 資料夾(版面配置可能因版本而異) |
| 使用者 | ~/.codex/skills/(或 $CODEX_HOME/skills/) |
| 管理員 | /etc/codex/skills/ |
| 系統 | 由 OpenAI 隨附(位於 ~/.codex/skills/.system/ 底下) |
建立 Skill
SKILL.md 格式:
---
name: security-audit
description: Run a thorough security audit on the codebase.
---
## Security Audit Procedure
1. Scan for hardcoded secrets using `rg -i "(api_key|password|secret|token)\s*=" --type py`
2. Check for SQL injection: look for string interpolation in queries
3. Verify input validation on all API endpoints
4. Check dependency vulnerabilities: `pip audit` or `npm audit`
5. Review authentication and authorization patterns
6. Report findings with severity levels (Critical/High/Medium/Low)
Metadata(agents/openai.yaml):
interface:
display_name: "Security Audit"
short_description: "Full codebase security review"
icon_small: "./assets/shield.svg"
brand_color: "#DC2626"
default_prompt: "Run a security audit on this repository"
policy:
allow_implicit_invocation: false # Require explicit $skill
dependencies:
tools:
- type: "mcp"
value: "snyk"
transport: "streamable_http"
url: "https://mcp.snyk.io/mcp"
叫用 Skills
- 明確叫用:
/skills選單,或在 prompt 中提及$skill-name - 隱含叫用:Codex 會根據任務描述自動偵測相符的 skills(若
allow_implicit_invocation: true) - Creator:使用
$skill-creator互動式建立新的 skill - Installer:使用
$skill-installer install <name>安裝社群 skills
啟用/停用
[[skills.config]]
path = "/path/to/skill/SKILL.md"
enabled = false
Skills 與 slash commands
| Skills | Slash Commands | |
|---|---|---|
| 定義於 | SKILL.md 檔案,可搭配選用 metadata |
內建於 Codex CLI binary |
| 範圍 | 專案、使用者或管理員層級 | 全域(永遠可用) |
| 叫用方式 | 在 prompt 中使用 $skill-name、/skills 選單,或隱含偵測 |
/command 語法 |
| 可自訂性 | 完全可自訂 — 由您撰寫指示 | 固定行為 |
| 相依性 | 可宣告 MCP server 需求 | 無 |
| 分享 | 將 skill 資料夾複製到團隊 repo 或 ~/.codex/skills/ |
無法分享 |
偵錯 Skills
如果 skill 沒有啟用:
- 檢查探索結果:
/skills應該會在 TUI 中列出它 - 確認路徑:確保 skill 資料夾位於可辨識的位置(
~/.codex/skills/、project root 或/etc/codex/skills/) - 檢查
enabled:config.toml 中enabled = false的 skills 不會載入 - 檢查隱含啟用:若仰賴自動偵測,請確認
agents/openai.yaml中有allow_implicit_invocation: true - 使用關鍵字:在 prompt 中加入 skill 的
description詞彙,以提升隱含比對效果
Production 範例:Deploy Skill
這是一個完整的多檔案 skill,展示 references 與 scripts 如何協同運作:
deploy-skill/
SKILL.md
references/
runbook.md
rollback-checklist.md
scripts/
pre-deploy-check.sh
smoke-test.sh
agents/openai.yaml
SKILL.md:
---
name: deploy
description: Deploy the application to staging or production. Runs pre-flight checks, executes deployment, and verifies with smoke tests.
---
## Deployment Procedure
### Pre-flight
1. Run `scripts/pre-deploy-check.sh` to verify:
- All tests pass
- No uncommitted changes
- Branch is up to date with remote
2. Review the runbook at `references/runbook.md` for environment-specific steps.
### Deploy
3. Execute the deployment command for the target environment.
4. Monitor logs for errors during rollout.
### Verify
5. Run `scripts/smoke-test.sh <environment-url>` to confirm critical paths.
6. If smoke tests fail, follow `references/rollback-checklist.md`.
叫用方式:$deploy to staging 或 $deploy production with canary rollout
Plugins
Plugins 會將 skills、MCP entries、hooks 與 app connectors 整合成單一可安裝套件(v0.110.0+)。65 自 v0.117.0 起,plugins 成為一級功能:product-scoped plugins 會在啟動時自動同步,而 /plugins 則提供 TUI 內的瀏覽器,用於探索與管理。75 v0.128.0 進一步擴充 plugin 工作流程,加入 marketplace 安裝、remote bundle caching、remote uninstall APIs、plugin-bundled hooks、hook enablement state,以及 external-agent config import。86 v0.129.0(2026年5月7日)新增plugin workspace sharing(無需重新發布即可將一組 plugin 推送給隊友)、share access controls(可針對每位接收者啟用/停用、撤銷)、source filtering(限制 workspace 從哪些 marketplaces 拉取),以及可直接從 /plugins 瀏覽器叫用的 marketplace operations,不必再透過 CLI。89 v0.130.0(2026年5月8日)讓 plugin 封裝更透明,分享流程也更可控:91
- Bundled hooks 會顯示在 plugin details 中。
/plugins詳細檢視現在會列出 plugin 隨附的每個 lifecycle hook(SessionStart、UserPromptSubmit、Stop等)。安裝 plugin 之前,您可以清楚看到它會在 session 中註冊哪些 hooks — 不會再因為只信任 plugin 的工具,就意外承受 hook 副作用。 shareContext中的 plugin share metadata。 從 workspace 分享 plugin 時,share-link payload 現在會公開連結 metadata(creator、scope、freshness),讓接收端 sessions 能顯示來源並決定是否接受。- Share settings 的 discoverability controls。 Share settings 提供 discoverability toggle,讓團隊可將 plugins 發布到特定 workspaces 或 recipient lists,而不必讓它們在整個 organization 中普遍可列出。
Plugin Sources
| 來源 | 位置 | 說明 |
|---|---|---|
| Config | config.toml |
手動宣告的 plugins |
| Local marketplace | marketplace.json |
專案本機 plugin catalog |
| Install endpoint | App server v2 | 遠端 plugin 安裝 |
| Product-scoped | 啟動時同步 | 自動同步的 plugins(v0.117.0+) |
Plugin 探索
Codex 會在 session 啟動時告知 model 哪些 plugins 已啟用(v0.111.0),改善已安裝 MCPs、apps 與 skills 的探索能力。65 Model 可根據任務脈絡,在 session 期間建議相關 plugins。v0.117.0 中,product-scoped plugins 會在啟動時同步,確保無需手動介入也能取得最新的 plugin catalog。75
@plugin 提及(v0.112.0+)
可在 chat 中使用 @plugin-name 直接參照任何已安裝的 plugin。68 提及 plugin 時,它的 context(capabilities、tools、configuration)會自動納入 model 的 context window — 無需再描述該 plugin 的用途。
@deploy push this branch to staging with canary rollout
@linter check for unused imports in src/
這適用於任何已安裝的 plugin,包括自訂 skills、MCP servers 與 app connectors。
Plugin Marketplace(v0.113.0+)
Plugin marketplace 現在提供更豐富的探索能力,包含 metadata、categories 與 ratings。69 安裝時的 auth checks 會確認需要 API keys 或 OAuth 的 plugins 在安裝前具備有效 credentials。Uninstall endpoint 則能乾淨移除 plugins 及其相關 configuration。
新增 Third-Party Marketplaces(v0.121.0+)
目前 OpenAI Codex 文件將 marketplace source 管理歸在 codex plugin marketplace 底下。這讓 OpenAI 第一方 marketplace 之外的 third-party plugin distribution 更正式化,並支援 GitHub repo shorthand、HTTP(S) Git URLs、SSH URLs,以及 local marketplace root directories;使用 --ref 固定 Git ref,而 --sparse PATH 只需針對 Git-backed marketplace repos 重複指定。93
# GitHub repository (shorthand)
codex plugin marketplace add owner/repo
# Arbitrary git URL
codex plugin marketplace add https://git.example.com/team/plugins.git
# SSH Git URL
codex plugin marketplace add [email protected]:team/plugins.git
# Local directory
codex plugin marketplace add /path/to/local/marketplace
# Upgrade or remove a configured marketplace
codex plugin marketplace upgrade <marketplace-name>
codex plugin marketplace remove <marketplace-name>
新增後,該 marketplace 的 plugins 會與預設 plugins 一起出現在 /plugins 瀏覽器中。App-server callers(IDE/desktop integrations)也有對應 endpoint,可透過程式註冊 marketplaces。82
安全性考量:Third-party marketplaces 會以您的 Codex 權限執行任意 plugin code。新增前請審慎檢查來源,首次執行時也建議使用 sandboxed execution。
管理 Plugins
codex plugin marketplace add <src> # Add a marketplace source
codex plugin marketplace upgrade [name] # Upgrade one marketplace or all
codex plugin marketplace remove <name> # Remove a configured marketplace
在 TUI 中,使用 /plugins(v0.117.0+)即可互動式瀏覽、安裝與移除個別 plugins,無需離開目前 session。75
Expert tip:Plugins 會整合過去需要分別設定的 MCP config、skill 安裝與 app connector setup。單一 plugin 可以同時封裝這三者 — 讓團隊 onboarding 更快速,configuration 也更容易攜帶。
Plan Mode 與協作
Plan mode 讓 Codex 在執行變更前先設計方案。此模式自 v0.94.0 起預設啟用。14 請參閱 Decision Frameworks 中的「Plan Mode vs Direct Execution」決策樹。
進入 Plan Mode
/plan # Switch to plan mode
/plan "redesign the API layer" # Plan mode with initial prompt
在 plan mode 下,Codex 會: - 讀取檔案並分析程式碼庫 - 提出實作計畫 - 在您核准前不會進行任何變更 - 在專屬的 TUI 視圖中即時呈現計畫
Steer Mode
Steer mode(自 v0.98.0 起預設啟用)讓您在 Codex 正在執行工作時注入新指令,而不會中斷其當前任務。14
有兩種注入方式:
| 輸入 | 行為 | 使用時機 |
|---|---|---|
| Enter | 立即送出指令;Codex 會在當前回合內看到 | 緊急修正(「停下——別動那個檔案」)、釐清(「設定檔在 /etc/app.conf,不是預設路徑」)或優先順序變更(「先專注在測試上」) |
| Tab | 將指令排入下一個回合;Codex 先完成目前工作 | 後續任務(「完成後也更新 changelog」)、範圍擴充(「結束後執行 linter」)或非緊急上下文(「部署目標是 staging,不是 prod」) |
實務範例:
# Codex is refactoring the auth module...
[Enter] "Use bcrypt instead of argon2 — we already have it as a dependency"
→ Codex adjusts immediately, mid-turn
[Tab] "Once auth is done, update the migration script too"
→ Codex finishes auth refactor, then starts the migration
Steer mode 在 TUI 中始終啟用。若您偏好等 Codex 完成後再下指令,只需在回合結束後正常輸入即可——不需要任何特殊模式。
TUI 強化(v0.105.0–v0.106.0)
語法高亮(v0.105.0): TUI 現在會對程式碼區塊與 diff 進行行內語法高亮。使用 /theme 選擇配色方案。61
新增 TUI 指令(v0.105.0+):61
| 指令 / 按鍵 | 說明 |
|---|---|
/copy |
將最後的回應複製到剪貼簿 |
/clear |
清除 TUI 畫面 |
Ctrl+L |
清除畫面(鍵盤快捷鍵) |
/theme |
切換語法高亮配色方案 |
/plugins |
瀏覽、安裝與移除 plugins(v0.117.0+)75 |
/title |
設定終端機視窗標題;在 TUI 與 app-server TUI 中皆可使用(v0.117.0+)75 |
語音轉錄(v0.105.0,實驗性): 按下空白鍵即可透過語音轉錄輸入提示。此功能為實驗性,可能需要麥克風權限。61 自 v0.107.0 起,即時語音工作階段支援麥克風與喇叭裝置選擇,讓您可以指定特定的音訊輸入/輸出硬體。62
其他改進:
- 長連結即使在 TUI 中跨行換行也能保持可點擊(v0.105.0)61
- 本地檔案連結以更佳的格式呈現(v0.106.0)60
- 修正 sub-agents 的 Ctrl+C 處理,可正確終止子程序(v0.106.0)60
Memory System
Codex 具備持久化的 memory system(v0.100.0+),可跨工作階段儲存事實、偏好設定與專案上下文。24
Memory 指令
| 指令 | 說明 |
|---|---|
/m_update <fact> |
儲存一則記憶(例如 /m_update always use pytest, never unittest) |
/m_drop <query> |
移除符合查詢條件的記憶 |
記憶以 markdown 檔案儲存於 ~/.codex/memory/。Codex 會在工作階段開始時載入這些記憶,並在所有後續工作階段中據此調整行為。
適合儲存的內容
Memory 最適合用於持久性的偏好設定與專案事實:
- 專案慣例:「本專案使用 tab,不用空格」或「API 回應一律包含
meta欄位」 - 工具偏好:「使用
pnpm而非npm」或「以pytest -x --tb=short執行測試」 - 架構決策:「auth 模組位於
src/core/auth/,不在src/middleware/」 - 工作流程偏好:「在顯示 diff 前一律先執行 linter」
Pipeline 中的 Memory
執行 codex exec 時會自動載入記憶。這代表 CI/CD pipeline 與指令稿可享有與互動式工作階段相同的上下文——不需要在每次呼叫時重複指示。
Memory 精修(v0.101.0–v0.107.0)
- 機密過濾:寫入磁碟前會自動掃描記憶中的機密資訊
- CWD 感知:記憶檔案現在會記錄工作目錄上下文,以便進行專案特定的回顧
- 排除開發者訊息:phase-1 記憶輸入會排除開發者/系統訊息,聚焦於使用者互動以提升記憶品質
- Diff-based forgetting(v0.106.0):記憶現在採用 diff-based forgetting 機制移除過時事實,讓記憶儲存隨時間保持精簡且切題60
- 使用率感知選取(v0.106.0):記憶檢索現在具備使用率感知能力,優先選用高頻存取與近期相關的記憶60
- 可設定的記憶(v0.107.0):記憶現在完全可設定。使用
codex debug clear-memories清空所有已儲存的記憶以重新開始——適用於在不相關專案間切換上下文,或記憶狀態已偏離預期時62 - Phase-2 模型升級(v0.121.0):phase-2 記憶整合模型現已升級為
gpt-5.4(較先前預設更新)。phase-2 pipeline 會在工作階段之間執行,將 phase-1 紀錄轉化為持久事實;此次模型變更在相同 token 成本下提升了回顧品質。82 - TUI 記憶選單(v0.121.0):全新的工作階段內 UI 提供記憶模式、個別記憶刪除以及重設按鈕。記憶重設現在會保留過往的 rollouts而非使其失效,因此重設僅清除未來的回顧範圍,不會破壞工作階段重播。82
Memory 與 AGENTS.md 的取捨
| 使用情境 | Memory(/m_update) |
AGENTS.md |
|---|---|---|
| 個人偏好 | 使用 memory(跨所有專案持續生效) | 不適用 |
| 專案慣例 | 兩者皆可(memory 用於個人回顧,AGENTS.md 用於團隊共享) | AGENTS.md 適用於團隊 |
| 架構決策 | AGENTS.md(共享上下文) | 首選 |
| 工具指令 | Memory(個人快速參考) | AGENTS.md 適用於團隊 |
提示:使用
/m_update儲存應永久保留的事實。若僅是工作階段中的特定上下文,直接在對話中告訴 Codex 即可。團隊共享上下文則請使用 AGENTS.md。
Session Management
Codex 將工作階段保存於 ~/.codex/sessions/,讓您能在 CLI 與桌面端跨介面進行 resume、fork 與多執行緒工作流程。
Resume
從上次中斷處繼續:
codex resume # Interactive picker (sorted by recency)
codex resume <SESSION_ID> # Resume a specific session
codex exec resume --last "continue" # Non-interactive: resume most recent
TUI 中的 /resume slash 指令會開啟同一個具備搜尋功能的互動式選擇器。
Fork
分支一段對話,讓您在不影響當前進度的情況下探索其他方案:
/fork # Fork current conversation
/fork "try a different approach" # Fork with new prompt
Fork 會建立獨立的執行緒,共享 fork 點之前的歷史紀錄。任一 fork 中的變更不會影響另一個。這在比較不同方案(例如「fork 一份試試 Redis 而非 Memcached」)或安全探索風險較高的變更時相當實用。
將 Thread fork 為 sub-agents(v0.107.0): Thread 現在可以 fork 為獨立的 sub-agents,讓單一對話衍生出可自主執行的並行工作流。此功能延伸既有的 fork 模型——不僅是分支對話,fork 出的 thread 會成為具備獨立執行上下文的 sub-agent。62 自 v0.117.0 起,sub-agents 採用以路徑為基礎的位址(例如 /root/agent_a)並具備結構化的 agent 間訊息傳遞,讓多 agent 協作更明確且易於除錯。75
列出 Thread
檢視與管理現行工作階段:
/status # Current session info and token usage
/ps # Show background terminals in session
在桌面應用程式中,thread 會顯示於側邊欄,並附上完整歷史紀錄與 diff 預覽。
Session 生命週期
| 動作 | CLI | 桌面應用程式 |
|---|---|---|
| 開新工作階段 | codex 或 /new |
New Thread 按鈕 |
| Resume | codex resume 或 /resume |
點擊側邊欄的 thread |
| Fork | /fork |
在 thread 上按右鍵 → Fork |
| 結束 | /quit 或 Ctrl+C |
關閉 thread 分頁 |
| 刪除 | 從 ~/.codex/sessions/ 移除 |
按右鍵 → Delete |
工作階段會在 CLI 與桌面應用程式之間同步——可在其中一端開始,在另一端繼續。
非互動模式(codex exec)
codex exec 以非互動方式執行 Codex,適用於指令稿、CI/CD 與自動化作業。15
基本用法
codex exec "summarize the repository structure"
codex exec --sandbox workspace-write --ask-for-approval on-request "fix the CI failure"
codex exec --json "triage open bugs" -o result.txt
預設情況下,codex exec 會將進度與事件寫入 stderr,並將代理的最終訊息寫入 stdout。此設計使其能夠與標準 Unix 管線無縫組合。
JSON Lines 輸出
加上 --json 後,stdout 會變成 JSONL 事件串流:
codex exec --json "fix the tests" | jq
事件類型:thread.started、turn.started/completed/failed、item.started/completed、error
{"type":"thread.started","thread_id":"019c5c94-..."}
{"type":"turn.started"}
{"type":"item.started","item":{"id":"item_1","type":"command_execution","status":"in_progress"}}
{"type":"item.completed","item":{"id":"item_3","type":"agent_message","text":"..."}}
{"type":"turn.completed","usage":{"input_tokens":24763,"cached_input_tokens":24448,"output_tokens":122}}
結構化輸出
透過 JSON Schema 強制規範回應格式:
codex exec "Extract project metadata" \
--output-schema ./schema.json \
-o ./project-metadata.json
-o / --output-last-message 會將最終訊息寫入指定檔案。
工作階段恢復與審查
codex exec resume --last "continue where you left off"
codex exec resume <SESSION_ID> "fix the remaining issues"
codex exec review --base main # Code review against a branch
主要旗標
| 旗標 | 說明 |
|---|---|
--sandbox workspace-write --ask-for-approval on-request |
工作區範圍內的自動化作業,遇到跨界操作時要求核准 |
--json |
將 JSONL 事件串流輸出至 stdout |
-o, --output-last-message <file> |
將最終訊息儲存至檔案 |
--output-schema <file> |
依據 JSON Schema 驗證回應 |
--ephemeral |
不保留工作階段檔案 |
-C, --cd <dir> |
設定工作目錄 |
--add-dir <dir> |
額外可寫入的目錄 |
--skip-git-repo-check |
允許在 git 儲存庫之外執行 |
--dangerously-bypass-approvals-and-sandbox |
不啟用沙盒,不需核准(僅限 CI 使用) |
CI 驗證
codex exec 支援 CODEX_API_KEY,可在自動化環境中進行非互動式驗證。
codex exec啟動橫幅(v0.130.0)。codex exec啟動橫幅不再印出舊版的「research preview」字樣。若您的 CI 會擷取啟動輸出,現在的橫幅文字較為精簡;結構化的--json事件則維持不變。91
codex remote-control(v0.130.0+)
codex remote-control 是一個頂層指令,可啟動無頭(headless)app-server,專為由其他程序驅動而設計——IDE 擴充功能、自訂協調器或遠端控制平面皆可使用。它取代了許多整合者過去手動拼湊的多旗標 codex app-server 呼叫方式,為第三方工具提供單一且穩定的進入點,連接桌面版與 IDE 介面下執行的同一套 app-server 執行環境。91
# Start a headless, remotely controllable app-server
codex remote-control
# Same lifecycle as a TUI session: thread store, hooks, plugins, MCP, sandbox
# all initialize from your normal config.toml.
當您要建構需要列舉大量執行緒歷史記錄的 UI、又不想一次將所有回合載入記憶體時,建議將 codex remote-control 與下方的 app-server 分頁 APIs 搭配使用。
App-Server 執行緒分頁(v0.130.0+)
App-server 用戶端現在可以透過三種不同的回合項目檢視方式,對大型執行緒進行分頁處理:91
| 檢視 | 使用情境 |
|---|---|
| Unloaded | 僅列出——只取得執行緒結構而不附帶回合內容(最節省資源) |
| Summary | 每回合的精簡中介資料——適用於側邊欄與恢復選擇器 |
| Full | 完整的回合內容,包含工具呼叫與輸出結果 |
請將分頁與 v0.121.0 引入的 ThreadStore 介面搭配使用,以有效率地遍歷長時間執行的執行緒,這在協調器與 rollout 檔案分屬不同機器的 remote-control 部署中特別實用。82
App-Server 即時設定重新載入(v0.130.0+)
執行中的 app-server 執行緒現在會自動套用 config.toml 的變更,無須重新啟動——編輯設定、儲存後,執行中的執行緒會在下一個回合反映新的設定值。這是 codex remote-control 的錯誤修正配套:長時間執行的無頭伺服器可以就地重新設定,而不必整個關閉重啟。91
Codex Cloud 與背景任務 [EXPERIMENTAL]
狀態:Codex Cloud 為實驗性功能。介面、定價與可用性可能會有所變動。OpenAI 負責管理雲端環境,您無法掌控其基礎架構。
Codex Cloud 在 OpenAI 管理的環境中以非同步方式執行任務。4 另請參閱 GitHub Action 與 CI/CD,了解如何將 Codex 整合至您的 CI 管線。
運作方式
- 提交任務(透過 chatgpt.com/codex、Slack 整合或 CLI)
- Codex 將您的儲存庫複製到隔離的雲端沙盒
- 代理獨立作業:閱讀程式碼、執行測試、進行修改
- 完成後,Codex 會建立 PR 或提供差異供審查
- 在本機透過
codex apply <TASK_ID>套用結果
雲端網路存取
代理的網路存取預設為關閉,可依環境個別設定:
- Off:代理沒有網路存取權(預設)
- On:可選擇性設定網域允許清單與 HTTP 方法限制
Allowed domains: pypi.org, npmjs.com, github.com
Allowed methods: GET, HEAD, OPTIONS
即便代理網路功能關閉,設定指令稿仍可使用網路安裝相依套件。
Slack 整合
在 Slack 頻道或討論串中提及 @Codex 即可啟動雲端任務。
先決條件: 1. 符合資格的 ChatGPT 方案(Plus、Pro、Business、Enterprise 或 Edu) 2. 已連結的 GitHub 帳號 3. 至少設定一個雲端環境 4. 您的工作區已安裝 Slack 應用程式
Codex 會回覆任務連結,並在完成時張貼結果。
Cloud CLI
codex cloud exec --env <ENV_ID> "Fix failing tests" # Start a cloud task
codex cloud status <TASK_ID> # Check task progress
codex cloud diff <TASK_ID> # View task diff
codex cloud list # List recent tasks
codex cloud list --json # JSON output
codex cloud apply <TASK_ID> # Apply from cloud subcommand
codex apply <TASK_ID> # Apply diff (top-level shortcut)
Codex 桌面應用程式
Codex 桌面應用程式(macOS 與 Windows)提供針對多專案管理最佳化的圖形介面。16 Windows 版本於 2026 年 3 月 4 日推出,原生支援 PowerShell 與 Windows 沙箱。66
安裝
codex app # Auto-downloads and installs on first run
或直接下載:Codex.dmg(macOS)| Microsoft Store 提供(Windows)
主要功能
| 功能 | 說明 |
|---|---|
| 平行執行緒 | 同時跨多個專案執行多個任務 |
| 執行緒模式 | 以 Local、Worktree 或 Cloud 模式啟動執行緒 |
| 內建 Git 工具 | 檢視差異、新增註解、暫存/還原區塊、提交/推送、建立 PR |
| 整合終端機 | 每個執行緒專屬的終端機(Cmd+J) |
| 語音聽寫 | 以語音輸入提示(Ctrl+M) |
| 自動化 | 排程定期任務 |
| 通知 | 應用程式於背景執行時的完成/核准通知 |
| 防止休眠 | 可選設定,於任務執行期間保持機器喚醒 |
| Skills + MCP | 跨應用程式、CLI 與 IDE 擴充功能的共用設定 |
| MCP 快捷鍵 | 在編輯器中快速存取 MCP 工具的快捷鍵(App v26.226)63 |
| Review @mentions | 在程式碼審查註解中 @mention 協作者(App v26.226)63 |
| 自訂主題 | 在「設定」中提供顏色控制與字型選擇(App v26.312)72 |
| App-server TUI | 預設啟用(v0.117.0+):! shell 指令、檔案系統監看、附帶 bearer 驗證的遠端 WebSocket、跨工作階段的提示歷史回顧75 |
執行緒模式
每個執行緒於建立時可選擇下列三種模式之一:
| 模式 | 隔離方式 | 檔案存取 | 適用情境 |
|---|---|---|---|
| Local | 無 — 直接在您的專案目錄中運作 | 完整讀寫 | 快速任務、探索、非破壞性工作 |
| Worktree | Git worktree — 隔離的分支副本 | 隔離副本 | 功能開發、高風險重構、平行實驗 |
| Cloud | 遠端伺服器 — 在 OpenAI 基礎設施上執行 | 無本機存取 | 長時間執行的任務、類 CI 工作流程、非同步委派 |
Worktree 隔離機制:
當您啟動 Worktree 執行緒時,桌面應用程式會:
1. 在暫存目錄中建立新的 git worktree(git worktree add)
2. 從目前的 HEAD 簽出全新分支
3. 在 worktree 內執行代理 — 所有檔案變更皆隔離
4. 完成後呈現差異審查 — 您可選擇要合併回去的變更
如此一來,多個 Worktree 執行緒可在同一個 repo 上同時執行而不衝突。每個執行緒都擁有自己的分支與工作目錄。
自動化
自動化在應用程式本機執行,因此應用程式必須處於執行狀態,且專案需可在磁碟上存取:
- 在 Git repo 中,自動化使用專屬的背景 worktree(與您的工作目錄隔離)
- 在非 Git 專案中,執行直接於專案目錄中進行
- 自動化使用您的預設沙箱設定
設定自動化: 1. 在桌面應用程式中開啟專案 2. 點擊側邊欄的「Automations」分頁 3. 定義觸發條件(排程、webhook 或手動) 4. 撰寫提示並選擇執行模式(local 或 worktree) 5. 設定自動化執行時的 reasoning level(App v26.312)72 6. 自動化依排程執行,並將結果排入審查佇列
範例使用情境: - Issue 分類:自動分類並排序新 issue 的優先順序 - CI 監控:監看建構失敗並建議修正方式 - 警示回應:以診斷分析回應監控警示 - 相依套件更新:檢查並套用安全性修補程式
結果會出現在審查佇列中,等待人工核准。
Windows 支援
Codex Desktop App 於 2026 年 3 月 4 日在 Windows 上推出(App v26.304),原生支援 PowerShell、原生 Windows 沙箱,且功能與其他平台完全對等,包含 skills、自動化與 worktree,無需透過 WSL。66
GitHub Action 與 CI/CD
官方 GitHub Action 可將 Codex 整合至您的 CI/CD pipeline。18
基本使用
# .github/workflows/codex.yml
name: Codex
on:
pull_request:
types: [opened]
jobs:
codex:
runs-on: ubuntu-latest
outputs:
final_message: ${{ steps.run_codex.outputs.final-message }}
steps:
- uses: actions/checkout@v5
- name: Run Codex
id: run_codex
uses: openai/codex-action@v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
prompt-file: .github/codex/prompts/review.md
sandbox: workspace-write
safety-strategy: drop-sudo
設定選項
| 輸入 | 用途 |
|---|---|
openai-api-key |
用於 proxy/驗證設定的 API key |
responses-api-endpoint |
覆寫端點(例如 Azure Responses URL) |
prompt / prompt-file |
任務指示(兩者擇一) |
working-directory |
傳遞給 codex exec --cd 的目錄 |
sandbox |
workspace-write / read-only / danger-full-access |
codex-args |
額外的 CLI 旗標(JSON 陣列或 shell 字串) |
output-schema / output-schema-file |
用於 --output-schema 的結構化輸出 schema |
model / effort |
代理設定 |
output-file |
將最終訊息儲存至磁碟 |
codex-version |
釘選 CLI 版本 |
codex-home |
自訂 Codex home 目錄 |
allow-users / allow-bots |
觸發允許清單控制 |
safety-strategy / codex-user |
權限降低行為與使用者選擇 |
輸出:final-message,供下游 step/job 使用的 Codex 最終回應文字。
安全性策略
| 策略 | 說明 |
|---|---|
drop-sudo(預設) |
Linux/macOS;於 action step 後移除 sudo 能力 |
unprivileged-user |
以預先建立的低權限使用者執行 Codex |
read-only |
唯讀沙箱(runner/使用者權限風險仍適用) |
unsafe |
不降低權限;Windows runner 必須使用 |
存取控制
with:
allow-users: "admin,maintainer" # Limit who can trigger
allow-bots: false # Block bot-triggered runs
預設:僅具寫入權限的協作者可觸發 Codex 工作流程。
Codex SDK
TypeScript SDK 將 Codex 的代理能力嵌入自訂應用程式中。19
安裝
npm install @openai/codex-sdk
基本使用
import { Codex } from "@openai/codex-sdk";
const codex = new Codex();
const thread = codex.startThread();
// Multi-turn conversation
const turn1 = await thread.run("Diagnose CI failures and propose a fix");
console.log(turn1.finalResponse);
const turn2 = await thread.run("Implement the fix and add tests");
console.log(turn2.items);
// Resume a previous session
const resumed = codex.resumeThread("<thread-id>");
await resumed.run("Continue from previous work");
進階 SDK 功能
runStreamed(...):用於中間更新的非同步事件串流outputSchema:強制執行 JSON 結構化最終輸出- 多模態輸入:傳入文字 + 本機圖片(
{ type: "local_image", path: "..." }) - 圖片工作流程(v0.117.0):
view_image回傳 URL、生成的圖片可重新開啟,且圖片歷史可在工作階段恢復後保留75 - 多環境
view_image(v0.130.0):對於跨多個環境的工作階段(v0.124.0 引入每個 turn 的環境 + 工作目錄選擇,v0.125.0 又以黏性環境加以調整),view_image現在會透過所選環境解析檔案路徑,而非透過協調器的本機檔案系統。從遠端環境附加的圖片會相對於該環境的工作目錄取得,而非執行 SDK 的主機。91
Thread 與 Client 設定
// Custom working directory, skip git check
const thread = codex.startThread({
workingDirectory: "/path/to/project",
skipGitRepoCheck: true,
});
// Custom environment and config overrides
const codex = new Codex({
env: { CODEX_API_KEY: process.env.MY_KEY },
config: { model: "gpt-5.5" },
});
工作階段會儲存在 ~/.codex/sessions 之下。
執行環境:Node.js 18+。
效能最佳化
上下文管理
各模型的上下文視窗大小不同。截至 2026 年 4 月:Codex 中的 GPT-5.5 提供 400K(API 中為 1M)。GPT-5.4 / GPT-5.4-mini 分別提供 1M / 400K(在 Codex 中與 API 相同)。GPT-5.3-Codex / GPT-5.2-Codex 系列則使用 272K 輸入 + 128K 輸出(總預算 400K)。所有模型的填滿速度都比您預期的快 — 請主動管理:
- 定期使用
/compact:摘要對話歷史以釋放 token - 提供本機文件:高品質的
AGENTS.md與本機文件可減少探索開銷(探索會消耗上下文) - 使用
@附加特定檔案:直接參照檔案,而非要求 Codex 自行尋找 - 保持提示聚焦:包含明確檔案的範圍化提示,比開放式探索消耗更少上下文
Token 效率
| 技巧 | 效果 |
|---|---|
設定 model_reasoning_summary = "none" |
減少約 20% 輸出 token |
使用 model_verbosity = "low" |
較簡短的說明,更多的行動 |
| 對簡單任務使用 mini 模型 | 每則訊息成本顯著降低 |
| 將複雜任務拆分為聚焦的工作階段 | 提升每個工作階段的 token 效率 |
| 使用設定檔依任務切換設定 | 避免在例行工作上支付高 reasoning 成本 |
速度最佳化
gpt-5.3-codex-spark:低延遲變體,適合互動式配對--profile fast:預先設定的 mini 模型搭配低 reasoning- 平行工具執行:Codex 會並行執行獨立的讀取/檢查,因此請設計提示以利用此特性
- 以結果為導向的循環:要求「實作、測試、修正、達成綠燈即停止」,而非逐步指示
如何除錯問題?
常見問題與解決方案
| 問題 | 原因 | 解決方案 |
|---|---|---|
| 「重新連線」迴圈 | 多個Codex執行個體 | 終止所有程序,等待60秒,重新啟動單一執行個體 |
| 401驗證錯誤 | 過期憑證 | rm ~/.codex/auth.json && codex login |
| 沙箱中網路被封鎖 | 預設行為 | -c 'sandbox_workspace_write.network_access=true' |
| WSL2連線中斷 | WSL狀態損毀 | 在PowerShell中執行wsl --shutdown,等待1分鐘,重新啟動 |
| 修補失敗 | 換行符號不一致 | 統一為LF,提供確切的檔案文字 |
| 內容壓縮失敗 | 內容過多 | 降低reasoning effort,拆分為較小的任務 |
| 模型意外變更 | Config.toml覆蓋 | 執行/config檢視生效的設定與來源 |
| Plan mode允許變更 | 已知錯誤 | Issue #11115 |
| 忘記AGENTS.md指示 | 內容限制 | 保持指示簡潔;使用skill檔案存放詳細程序 |
| Read Only模式中停滯 | 已知問題 | Discussion #7380 |
錯誤訊息參考
| 錯誤訊息 | 意義 | 修正方式 |
|---|---|---|
Error: EACCES permission denied |
沙箱封鎖了檔案操作 | 檢查sandbox模式;若Codex需要編輯檔案,請使用workspace-write |
Error: rate limit exceeded |
達到API速率限制 | 等待後重試;降低model_reasoning_effort或切換至較輕量的模型 |
Error: context length exceeded |
對話超過272K input tokens | 使用/compact進行摘要,或以/new開啟新工作階段 |
Error: MCP server failed to start |
MCP server程序崩潰或逾時 | 透過codex mcp get <name>檢查設定;增加startup_timeout_sec |
Error: authentication required |
無有效的API金鑰或工作階段 | 執行codex login或設定CODEX_API_KEY |
Error: sandbox execution failed |
沙箱內指令執行失敗 | 檢查指令語法;確認沙箱環境中具備所需工具 |
WARN: skill not found |
預期路徑下不存在所引用的skill | 檢查/skills清單;確認skill資料夾位置 |
Error: wire format mismatch |
提供者的wire_api設定錯誤 |
OpenAI端點請使用wire_api = "responses"(參閱Custom Model Providers) |
診斷工具
codex --version # Check CLI version
codex login status # Verify authentication
codex mcp list # Check MCP server status
codex debug app-server --help # Debug app server issues
工作階段內的TUI診斷:
/status # Token/session overview
/config # Inspect effective config values and sources
/compact # Summarize history to reclaim context
注意:
codex --verbose並非有效的頂層旗標。請改用上述debug子指令與TUI診斷功能。
全新重新安裝
npm uninstall -g @openai/codex && npm install -g @openai/codex@latest
除錯模式
codex debug app-server send-message-v2 # Test app-server client
回報問題
/feedback # Send logs to Codex maintainers (in TUI)
或於github.com/openai/codex/issues提交問題。1
Codex Security [PREVIEW]
Codex Security於2026年3月6日進入研究預覽階段,將具備情境感知能力的應用程式安全審查整合至Codex技術堆疊中。77ChatGPT Pro、Enterprise、Business與Edu客戶可透過Codex web使用此功能。
運作方式:Codex Security會分析儲存庫以建立專案專屬的威脅模型,辨識依據真實世界影響分類的漏洞,並在沙箱環境中進行壓力測試以驗證結果。該代理會呈現較高可信度的發現並提供修正建議,降低不重要錯誤所造成的雜訊。
效能表現:在研究預覽期間,Codex Security掃描了120萬次commits,辨識出10,561個高嚴重性漏洞。準確度隨時間提升——雜訊減少84%,過度回報的嚴重性降低90%以上,誤判率減半。此系統已在OpenSSH、GnuTLS與Chromium中發現真實漏洞,並獲指派14個CVE編號。77
注意:Codex Security與CLI內建的沙箱安全模型彼此獨立。沙箱保護您的機器免受Codex影響;Codex Security則保護您的程式碼基底免於漏洞威脅。
企業部署
管理控制(requirements.toml)
管理員透過 requirements.toml 強制執行企業政策,這是一個由管理員強制套用的設定檔,用於限制使用者無法覆寫的安全敏感設定:21
# /etc/codex/requirements.toml
# Restrict which approval policies users can select
allowed_approval_policies = ["untrusted", "on-request", "never"]
# Limit available sandbox modes
allowed_sandbox_modes = ["read-only", "workspace-write"]
# Control web search capabilities
allowed_web_search_modes = ["cached"]
# Allowlist MCP servers by identity (both name and identity must match)
[mcp_servers.approved-server]
identity = { command = "npx approved-mcp-server" }
# Admin-enforced command restrictions
[[rules.prefix_rules]]
pattern = [{ token = "rm" }, { any_of = ["-rf", "-fr"] }]
decision = "forbidden"
justification = "Recursive force-delete is prohibited by IT policy"
[[rules.prefix_rules]]
pattern = [{ token = "sudo" }]
decision = "prompt"
justification = "Elevated commands require explicit approval"
不同於使用者層級的
config.toml用於設定偏好,requirements.toml是一層硬性限制,用於約束使用者可選擇的值,且使用者無法覆寫。管理員的 requirements 規則只能 prompt 或 forbid(永遠無法靜默允許)。
macOS MDM 設定
使用 com.openai.codex 偏好網域透過 MDM 分發。21 Codex 遵循標準的 macOS MDM 酬載(Jamf Pro、Fleet、Kandji 等)。將 TOML 編碼為 base64,且不換行:
| 鍵 | 用途 |
|---|---|
config_toml_base64 |
Base64 編碼的受管理預設值(使用者可變更的起始值) |
requirements_toml_base64 |
Base64 編碼的管理員強制要求(使用者無法覆寫) |
優先順序(由高至低):
- macOS 受管理偏好(MDM)
- 雲端取得的要求(ChatGPT Business / Enterprise)
/etc/codex/requirements.toml(本機檔案系統)
雲端要求僅會填補未設定的 requirement 欄位,因此較高優先順序的受管理層級永遠勝出。雲端要求採盡力而為原則;若取得失敗或逾時,Codex 會在沒有雲端層的情況下繼續運作。
OpenTelemetry 整合
Codex 支援將 OpenTelemetry trace-context 從標準 OTel 環境變數一路傳遞至 OpenAI API 呼叫。在啟動 Codex 之前設定標準環境變數:
# Point Codex at your OTel collector
export OTEL_EXPORTER_OTLP_ENDPOINT="https://otel-collector.internal:4318"
export OTEL_SERVICE_NAME="codex-cli"
export OTEL_RESOURCE_ATTRIBUTES="team=platform,env=production"
# Launch Codex — trace context propagates to all OpenAI API calls
codex
- 標準的
OTEL_*環境變數均受支援(端點、服務名稱、資源屬性) - Trace context 會經由 Codex 傳遞至 API 呼叫,實現端到端的可觀測性
- 利用資源屬性依團隊、環境或專案標記 traces
- 啟用 prompt/工具記錄時請留意隱私要求——traces 可能包含程式碼片段
- 可設定的 OpenTelemetry trace 中繼資料(v0.130.0+)。 除了標準的
OTEL_RESOURCE_ATTRIBUTES封裝外,codex-otelcrate 現在開放可設定的 trace 中繼資料,管理員可以用組織專屬的維度(成本中心、專案 ID、工單編號)標記 traces,而不必在每次呼叫時從頭重建OTEL_RESOURCE_ATTRIBUTES。請搭配同一版本所推出更豐富的審查/回饋分析,以便在 CLI、app-server 與 remote-control 工作階段之間進行統一的除錯與分流。91
企業存取
- ChatGPT Business / Enterprise / Edu:由組織管理員控管存取,並自動套用雲端取得的要求。透過您的身分提供者(Okta、Entra ID 等)以 SAML/OIDC 支援 SSO
- API:標準的 API 認證、計費以及組織/專案控管。OpenAI 發布 SOC 2 Type II 與 SOC 3 報告;Enterprise 等級可提供 HIPAA BAA
- Codex SDK:嵌入內部工具與工作流程
- 大規模政策強制:使用 MDM 分發的
requirements_toml_base64或檔案系統層級的/etc/codex/requirements.toml
資料處理與合規: - 在 OpenAI 的 Business/Enterprise/API 條款下,API 的輸入/輸出不會用於訓練 - 在資料駐留方面,OpenAI API 流量預設透過位於美國的基礎設施路由;若有歐盟資料駐留需求,請洽詢 OpenAI 的 Enterprise 業務團隊 - 工作階段逐字稿儲存於本機;只有 API 呼叫會離開機器 - ChatGPT Enterprise 支援 SOC 2、GDPR 與 CCPA 等合規架構
推行策略
針對組織建議的分階段推行方式:
- 試行(第 1-2 週):部署給 3-5 位資深工程師,並透過
requirements.toml強制執行untrusted沙箱模式與cached網路搜尋。蒐集對 AGENTS.md 模式與 MCP 伺服器需求的回饋。 - 團隊擴展(第 3-4 週):推行至整個團隊。透過 MDM 或 repo 分發團隊標準的
config.toml。為受信任的儲存庫啟用workspace-write沙箱。 - CI 整合(第 5-6 週):將
codex-action加入 CI/CD 流水線,以進行自動化的 PR 審查與測試產生。使用--ephemeral讓成本可預測。 - 全組織(第 2 個月以後):透過 MDM 部署,並以
requirements.toml強制執行已核可的 MCP 伺服器、沙箱政策與模型 allowlist。
稽核模式
追蹤 Codex 使用情形並強制合規:
- OpenTelemetry traces:監控各團隊的 API 呼叫量、token 用量與延遲
- 工作階段持久化:稽核
~/.codex/sessions/以供合規審查(在敏感情境下可使用--ephemeral停用) - MCP identity 強制:
requirements.toml會記錄被封鎖的伺服器嘗試——可審查未授權的工具使用情形 - Git 稽核軌跡:所有 Codex 的檔案變更皆透過標準 git——可透過分支歷程與 PR diffs 進行審查
最佳實踐與反模式
提示模式
- 約束驅動的提示:先提出邊界。「請勿變更API合約。僅重構內部實作。」
- 結構化重現步驟:編號步驟比模糊描述能產生更好的修正
- 驗證請求:以「執行 lint 與最小相關的測試套件。回報指令與結果。」作結
- 檔案參照:使用
@filename將特定檔案附加至上下文 - 以結果為導向的迴圈:「實作、執行測試、修正失敗,僅在所有測試通過時停止。」Codex 會反覆執行直到完成
測試哲學
社群匯聚於測試驅動的 AI 協作:22
- 預先定義測試作為完成訊號
- 讓 Codex 反覆執行直到測試通過(red → green → refactor)
- 採用 Tiger Style 程式設計模式
- 請求修補時提供精確的檔案文字。Codex 採用嚴格匹配,而非基於 AST 的模糊修補
上下文管理最佳實踐
- 提供高品質的本地文件,而非依賴網路搜尋
- 維護結構化的 markdown,包含目錄與進度檔案(「漸進式揭露」)
- 在受追蹤的檔案間統一行尾符號(LF 與 CRLF),以避免修補失敗
- 保持
AGENTS.md簡潔,因為冗長的指令會被推出上下文
Git 工作流程
- 在不熟悉的儲存庫執行 Codex 前,務必建立新分支
- 採用基於修補的工作流程(
git diff/git apply),而非直接編輯 - 像審查 PR 一樣審視 Codex 的建議
- 提交前使用
/diff驗證變更
社群技能與提示
feiskyer/codex-settings 儲存庫提供社群維護的設定:23
可重複使用的提示(位於 ~/.codex/prompts/):
- deep-reflector:從開發工作階段中萃取學習成果
- github-issue-fixer [issue-number]:系統化的 bug 分析與 PR 建立
- github-pr-reviewer [pr-number]:程式碼審查工作流程
- ui-engineer [requirements]:生產等級的前端開發
社群技能:
- claude-skill:以權限模式將任務交接給 Claude Code
- autonomous-skill:具進度追蹤的多工作階段任務自動化
- deep-research:平行子任務協調
- kiro-skill:需求 → 設計 → 任務 → 執行的管線
反模式
浪費 token、產生劣質結果或造成挫折工作流程的常見錯誤。
成本反模式
| 反模式 | 為何失敗 | 修正方式 |
|---|---|---|
對所有任務使用 xhigh 推理 |
token 成本為 3-5 倍,且簡單任務的邊際效益遞減 | 預設使用 medium;將 xhigh 保留給跨檔案架構決策 |
從不使用 /compact |
上下文填滿至 272K,回應品質下降 | 在每個重大里程碑後或 /status 顯示使用率超過 60% 時進行壓縮 |
| 在 CI 中執行旗艦模型 | 對例行檢查而言過於昂貴 | 建立 ci profile,搭配 gpt-5.1-codex-mini 與 low 推理 |
上下文反模式
| 反模式 | 為何失敗 | 修正方式 |
|---|---|---|
| 開放式的「探索一切」提示 | Codex 讀取數十個檔案,將上下文耗費於無關的程式碼上 | 以特定檔案界定範圍:「檢視 src/auth/login.py 與 tests/test_auth.py」 |
專案中沒有 AGENTS.md |
Codex 浪費回合來探索專案結構 | 新增一份 20 行的 AGENTS.md,記載關鍵路徑、慣例與測試指令 |
| 附加整個目錄 | 以無關檔案淹沒上下文 | 使用 @filename 僅附加 Codex 所需的檔案 |
工作流程反模式
| 反模式 | 為何失敗 | 修正方式 |
|---|---|---|
直接在 main 上工作 |
沒有安全網;高風險編輯難以還原 | 啟動 Codex 前務必建立功能分支 |
提交前略過 /diff |
Codex 可能進行了非預期的變更 | 每次任務完成後、任何提交前審視 /diff |
| 忽略測試輸出 | 若您不標示失敗,Codex 會略過失敗繼續執行 | 在提示中使用「執行測試,僅在全部通過時停止」 |
| 從不分叉對話 | 一次錯誤轉向便會污染整個上下文 | 在高風險探索前 /fork;捨棄不良分支 |
提示反模式
| 反模式 | 為何失敗 | 修正方式 |
|---|---|---|
| 「修正 bug」(沒有上下文) | Codex 猜測是哪個 bug,讀取所有內容 | 「修正 src/api/handler.py:42 中的 TypeError — 未驗證時 user.name 為 None」 |
| 在單一訊息中包含多任務的提示 | Codex 混淆任務,遺漏部分 | 每則訊息一個任務;使用 steer 模式(Tab)排隊後續任務 |
| 每則訊息都重複上下文 | 將 token 浪費在重複資訊上 | 對持久性事實使用 /m_update;參照先前的上下文 |
工作流程秘訣
常見開發情境的端對端模式。
秘訣 1:新專案設定
mkdir my-app && cd my-app && git init
codex
> Create a FastAPI project with: main.py, requirements.txt, Dockerfile,
basic health endpoint, and a README. Use async throughout.
> /init
審視產生的 AGENTS.md,編輯使其符合您的慣例,然後:
> Run the health endpoint test and confirm it passes
秘訣 2:日常開發流程
cd ~/project && git checkout -b feature/user-auth
codex
> @src/models/user.py @src/api/auth.py
Add password reset functionality. Requirements:
1. POST /api/auth/reset-request (email → sends token)
2. POST /api/auth/reset-confirm (token + new password)
3. Tests for both endpoints
Run tests when done.
以 /diff 審視,然後提交。
秘訣 3:以 Plan 模式進行複雜重構
codex
> /plan Migrate the database layer from raw SQL to SQLAlchemy ORM.
Constraints: don't change any API contracts, keep all existing tests passing.
審視計畫。核可或調整方向:
[Tab] Also add a migration script using Alembic
Codex 執行完畢後,進行驗證:
> Run the full test suite and report results
> /diff
秘訣 4:以 codex exec 進行 PR 審查
codex exec --model gpt-5.1-codex-mini \
"Review the changes in this branch against main. \
Flag security issues, missed edge cases, and style violations. \
Format as a markdown checklist." \
-o review.md
秘訣 5:以 Cloud Tasks 進行除錯 [EXPERIMENTAL]
codex cloud exec --env my-env "Diagnose why the /api/orders endpoint returns 500 \
for orders with > 100 line items. Check the serializer, database query, \
and pagination logic. Propose a fix with tests."
稍後檢查進度:
codex cloud status <TASK_ID>
codex cloud diff <TASK_ID>
完成後在本地套用修正:
codex apply <TASK_ID>
遷移指南
從 Claude Code 遷移
| Claude Code 概念 | Codex 對應項目 |
|---|---|
CLAUDE.md |
AGENTS.md(開放標準) |
.claude/settings.json |
.codex/config.toml(TOML 格式) |
--print 旗標 |
codex exec 子指令 |
--dangerously-skip-permissions |
--dangerously-bypass-approvals-and-sandbox |
| Hooks(12 種以上事件) | Hooks(SessionStart、Stop、UserPromptSubmit、AfterAgent、AfterToolUse;v0.99.0–v0.116.0) |
| Subagents(Task 工具) | 子代理(內部使用,最多 6 個;沒有面向使用者的 Task 工具對應項) |
/compact |
/compact(完全相同) |
/cost |
/status(顯示 token 用量) |
| 模型:Opus/Sonnet/Haiku | 模型:gpt-5.5 / gpt-5.4 / gpt-5.4-mini / 舊版 gpt-5.3-codex 變體(Codex 採用 OpenAI 的 GPT-5.x 模型家族) |
claude --resume |
codex resume |
| 權限規則 | Sandbox 模式 + 核准政策 |
| settings.json 中的 MCP 設定 | config.toml 中的 MCP 設定 |
需要理解的關鍵差異:
- Sandbox 為作業系統層級:Codex 使用 Seatbelt/Landlock,而非容器。限制在核心層級運作,位於應用程式層之下。
- Hooks 持續擴充中:Codex 目前支援 5 個 hook 事件:
SessionStart、Stop與UserPromptSubmit(v0.114.0–v0.116.0,實驗性)以及AfterAgent(v0.99.0)和AfterToolUse(v0.100.0)。此系統涵蓋會話生命週期、提示攔截與工具層級自動化,不過 Claude Code 的 12 種以上生命週期事件仍提供更廣泛的覆蓋範圍。對於尚未涵蓋的自動化模式,請改用 AGENTS.md 指令或 skills。 - Sub-agents v2(v0.117.0):子代理現在採用基於路徑的位址(例如
/root/agent_a),並具備結構化的代理間訊息傳遞與代理列表功能。75 此功能延伸了既有機制(最多 6 個並行,自 v0.91.0 的 12 個降低)。多代理角色仍可透過設定自訂(v0.104.0+)。47 v0.105.0 新增了spawn_agents_on_csv,可跨列扇出並提供進度追蹤與 ETA。61 Codex 目前仍缺少 Claude Code 用於使用者導向委派的明確 Task 工具 UX——委派模式請使用雲端任務或 SDK 編排。 - AGENTS.md 跨工具通用:您的 AGENTS.md 可在 Cursor、Copilot、Amp、Jules、Gemini CLI 以及 60,000 個以上的開源專案中使用。CLAUDE.md 僅限 Claude 使用。
- 設定檔取代手動切換:不必每次執行時更改旗標,改於 config.toml 中定義設定檔即可。
從 GitHub Copilot 遷移
| Copilot 概念 | Codex 對應項目 |
|---|---|
| Copilot CLI(代理式終端機) | 互動式 CLI 或桌面應用程式 |
| 專業代理(Explore、Plan) | Skills + plan 模式 + steer 模式 |
copilot-instructions.md / AGENTS.md |
AGENTS.md(同一標準) |
| MCP 支援 | MCP 支援(STDIO + HTTP) |
| ACP(Agent Client Protocol) | Hooks(AfterAgent、AfterToolUse) |
| Copilot SDK | Codex SDK(TypeScript) |
| Coding agent 工作流程 | Codex 代理搭配 sandbox/核准控制 + 雲端任務 |
您能獲得的優勢:
- 作業系統層級的 sandbox(Seatbelt/Landlock——核心強制執行,而非容器型)
- 透過 codex apply 進行雲端任務委派
- 用於切換工作流程的設定檔
- 支援 worktree 隔離的桌面應用程式
從 Cursor 遷移
| Cursor 概念 | Codex 對應項目 |
|---|---|
專案規則(.cursor/rules)/ AGENTS.md |
AGENTS.md + 設定檔/設定 |
| Agent chat/composer 工作流程 | 互動式 CLI 或桌面應用程式 |
@ 檔案參照 |
@ 檔案參照(完全相同) |
| 套用/編輯 + 審查 | 內建的修補與 diff 審查 |
快速參考卡
╔═══════════════════════════════════════════════════════════════╗
║ CODEX CLI QUICK REFERENCE ║
╠═══════════════════════════════════════════════════════════════╣
║ ║
║ LAUNCH ║
║ codex Interactive TUI ║
║ codex "prompt" TUI with initial prompt ║
║ codex exec "prompt" Non-interactive mode ║
║ codex app Desktop app ║
║ codex resume Resume previous session ║
║ codex fork Fork a session ║
║ ║
║ FLAGS ║
║ -m, --model <model> Select model ║
║ -p, --profile <name> Load config profile ║
║ -s, --sandbox <mode> Sandbox mode ║
║ -C, --cd <dir> Working directory ║
║ -i, --image <file> Attach image(s) ║
║ -c, --config <key=value> Override config ║
║ --ask-for-approval <p> Approval policy ║
║ --oss Use local models (Ollama) ║
║ --search Enable live web search ║
║ ║
║ SLASH COMMANDS (in TUI) ║
║ /compact Free tokens /diff Git diff ║
║ /review Code review /plan Plan mode ║
║ /model Switch model /status Session info ║
║ /fork Fork thread /goal Persisted goal ║
║ /vim Modal Vim /hooks Browse/toggle hooks ║
║ /init AGENTS.md scaffold ║
║ /mcp MCP tools /skills Invoke skills ║
║ /ps Background /personality Style ║
║ /permissions Approval mode /statusline Footer config ║
║ /fast Toggle fast mode (default: on) ║
║ /copy Copy last response to clipboard ║
║ /clear Clear screen /theme Syntax highlighting ║
║ ║
║ TUI SHORTCUTS ║
║ @ Fuzzy file search ║
║ !command Run shell command ║
║ Ctrl+G External editor ║
║ Ctrl+L Clear screen ║
║ Enter Inject instructions (while running) ║
║ Esc Esc Edit previous messages ║
║ ║
║ EXEC MODE (CI/CD) ║
║ codex exec --sandbox workspace-write "task" Sandboxed auto ║
║ codex exec --json -o out.txt "task" JSON + file output ║
║ codex exec --output-schema s.json Structured output ║
║ codex exec resume --last "continue" Resume session ║
║ ║
║ MCP MANAGEMENT [EXPERIMENTAL] ║
║ codex mcp add <name> -- <cmd> Add STDIO server ║
║ codex mcp add <name> --url <u> Add HTTP server ║
║ codex mcp list List servers ║
║ codex mcp login <name> OAuth flow ║
║ codex mcp remove <name> Delete server ║
║ ║
║ PLUGINS ║
║ codex plugin marketplace add <src> Add marketplace ║
║ codex plugin marketplace upgrade Upgrade marketplaces ║
║ ║
║ CLOUD [EXPERIMENTAL] ║
║ codex cloud exec --env <ID> Start cloud task ║
║ codex cloud status <ID> Check task progress ║
║ codex cloud diff <ID> View task diff ║
║ codex cloud list List tasks ║
║ codex apply <TASK_ID> Apply cloud diff locally ║
║ ║
║ CONFIG FILES ║
║ ~/.codex/config.toml User config ║
║ .codex/config.toml Project config ║
║ ~/.codex/AGENTS.md Global instructions ║
║ AGENTS.md Project instructions ║
║ requirements.toml Enterprise policy constraints ║
║ ║
║ SANDBOX MODES ║
║ read-only Read files only, no mutations ║
║ workspace-write Read/write in workspace + /tmp ║
║ danger-full-access Full machine access ║
║ ║
║ APPROVAL POLICIES ║
║ untrusted Prompt for all mutations ║
║ on-request Prompt for boundary violations ║
║ never No prompts ║
║ ║
║ MODELS (April 2026) ║
║ gpt-5.5 Recommended default (400K in Codex) ║
║ gpt-5.5-pro Highest-effort GPT-5.5 tier ║
║ gpt-5.4 Prior flagship / fallback ║
║ gpt-5.4-mini Subagent work, 2x faster (400K) ║
║ gpt-5.3-codex Legacy coding specialist ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
變更記錄
| 日期 | 版本 | 變更內容 | 來源 |
|---|---|---|---|
| 2026-05-15 | Guide v2.27:security-hygiene與latest-line維護修訂。本機codex --version傳回codex-cli 0.130.0;codex features list顯示hooks與plugins為穩定/已啟用,而remote_control仍在開發中。穩定版指南指引仍固定於CLI v0.130.0。新增可公開發布的安全指引,將命令輸出、session transcripts、shell snapshots、logs、helper scripts,以及有意設置的secret stores視為彼此獨立的稽核面。 |
91 95 | |
| 2026-05-13 | Guide v2.26:latest-line維護檢查。本機codex --version傳回codex-cli 0.130.0;穩定版指南指引仍固定於CLI v0.130.0。v0.131.0列車已進展至alpha.9,但仍屬prerelease,未提升至指南標題或TL;DR。94 |
91 94 | |
| 2026-05-09 | Guide v2.25:CLI v0.130.0穩定版(2026年5月8日,23:09 UTC)。新增codex remote-control頂層命令,用於headless app-server控制(#21424);plugin詳細資訊顯示bundled hooks、plugin分享公開link metadata、discoverability controls,以及更新後的share settings(#21447、#21495、#21637);app-server thread pagination,支援unloaded/summary/full turn檢視(#21566);透過AWS aws login console-login credentials進行Bedrock auth(#21623);view_image會透過所選環境解析multi-environment sessions(#21143);running threads的live app-server config refresh(#21187);自codex exec啟動banner移除「research preview」措辭(#21683);可設定的OpenTelemetry trace metadata+更完整的review/feedback analytics(#21556、#18747、#21434、#21498);Linux sandbox startup hardening、Windows sandbox對desktop runtime binary cache的grant(#21564)。v0.131.0 alpha線正在進行中(5月9日alpha.1、alpha.2、alpha.4,稍後5月12日alpha.9)。僅註腳:GPT-5.5 Instant已於2026年5月5日推出至free tier。92 |
91 | |
| 2026-05-08 | Guide v2.24:Codex for Chrome(2026年5月7日)。新增Chrome extension,成為繼CLI、desktop app、IDE extension與cloud之後的第5個Codex操作介面。此extension可在背景跨分頁平行運作,不會接管瀏覽器,並提供per-site allow-listing以控制權限。更新Key Takeaways與Core Interaction Surfaces,從4個介面改為5個。 | 90 | |
| 2026-05-07 | Guide v2.23:CLI v0.129.0穩定版(2026年5月7日,17:02 UTC)。新增composer中的modal Vim editing(/vim+可設定default-mode)、重新設計的TUI workflow picker(更容易resume/fork、raw scrollback mode)、TUI內建/hooksbrowser、theme-aware status line並可選擇顯示PR+branch-change summaries、plugin管理升級(workspace sharing、share access controls、source filtering、marketplace operations)、/goal生命週期變更(experimental goals在resume後保持paused,除非選擇重新啟用)、Linux sandbox startup hardening、Windows sandbox可靠性改善,以及Bubblewrap升級至0.11.2並納入上游安全性修補。也記錄2026年5月usage limit提升(Codex Plus 5小時限制提高25倍+每月100美元tier加倍,兩者皆至2026年5月31日止)。 |
89 | |
| 2026-05-05 | Guide v2.22:將目前指引同步至CLI v0.128.0。新增持久化/goalworkflows、codex update、可設定的TUI keymaps、明確的permission-profile指引,以及目前codex plugin marketplace命令語法。修正過時指引:標記js_repl已移除、以明確sandbox/approval flags或permissions profiles取代--full-auto範例,並依OpenAI於2026年7月23日的deprecation table標示舊版GPT-5.2/5.1 Codex models。 |
86 87 88 | |
| 2026-04-24 | Guide v2.21:GPT-5.5發布(2026年4月23日至24日)+CLI v0.122.0–v0.125.0。GPT-5.5是OpenAI新的旗艦模型——Codex中400K context window(API中1M),input/output每MTok 5/30美元(為GPT-5.4費率的2倍,但在token-efficiency gains後,實際增幅約20%)。Benchmarks:82.7% Terminal-Bench 2.0(SOTA)、84.9% GDPval、78.7% OSWorld-Verified、98.0% Tau2-bench Telecom。可用於Codex CLI/web/desktop與API;建議作為多數Codex任務的預設選擇。ChatGPT Plus/Pro/Business/Enterprise/Edu/Go於4月23日推出;API於4月24日推出。90+個新的plugin partners,包括Atlassian Rovo、CircleCI、CodeRabbit、GitLab Issues、Microsoft Suite、Neon by Databricks、Remotion、Render與Superpowers。CLI v0.122.0:filesystem deny-read glob policies+managed deny-read requirements+platform sandbox enforcement+隔離的codex exec執行,會忽略user config/rules;tool discovery與image generation預設啟用;以original-detail metadata為MCP與js_repl提供更高細節的image handling;跨clients解決app-server stale-prompt;resumed/forked threads會立即重播token usage;remote-control startup可容忍缺少ChatGPT auth;MCP startup cancellation再次可透過app-server sessions運作;內部分拆為codex-core-plugins。CLI v0.123.0:內建amazon-bedrockmodel provider並支援AWS profile;/mcp verbose提供完整MCP diagnostics、resources與resource templates(一般/mcp保持快速);plugin MCP loading可接受.mcp.json中的mcpServers與top-level server maps;realtime handoffs會把transcript deltas交付給background agents(並提供明確的silent-stay選項);remote environments的host-specific remote_sandbox_config;更新bundled model metadata(當時預設為gpt-5.4)。修正:rollback後的/copy、shell command執行期間queued text、VS Code WSL Unicode/dead-key input、stale proxy env restore、codex exec繼承root-level shared flags、TUI中洩漏review prompts。CLI v0.124.0:TUI快速reasoning controls(Alt+,降低/Alt+.提高);接受model upgrades會將reasoning重設為新模型預設值;app-server sessions可管理多個環境,並支援per-turn environment+working-directory selection;對OpenAI-compatible providers提供first-class Amazon Bedrock支援(AWS SigV4 signing、credential auth);remote plugin marketplaces提供可靠detail lookups與更大的result pages;hooks現已穩定——可於config.toml與requirements.toml中inline設定,觀察MCP tools+apply_patch+long-running Bash sessions;符合資格的ChatGPT plans預設使用Fast service tier,除非明確退出。修正:Cloudflare cookies會在已核准ChatGPT hosts間保留、負載下的websocket可靠性、side conversations之間的permission-mode drift、wait_agent mailbox-queue timing、本機stdio MCP relative-command path resolution、startup managed-config edge cases。CLI v0.125.0(4月24日):app-server Unix socket transport、pagination-friendly resume/fork、sticky environments、remote thread config/store plumbing;app-server plugin management會安裝remote plugins並升級已設定的marketplaces;permission profiles round-trip涵蓋TUI sessions、user turns、MCP sandbox state、shell escalation與app-server APIs;model providers負責model discovery,並將AWS/Bedrock account state公開給app clients;codex exec --json會回報reasoning-token usage;rollout tracing會記錄tool/code-mode/session/multi-agent relationships,並提供debug reducer command。修正:/review interrupt不再卡住TUI、exec-server output/stream-closure handling、app-server會遵守明確標為untrusted的project config、notification bursts期間的websocket disconnection、Windows sandbox startup與background process handling、thread limits與agent paths的config-schema validation。 |
83 84 85 | |
| 2026-04-16 | Guide v2.20:CLI v0.121.0(2026-04-15)。Plugin Marketplace(codex marketplace add <source>),支援GitHub、git URL、local-dir與marketplace.jsonsource types。TUI reverse history search(Ctrl+R)與slash-command recall。TUI中的Memories menu可reset/deletion;memory reset現在會保留past rollouts。Phase-2 memory consolidation model升級至GPT-5.4。具Bubblewrap sandboxing的Secure devcontainer profile(僅WSL2;拒絕WSL1)。macOS sandbox:Unix socket allowlists與private DNS解除封鎖。danger-full-access denylist-only mode已移除——full-access現在為二元模式。MCP tools以namespaces註冊;supports_parallel_tool_calls flag已接通;sandbox-state metadata會流經MCP tool metadata。Guardian review sessions會停用hooks。Status line新增context-percent indicator;CLI update announcement會顯示新版本。Windows resume --last已修正verbatim paths。用於本機thread lookups的codex-thread-storeinterface。 |
82 | |
| 2026-04-13 | Guide v2.19:CLI v0.119.0–v0.120.0。Realtime voice sessions(V2 WebRTC,transport可設定)。MCP Apps支援resource reads、elicitations、file uploads。codex exec-serverexperimental。可依ID或name使用/resume。Ctrl+O複製最新回應。TUI中的Hook activity improvements。SessionStart hooks可區分/clear。 |
80 81 | |
| 2026-04-04 | Guide v2.18:更新Business pricing(25美元/月→年度方案20美元)。新增Business/Enterprise的Codex-only pay-as-you-go seats。 | 79 | |
| 2026-04-01 | Guide v2.17 | 更新至CLI v0.118.0:Windows proxy-only sandbox networking(OS-level egress)、ChatGPT device-code auth flow、codex exec prompt-plus-stdin、custom providers的dynamic bearer token refresh。首次建立時保護.codex檔案。Linux bwrap PATH discovery修正。TUI app-server regressions修正(hook replay、/copy、/resume <name>、/agent、skills picker scrolling)。MCP startup robustness(更長startup window、warning display)。Windows apply_patch ACL修正。新增GPT-5.4 mini至model table(400K context、30% GPT-5.4 quota、速度快2倍)。新增Codex Security section(research preview、context-aware vulnerability detection)。 |
78 76 77 |
| 2026-03-31 | CLI 0.118.0 | 透過OS-level egress rules實作Windows proxy-only sandbox networking、app-server clients的ChatGPT device-code auth flow、codex exec prompt-plus-stdin workflow(piped input+separate prompt)、custom model providers的dynamic bearer token fetch/refresh。修正:首次建立時的.codex檔案保護、Linux bwrap PATH discovery、TUI app-server regressions(hook notification replay、/copy、/resume <name>、/agent threads、skills picker scrolling)、MCP startup robustness(更長startup window、failure warnings)、Windows apply_patch redundant writable-root ACL churn。 |
78 |
| 2026-03-17 | – | GPT-5.4 mini發布:400K context、每MTok 0.75/4.50美元、30% GPT-5.4 quota、速度快2倍。可用於Codex app、CLI、IDE extension與web。適合subagent/parallel subtask delegation。 | 76 |
| 2026-03-06 | – | Codex Security research preview:透過Codex web為Pro/Enterprise/Business/Edu提供context-aware application security review。已掃描120萬個commits、10,561個high-severity findings,並在OpenSSH/GnuTLS/Chromium中指派14個CVEs。 | 77 |
| 2026-03-30 | Guide v2.16 | 更新至CLI v0.117.0:first-class plugins(啟動時product-scoped sync、/pluginsbrowser、install/remove)、sub-agents v2(path-based addresses、structured inter-agent messaging、agent listing)、/title terminal-title picker、app-server TUI預設啟用(! shell commands、filesystem watch、具bearer auth的remote WebSocket、跨sessions的prompt history recall)、image workflow improvements(view_image傳回URLs、generated images可重新開啟、history在resume後保留)、移除legacy artifact tool(read_file與grep_files退役)、舊版distros的Linux sandbox improvements、Windows restricted-token sandbox improvements。 |
75 |
| 2026-03-28 | CLI 0.117.0 | First-class plugins,啟動時進行product-scoped sync,並提供/plugins TUI browser。Sub-agents v2:path-based addresses(/root/agent_a)、structured inter-agent messaging、agent listing。TUI與app-server TUI中的/title terminal-title picker。App-server clients:! shell commands、filesystem watch、具bearer auth的remote WebSocket。Image workflows:view_image傳回URLs、generated images可重新開啟、history在resume後保留。App-server TUI跨sessions召回prompt history。App-server TUI預設啟用。Legacy artifact tool已移除;舊read_file與grep_files退役。舊版distros的Linux sandbox improvements。Windows restricted-token sandbox improvements。 |
75 |
| 2026-03-21 | Guide v2.15 | 更新至CLI v0.116.0:UserPromptSubmit hook event(共5個)、app-server TUI中的ChatGPT device-code auth、更順暢的plugin installation並具suggestion allowlist與remote sync、realtime sessions會帶入recent thread context、減少audio self-interruptions。修正:WebSocket first-turn delays、remote resume/fork的conversation history、symlinked checkouts/AppArmor上的Linux sandbox、agent job finalization race condition。 |
74 |
| 2026-03-19 | CLI 0.116.0 | UserPromptSubmit hook(執行前block/augment prompts)、TUI中的ChatGPT device-code auth、具allowlist/remote sync的更順暢plugin setup、帶有recent thread context的realtime sessions、減少audio self-interruptions。修正:WebSocket prewarm first-turn hangs、remote resume/fork的conversation history、symlinked checkouts/AppArmor上的Linux sandbox startup、agent job finalization race。合併77個PRs。 |
74 |
| 2026-03-18 | Guide v2.14 | 更新至CLI v0.115.0:透過view_image與codex.emitImage進行full-resolution image inspection、js_repl公開codex.cwd/codex.homeDir、realtime WebSocket transcription mode、app-server v2 filesystem RPCs、Smart Approvals with guardian subagent(approvals_reviewer = "guardian_subagent")、Responses API tool-search。Bug fixes:subagent sandbox inheritance、js_repl U+2028/U+2029 hang、TUI exit stalls、使用codex exec --profile時保留profile settings、MCP/elicitation improvements、HTTP/1 CONNECT proxy。 |
73 |
| 2026-03-16 | CLI 0.115.0 | 透過view_image與codex.emitImage(..., detail: "original")進行full-resolution image inspection,js_repl公開codex.cwd與codex.homeDir並支援persistent tool references,realtime WebSocket sessions支援transcription mode與v2 handoff,app-server v2 filesystem RPCs(reads/writes/copies/directory ops/path watching),Smart Approvals透過guardian subagent路由,app integrations使用Responses API tool-search並提供fallback。修正:spawned subagents更可靠地繼承sandbox/network rules、js_repl不再因U+2028/U+2029卡住、TUI exit stalls已解決、使用codex exec --profile時保留profile settings、MCP/elicitation flows改善、local network proxy以HTTP/1提供CONNECT。 |
73 |
| 2026-03-13 | Guide v2.13 | App v26.312:可自訂themes(color+font)、改版Automations,支援local/worktree execution與per-run reasoning levels。新增winget installation method。新增GPT-5.1 deprecation note(3月11日——自ChatGPT移除,auto-migrated至GPT-5.3/5.4)。 | 71 72 |
| 2026-03-12 | App v26.312 | Settings中提供可自訂themes,包含color controls與font selection;改版Automations interface,支援local或worktree execution mode與custom reasoning levels;performance improvements。 | 72 |
| 2026-03-11 | Guide v2.12 | 更新至CLI v0.114.0:experimental hooks engine(SessionStart、Stop events)、experimental code mode、health check endpoints、disable system skills config、handoff transcript context、增強的$ mention picker。更新Hooks section,加入4個events。修正Windows Desktop App section(現已推出)。更新Quick Reference Card models至2026年3月。 | 70 |
| 2026-03-11 | CLI 0.114.0 | 用於隔離coding workflows的experimental code mode、具SessionStart與Stop events的experimental hooks engine、WebSocket app-server health check endpoints(/readyz、/healthz)、停用bundled system skills的config switch、handoffs會攜帶realtime transcript context、增強的$ mention picker並具skill/app/plugin labels。Bug fixes:Linux tmux crash、重新開啟的threads卡在mid-run、legacy permission handling、approval flow persistence。 | 70 |
| 2026-03-10 | Guide v2.11 | 更新至CLI v0.113.0:@plugin mentions(v0.112.0)、request_permissions tool、permission-profile config language、plugin marketplace expansion(v0.113.0)。新增@plugin Mentions、Plugin Marketplace、Runtime Permission Requests與Permission-Profile Config Language sections。 | 68 69 |
| 2026-03-10 | CLI 0.113.0 | 內建request_permissions tool供runtime permission requests使用、plugin marketplace discovery支援更豐富metadata/install-time auth checks/uninstall endpoint、app-server streaming stdin/stdout/stderr並支援TTY/PTY、permission-profile config language具拆分的filesystem/network sandbox policies、image generation會儲存至CWD、web search settings支援完整tool config、強化network proxy policy以拒絕global wildcard domains | 69 |
| 2026-03-08 | CLI 0.112.0 | @plugin mentions可在chat中參照plugins並自動包含context、TUI picker的新model-selection surface、executable permission profiles會合併至per-turn sandbox policy以供zsh-fork skill execution、JS REPL state handling fix(bindings在failed cells後仍保留)、SIGTERM對app-server websocket shutdown的處理同Ctrl-C、Linux bubblewrap一律unshares user namespace、macOS sandbox network/unix-socket handling improvements | 68 |
| 2026-03-06 | Guide v2.10 | 更新至CLI v0.111.0:GPT-5.4作為recommended model(1M context)、fast mode預設、plugin system(v0.110.0)、js_repl dynamic imports、persistent /fast toggle、Windows installer。Codex App for Windows(v26.304)。透過Cerebras partnership提供GPT-5.3-Codex-Spark。更新model table、flowchart、profiles。新增Plugins section。 | 64 65 66 67 |
| 2026-03-05 | CLI 0.111.0 | Fast mode預設、js_repl可對local files進行dynamic imports、session start時plugin discovery、image workflow support、thread resumption會保留git context | 65 |
| 2026-03-05 | – | GPT-5.4發布:旗艦frontier model、1M context、native computer use,可用於所有Codex surfaces | 64 |
| 2026-03-05 | CLI 0.110.0 | 用於skills/MCP/app connectors的Plugin system、multi-agent approval prompts、persistent /fast toggle、workspace-scoped memory writes、Windows installer script | 65 |
| 2026-03-04 | App v26.304 | Codex App for Windows:native PowerShell support、native sandbox、不需WSL即可使用skills/automations/worktrees | 66 |
| 2026-03-03 | App v26.303 | Worktree auto-cleanup toggle、Local-to-Worktree handoff support、明確的English language option | 66 |
| 2026-03-02 | Guide v2.9 | 更新至CLI v0.107.0:thread forking into sub-agents、realtime voice device selection、可設定memories並支援codex debug clear-memories、multimodal custom tool output。新增App v26.226:composer中的MCP shortcuts、review comments中的@mentions。 |
62 63 |
| 2026-03-02 | CLI 0.107.0 | Thread forking into sub-agents、realtime voice sessions支援microphone/speaker device selection、custom tools multimodal output、可設定memories+codex debug clear-memories、bug fixes |
62 |
| 2026-02-28 | Guide v2.8 | 更新至CLI v0.106.0:新增direct install script、zsh-fork sandbox bypass fix、約1M char input cap、Linux /dev filesystem、彈性的approval controls、JS REPL升級至/experimental(Node 22.22.0+)、diff-based memory forgetting、TUI syntax highlighting+/theme、/copy、/clear、Ctrl-L、voice transcription、Default mode中的spawn_agents_on_csv、request_user_input。新增v0.105.0與v0.106.0 changelog entries。 | 60 61 |
| 2026-02-26 | CLI 0.106.0 | Direct install script、js_repl升級至/experimental且最低需求Node 22.22.0、Default mode中的request_user_input、API users可在CLI model list看到5.3-codex、具usage-aware selection的diff-based memory forgetting、zsh-fork sandbox bypass fix、約1M char input cap、改進TUI file-link rendering、sub-agents的Ctrl-C handling fix | 60 |
| 2026-02-25 | CLI 0.105.0 | TUI會以syntax-highlights呈現fenced code blocks與diffs並提供/theme picker、voice transcription(spacebar dictation,experimental)、spawn_agents_on_csv可用於multi-agent fanout並顯示progress/ETA、/copy /clear Ctrl-L commands、彈性的approval controls(extra sandbox permissions、granular rejection)、clickable wrapped links、sandboxed commands可使用Linux /dev filesystem、js_repl error reporting improvements | 61 |
| 2026-02-24 | Guide v2.7 | 擴充Access/Pricing section:新增Free/Go promotional tier、paid plans的2倍rate limits、per-plan usage limits(5-hour window)、credit costs table。新增allow_login_shell config key。 |
51 |
| 2026-02-22 | Guide v2.6 | 新增缺漏config keys:features.multi_agent、features.apply_patch_freeform、features.search_tool、agents.*(multi-agent roles)、model_context_window、model_auto_compact_token_limit、mcp_oauth_callback_port、mcp_oauth_credentials_store、notify。新增App v26.217 changelog entry。 |
50 |
| 2026-02-19 | Guide v2.5 | 更新version references至CLI 0.104.0、新增v0.103.0與v0.104.0 changelog entries、新增WS_PROXY/WSS_PROXY proxy support、distinct approval IDs、commit co-author attribution,並以command_attribution取代已移除的remote_models feature flag。 |
— |
| 2026-02-18 | CLI 0.104.0 | WS_PROXY/WSS_PROXY WebSocket proxy support、multi-step commands的distinct approval IDs、thread archive/unarchive notifications | 49 |
| 2026-02-17 | App v26.217 | 拖放以重新排序queued messages、model downgrade warning、改進fuzzy file search並在restart後提供attachment recovery | 50 |
| 2026-02-17 | CLI 0.103.0 | 透過prepare-commit-msg hook提供commit co-author attribution(可透過command_attribution設定)、更豐富的app listing metadata/branding、移除remote_models feature flag |
48 |
| 2026-02-17 | Guide v2.4 | 更新所有CLI 0.102.0的version references、新增v0.102.0 changelog entry與footnote、更新sub-agents note並加入可設定multi-agent roles。 | — |
| 2026-02-17 | CLI 0.102.0 | Unified permissions flow、structured network approvals、可自訂multi-agent roles、model reroute notifications、js_repl stability fixes | 47 |
| 2026-02-16 | Guide v2.3 | 修正migration table:hooks現在已存在(v0.99.0+)、承認subagents(最多6個)、model list完整。新增專屬Hooks section(AfterAgent、AfterToolUse、migration patterns)。修正Recipe 5 phantom commands(cloud start→cloud exec、cloud pull→apply)。修正codex auth→codex login。Windows sandbox從Experimental升級。Linux Bubblewrap現在為vendored/built-in。新增minimal reasoning effort level。擴充memory section(v0.101.0 refinements、memory vs AGENTS.md)。更新AGENTS.md adopter list(60,000+ projects、Linux Foundation governance)。更新Copilot migration table。修正[EXPERIMENTAL]大小寫一致性。新增ReadOnlyAccess policy documentation、JS REPL Runtime section、production Deploy skill example、擴充cost section(hidden token overhead、team cost management)。標記20個未標記code blocks。驗證全部30個ToC anchors。Post-evaluation fixes:/permissions terminology修正(approval mode→approval policy)、duplicate “Project Trust” header重新命名、chat/completions deprecation language改為保守表述、OpenTelemetry section擴充並加入config example、migration「harder to escape」措辭改得更精確。 |
Deliberation audit |
| 2026-02-16 | Guide v2.2 | 在changelog新增19個歷史CLI milestone releases(v0.2.0–v0.91.0)。以20個individual release footnotes(35–59)取代bulk 24 citation。新增59 Apache 2.0 license citation。新增5 citation至codex-linux-sandbox reference。新增21 citation至MDM preference domain。更新6 Seatbelt note關於bot-blocking。新增關於無法驗證OpenAI blog URLs的note。Footnotes總數:56(原36)。 | Deliberation audit |
| 2026-02-15 | Guide v2.1 | Enterprise section修正(managed-admin-config.toml→requirements.toml並使用已驗證TOML keys)、272K context限定為input window並附citation、6 Seatbelt citation URL已新增、Key Takeaways block已新增、style violations已修正、meta description已縮短、AGENTS.md adopter list已擴充。 | Blog evaluator audit |
| 2026-02-14 | Guide v2 | Major revision:Codex-verified corrections to models(272K context)、config keys、feature flags、pricing、enterprise config、CI/CD action、SDK API、MCP options、codex exec flags、desktop app features、migration comparisons。移除無法驗證的claims。 | Self-review |
| 2026-02-12 | CLI 0.101.0 | Model resolution improvements、memory refinements、stability | 35 |
| 2026-02-12 | CLI 0.100.0 | Experimental JS REPL、multiple rate limits、WebSocket transport、memory commands、enhanced sandbox | 36 |
| 2026-02-12 | App v260212 | Conversation forking、floating pop-out window、Windows alpha | 17 |
| 2026-02-12 | – | GPT-5.3-Codex-Spark發布(較低延遲的interactive variant) | 25 |
| 2026-02-11 | CLI 0.99.0 | Concurrent shell commands、/statusline、sortable resume picker、GIF/WebP support、shell snapshotting |
37 |
| 2026-02-06 | CLI 0.98.0 | GPT-5.3-Codex support、steer mode穩定且預設啟用、model switching fixes | 38 |
| 2026-02-06 | CLI 0.97.0 | 「Allow and remember」MCP approvals、live skill detection、/config diagnostics、memory plumbing |
39 |
| 2026-02-06 | CLI 0.96.0 | Async thread/compact v2、WebSocket rate limits、unified_exec non-Windows、config provenance | 40 |
| 2026-02-06 | CLI 0.95.0 | codex app command、personal skills、parallel shell tools、git hardening |
41 |
| 2026-02-05 | – | GPT-5.3-Codex發布——unified model、速度快25%、end-to-end computer operation | 26 |
| 2026-02-02 | – | Codex Desktop App發布(macOS)——multi-tasking、worktrees、automations | 16 |
| 2026-01-30 | CLI 0.94.0 | Plan mode預設、personality穩定、來自.agents/skills的skills、runtime metrics |
42 |
| 2026-01-29 | CLI 0.93.0 | SOCKS5 proxy、plan mode streaming、/apps、smart approvals預設啟用、SQLite logs |
43 |
| 2026-01-29 | CLI 0.92.0 | API v2 threads、thread filtering、MCP OAuth scopes、multi-agent collaboration | 44 |
| 2026-01-25 | CLI 0.91.0 | 將max sub-agents從12降至6,以提供更嚴格的resource guardrails | 45 |
| 2026-01-21 | CLI 0.88.0 | Device-code auth fallback、collaboration modes、/fork、remote models、model_personality config |
46 |
| 2026-01-06 | CLI 0.78.0 | Ctrl+G external editor、project-aware config layering、macOS MDM config、TUI2 transcript nav、.dmg installers |
52 |
| 2025-12-18 | – | GPT-5.2-Codex發布——context compaction、refactors/migrations、cybersecurity | 27 |
| 2025-12-09 | CLI 0.66.0 | Exec policy system(TUI whitelisting、sandbox denial amendments)、CRLF preservation、Linux Sigstore signing | 53 |
| 2025-11-19 | – | GPT-5.1-Codex-Max——multi-window compaction、Windows training、thinking tokens減少30% | 28 |
| 2025-11-19 | CLI 0.59.0 | Native compaction、tool output limit提高至10K tokens、Windows Agent mode sandbox、/status中的credits |
54 |
| 2025-10-25 | CLI 0.50.0 | /feedback diagnostics、sandbox violation risk assessment、MCP startup improvements、env var redaction |
55 |
| 2025-10-06 | – | Codex於DevDay GA——Slack integration、SDK、admin tools | 29 |
| 2025-10-06 | CLI 0.45.0 | Breaking:codex login --api-key→--with-api-key(stdin)。OAuth MCP auth、parallel tool calls、pulsing dot UI |
56 |
| 2025-09-23 | – | GPT-5-Codex+IDE extension+CLI revamp——images、web search、code review | 30 |
| 2025-09-23 | CLI 0.40.0 | Default model→gpt-5-codex、220K tokens時auto-compaction、/review commands、git undo、Windows binary support |
57 |
| 2025-06-30 | CLI 0.2.0 | 首個Rust binary release——提供macOS(aarch64/x86_64)與Linux(gnu/musl)的pre-built binaries、codex-exec與codex-linux-sandbox tools |
58 |
| 2025-06 | – | Rust rewrite宣布(「Codex CLI is Going Native」) | 31 |
| 2025-06-03 | – | Plus user expansion、cloud的internet access、PR updates、voice dictation | 32 |
| 2025-05-16 | – | Codex Cloud發布——使用codex-1 model的cloud agent、GitHub PR creation | 33 |
| 2025-04-16 | – | Codex CLI open-source launch(Apache 2.0、TypeScript、codex-mini-latest)59 | 1 |
參考資料
OpenAI blog URLs注意事項:參考資料16、25–30、33、64、66、67、76與77連到
openai.com/index/blog posts,這些頁面因Cloudflare bot protection,會對自動化存取回傳HTTP 403。使用標準網頁瀏覽器存取時,這些URLs是有效的。
-
GitHub — openai/codex — 開放原始碼儲存庫、版本發布與討論。 ↩↩↩
-
Codex CLI Windows支援 — Windows安裝與WSL指南。 ↩
-
Codex IDE Extension — VS Code、Cursor與Windsurf整合。 ↩
-
Codex Cloud — Cloud工作文件與網際網路存取控制。 ↩↩
-
Codex Security — Sandbox架構與安全模型。 ↩↩↩
-
macOS Seatbelt Sandbox — Apple sandbox-exec框架的社群文件(Apple未發布官方開發者文件)。注意:此wiki可能會阻擋自動化存取(HTTP 403);另可參閱macOS上的
man sandbox-exec。 ↩↩↩ -
Linux Landlock LSM — 核心檔案系統存取控制。 ↩
-
Breaking Out of the Sandbox — 社群sandbox設定模式。 ↩
-
AGENTS.md Open Standard — Linux Foundation旗下的跨工具指令標準。 ↩
-
Custom Instructions with AGENTS.md — 官方指南。 ↩
-
Codex MCP整合 — MCP伺服器設定與管理。 ↩
-
Building Workflows with Agents SDK — 將Codex作為MCP伺服器,用於多agent編排。 ↩
-
Agent Skills — skills系統文件。 ↩
-
Codex CLI功能 — Plan模式、steer模式與協作功能。 ↩↩
-
Non-Interactive Mode —
codex exec文件。 ↩ -
Introducing the Codex App — Desktop app發布公告。 ↩↩↩
-
Codex App Documentation — Desktop app功能與疑難排解。 ↩
-
Codex GitHub Action — CI/CD整合。 ↩
-
Codex Pricing — 訂閱與API定價。 ↩
-
Codex Configuration Reference — Enterprise requirements.toml結構描述與MDM散發。 ↩↩↩
-
Best Practices for Using Codex — 社群論壇討論串。 ↩
-
feiskyer/codex-settings — 社群維護的設定、skills與prompts。 ↩
-
Codex CLI版本發布 — GitHub版本說明。 ↩↩
-
Introducing GPT-5.3-Codex-Spark — Cerebras合作關係,1000+ tok/s。 ↩↩
-
Introducing GPT-5.3-Codex — 統一模型發布。 ↩
-
Introducing GPT-5.2-Codex — Context compaction與大規模變更。 ↩
-
Building More with GPT-5.1-Codex-Max — 多視窗compaction。 ↩
-
Codex is Now Generally Available — DevDay 2025公告。 ↩
-
Introducing Upgrades to Codex — GPT-5-Codex + IDE extension。 ↩↩
-
Codex CLI邁向Native — Rust重寫討論。 ↩
-
Codex Updates: Internet Access and Plus Rollout — 2025年6月擴展。 ↩
-
Introducing Codex — Cloud agent發布。 ↩↩
-
Deprecating chat/completions support in Codex — OpenAI宣布移除Codex的chat/completions API,已於2026年2月完成。 ↩
-
Codex CLI v0.101.0 — 模型解析改進、memory精煉、穩定性。2026年2月12日。 ↩↩
-
Codex CLI v0.100.0 — 實驗性JS REPL、多重速率限制、WebSocket transport、memory commands、強化sandbox。2026年2月12日。 ↩
-
Codex CLI v0.99.0 — 並行shell commands、
/statusline、可排序的resume picker、GIF/WebP支援、shell snapshotting。2026年2月11日。 ↩↩ -
Codex CLI v0.98.0 — GPT-5.3-Codex支援、steer模式穩定並成為預設、模型切換修正。2026年2月6日。 ↩
-
Codex CLI v0.97.0 —「Allow and remember」MCP核准、即時skill偵測、
/config診斷、memory plumbing。2026年2月6日。 ↩ -
Codex CLI v0.96.0 — Async thread/compact v2、WebSocket速率限制、非Windows的unified_exec、設定來源追溯。2026年2月6日。 ↩
-
Codex CLI v0.95.0 —
codex appcommand、personal skills、parallel shell tools、git強化。2026年2月6日。 ↩ -
Codex CLI v0.94.0 — Plan模式預設、personality穩定、來自
.agents/skills的skills、runtime metrics。2026年1月30日。 ↩ -
Codex CLI v0.93.0 — SOCKS5 proxy、plan模式串流、
/apps、smart approvals預設、SQLite logs。2026年1月29日。 ↩ -
Codex CLI v0.92.0 — API v2 threads、thread filtering、MCP OAuth scopes、多agent協作。2026年1月29日。 ↩
-
Codex CLI v0.91.0 — 將max sub-agents從12降至6,以建立更嚴謹的資源防護。2026年1月25日。 ↩
-
Codex CLI v0.88.0 — Device-code auth fallback、collaboration modes、
/fork、remote models、model_personality設定。2026年1月21日。 ↩ -
Codex CLI v0.102.0 — 統一permissions流程、結構化network approvals、可自訂multi-agent roles、model reroute通知。2026年2月17日。 ↩↩
-
Codex CLI v0.103.0 — 透過prepare-commit-msg hook標註commit co-author attribution、更豐富的app listing metadata/branding、移除
remote_modelsfeature flag。2026年2月17日。 ↩ -
Codex CLI v0.104.0 — WS_PROXY/WSS_PROXY WebSocket proxy支援、commands使用不同approval IDs、thread archive/unarchive通知。2026年2月18日。 ↩↩↩
-
Codex Changelog — Codex App v26.217:拖放重新排序、模型降級警告、模糊檔案搜尋改進。Codex Config Reference — 完整設定鍵參考。2026年2月。 ↩↩
-
Codex Pricing — 方案級距、每5小時視窗用量限制、credit成本,以及Free/Go促銷存取。2026年2月。 ↩
-
Codex CLI v0.78.0 —
Ctrl+G外部編輯器、專案感知設定分層、macOS MDM設定、TUI2 transcript nav、.dmg安裝程式。2026年1月6日。 ↩ -
Codex CLI v0.66.0 — Exec policy系統、Windows上的CRLF保留、cloud exec
--branch、Linux Sigstore簽章。2025年12月9日。 ↩ -
Codex CLI v0.59.0 — 原生compaction、tool output limit提升至10K tokens、Windows Agent mode sandbox、
/status中的credits。2025年11月19日。 ↩ -
Codex CLI v0.50.0 —
/feedback診斷、sandbox violation風險評估、MCP啟動改進、env var遮蔽。2025年10月25日。 ↩↩ -
Codex CLI v0.45.0 — 破壞性變更:
codex login --api-key→--with-api-key(stdin)。OAuth MCP auth、parallel tool calls。2025年10月6日。 ↩ -
Codex CLI v0.40.0 — 預設模型→
gpt-5-codex、220K tokens自動compaction、/reviewcommands、git undo、Windows binary。2025年9月23日。 ↩ -
Codex CLI v0.2.0 — 第一個Rust binary版本。macOS(aarch64/x86_64)與Linux(gnu/musl)預建binaries、
codex-exec與codex-linux-sandboxtools。2025年6月30日。 ↩ -
GitHub — openai/codex LICENSE — Apache License 2.0。原始開放原始碼發布為2025年4月。 ↩↩↩
-
Codex CLI v0.106.0 — 直接安裝script、js_repl升級為/experimental(Node 22.22.0+)、Default模式中的request_user_input、diff-based memory forgetting、zsh-fork sandbox bypass修正、約1M字元輸入上限、Ctrl-C sub-agent修正。2026年2月26日。 ↩↩↩↩↩↩↩↩↩↩
-
Codex CLI v0.105.0 — TUI syntax highlighting with /theme、voice transcription、spawn_agents_on_csv、/copy /clear Ctrl-L、彈性approval controls、Linux /dev filesystem、js_repl error recovery。2026年2月25日。 ↩↩↩↩↩↩↩↩↩
-
Codex CLI v0.107.0 — Thread forking into sub-agents、realtime voice device selection、custom tools multimodal output、可透過
codex debug clear-memories設定的memories。2026年3月2日。 ↩↩↩↩↩↩ -
Codex Changelog — App v26.226 — composer中的MCP shortcuts、review comments中的@mentions、Mermaid diagram錯誤處理。2026年2月26日。 ↩↩↩
-
Introducing GPT-5.4 — 旗艦frontier model,結合GPT-5.3-Codex coding、更強reasoning、原生computer use與1M context windows。2026年3月5日。 ↩↩↩↩↩
-
Codex CLI v0.110.0–v0.111.0 — skills/MCP/app connectors的plugin system(v0.110.0)、fast mode預設、js_repl dynamic imports、session start時plugin discovery(v0.111.0)。2026年3月5日。 ↩↩↩↩↩
-
Codex App for Windows — 原生Windows app,支援PowerShell、native sandbox、skills/automations/worktrees。App v26.304(2026年3月4日)、v26.303(2026年3月3日)。 ↩↩↩↩↩↩
-
Introducing GPT-5.2-Codex — GPT-5.3-Codex-Spark:text-only research preview model,針對近乎即時的coding iteration最佳化。透過Cerebras合作提供給ChatGPT Pro使用者。128K context。 ↩↩↩
-
Codex CLI v0.112.0 — @plugin mentions並自動納入context、TUI model-selection surface、per-turn sandbox policy中的executable permission profiles、JS REPL state fix、SIGTERM handling、Linux bubblewrap user namespace、macOS sandbox改進。2026年3月8日。 ↩↩↩
-
Codex CLI v0.113.0 — 內建request_permissions tool、plugin marketplace擴展(metadata、auth checks、uninstall)、含TTY/PTY的app-server streaming、permission-profile config language、image generation儲存至CWD、web search tool settings、強化network proxy policy。2026年3月10日。 ↩↩↩↩
-
Codex CLI v0.114.0 — 實驗性code mode、實驗性hooks engine(SessionStart、Stop events)、WebSocket health check endpoints、停用system skills config、handoff transcript context、強化$ mention picker。2026年3月11日。 ↩↩↩↩
-
OpenAI Developer Changelog — 2026年3月11日 — GPT-5.1模型已從ChatGPT移除;既有對話會在GPT-5.3 Instant、GPT-5.4 Thinking或GPT-5.4 Pro上自動延續。 ↩↩
-
Codex Changelog — App v26.312 — 可自訂themes,具備色彩控制與字型選擇;重新設計的Automations介面,支援local/worktree execution與custom reasoning levels;效能改進。2026年3月12日。 ↩↩↩↩
-
Codex CLI v0.115.0 — 透過
view_image與codex.emitImage進行全解析度圖片檢查、js_repl公開codex.cwd/codex.homeDir、realtime WebSocket transcription mode、app-server v2 filesystem RPCs、具guardian subagent的Smart Approvals、Responses API tool-search。修正:subagent sandbox inheritance、js_repl U+2028/U+2029 hang、TUI exit stalls、profile settings preservation、MCP/elicitation改進。2026年3月16日。 ↩↩↩ -
Codex CLI v0.116.0 —
UserPromptSubmithook event、app-server TUI中的ChatGPT device-code auth、透過suggestion allowlist與remote sync讓plugin installation更順暢、含recent thread context的realtime sessions、減少audio self-interruptions。修正:WebSocket prewarm first-turn hangs、remote resume/fork的conversation history、symlinked checkouts/AppArmor上的Linux sandbox、agent job finalization race。合併77個PR。2026年3月19日。 ↩↩ -
Codex CLI v0.117.0 — First-class plugins(product-scoped sync、
/pluginsbrowser、install/remove)、sub-agents v2(path-based addresses、structured messaging、agent listing)、/titleterminal-title picker、app-server TUI預設啟用並支援!shell commands/filesystem watch/remote WebSocket bearer auth/prompt history recall、image workflows(view_imageURLs、可重新開啟的generated images、resume-surviving history)、移除legacy artifact/read_file/grep_files tools、改善舊版distros上的Linux sandbox、Windows restricted-token sandbox改進。2026年3月28日。 ↩↩↩↩↩↩↩↩↩↩↩↩↩ -
Introducing GPT-5.4 mini and nano — GPT-5.4 mini:400K context、每MTok $0.75/$4.50、GPT-5.4配額的30%、速度快2倍。可在Codex app、CLI、IDE extension與web使用。2026年3月17日。 ↩↩↩↩↩
-
Codex Security: now in research preview — Context-aware application security review。透過Codex web提供給Pro/Enterprise/Business/Edu。已掃描120萬次commits,發現10,561項high-severity findings,分配14個CVEs。2026年3月6日。 ↩↩↩↩↩
-
Codex CLI v0.118.0 — Windows proxy-only sandbox networking、ChatGPT device-code auth、
codex execprompt-plus-stdin、dynamic bearer tokens、.codex檔案保護、Linux bwrap修正、TUI app-server regressions、MCP startup robustness、Windows apply_patch修正。2026年3月31日。 ↩↩ -
Codex now offers pay-as-you-go pricing for teams。OpenAI,2026年4月2日。Business年度定價降至$20/seat/mo。Business與Enterprise可使用Codex-only seats,採token-based billing,無固定seat fee,無速率限制。 ↩
-
Codex CLI v0.119.0。「v0.119.0:Realtime voice V2(WebRTC、可設定transport、voice selection、native TUI media)、MCP Apps(resource reads、tool-call metadata、elicitations、file uploads)、remote workflows(egress websocket、
--cdforwarding、codex exec-server)、Ctrl+Ocopy response、依ID/name使用/resume、Warp OSC 9 notifications。」2026年4月10日。 ↩ -
Codex CLI v0.120.0。「v0.120.0:Realtime V2串流background agent progress、hook activity UI improvements、SessionStart hooks可區分
/clear、code mode中的MCPoutputSchema、Windows sandbox symlink handling、tool search ordering fix。」2026年4月11日。 ↩ -
Codex CLI v0.121.0。2026年4月15日。Plugin Marketplace(
codex marketplace add支援GitHub、git URL、local dir、marketplace.jsonURL)與app-server counterpart(#17087、#17717、#17756)。TUI reverse history searchCtrl+R並支援slash-command recall(#17550、#17336)。TUI memories menu,具reset button與per-memory deletion(#17632、#17626、#17913、#17937、#17844)。Phase-2 memory consolidation model升級至GPT-5.4(#17384)。Memory reset保留past rollouts(#17919)。使用Bubblewrap的secure devcontainer profile(僅WSL2;拒絕WSL1)(#10431、#17547、#17559)。macOS sandbox:Unix socket allowlists(#17654)、private DNS解除封鎖(#17370)。移除danger-full-accessdenylist-only模式(#17732)。MCP Apps tool-call支援(#17364)、MCP tool namespaces(#17404)、supports_parallel_tool_callsflag plumbing(#17667)、透過MCP tool metadata提供sandbox-state metadata(#17763、#17957)、flattened deferred tool calls(#17556)。Guardian review停用hooks(#17872)。status line中的context-percent indicator(#17637、#17420)。CLI update announcement(#17942)。codex-thread-storeinterface(#17659、#17824)。Windowsresume --lastverbatim-path修正(#17414)。總計180+ commits。完整PR清單另請參閱rust-v0.120.0...rust-v0.121.0compare URL。 ↩↩↩↩↩↩↩↩↩↩↩↩ -
Introducing GPT-5.5。OpenAI公告,2026年4月23日。Context window:Codex中為400K,API中為1M(分別依OpenAI的GPT-5.5-in-Codex availability頁面與GPT-5.5 API model docs)。定價(API):每MTok輸入$5/輸出$30(GPT-5.4費率的2倍;OpenAI表示在token-efficiency improvements後,實際增幅約20%)。Benchmarks:82.7% Terminal-Bench 2.0(目前公開可用模型中的SOTA)、84.9% GDPval(44種職業)、78.7% OSWorld-Verified(真實電腦操作)、98.0% Tau2-bench Telecom(無prompt tuning)。2026年4月23日起,ChatGPT Plus/Pro/Business/Enterprise/Edu/Go可在Codex CLI/web/desktop使用;4月24日起在OpenAI API中可用。OpenAI的說法:「GPT-5.5 is now available in Codex as OpenAI’s newest frontier model for complex coding, computer use, knowledge work, and research workflows, and is the recommended choice for most Codex tasks.」另請參閱:Introducing upgrades to Codex(2026年4月17日 — background computer use、90+ new plugin partners,包括Atlassian Rovo、CircleCI、CodeRabbit、GitLab Issues、Microsoft Suite、Neon by Databricks、Remotion、Render與Superpowers);NVIDIA blog: GPT-5.5 Powers Codex on NVIDIA Infrastructure;TechCrunch: OpenAI releases GPT-5.5。 ↩↩↩↩↩↩
-
Codex CLI v0.122.0與v0.123.0。v0.122.0:filesystem deny-read glob policies + managed deny-read requirements + platform sandbox enforcement + 隔離的
codex execruns,會忽略user config或rules;tool discovery與image generation預設啟用;MCP與js_repl的higher-detail image handling與original-detail metadata;跨clients的app-server stale-prompt resolution;resumed/forked threads會立即replay token usage;remote-control startup可容忍缺少ChatGPT auth;MCP startup cancellation可再次透過app-server sessions運作;內部分拆為codex-core-plugins並重組connector。v0.123.0(2026年4月23日):內建amazon-bedrockmodel provider,支援可設定AWS profile;/mcp verbose提供完整MCP server diagnostics、resources與resource templates,同時維持一般/mcp快速;plugin MCP loading在.mcp.json中同時接受mcpServers與top-level server maps;realtime handoffs將transcript deltas傳遞給background agents並允許明確silent-stay;remote environments支援host-specificremote_sandbox_configrequirements;更新bundled model metadata。修正:rollback後/copy會複製最新可見assistant response(不是rollback前的內容)、manual shell command執行時提交的follow-up text會排入佇列(不再卡在Working狀態)、VS Code WSL terminals中的Unicode/dead-key input(已在該處停用enhanced keyboard mode)、stale proxy env vars不會從shell snapshots還原、codex exec繼承root-level shared flags如sandbox與model options、移除TUI transcripts中外洩的review prompts。 ↩↩↩ -
Codex CLI v0.124.0與v0.125.0。v0.124.0(2026年4月23日):TUI quick reasoning controls(
Alt+,降低、Alt+.提高),且model-upgrade reasoning會重設為新模型預設值;app-server sessions管理多個環境,遠端設定可在每回合選擇environment + working-directory;對OpenAI-compatible providers提供first-class Amazon Bedrock支援(AWS SigV4 signing、AWS credential auth);remote plugin marketplaces具備可靠detail lookups與更大的result pages;hooks現已穩定 — 可在config.toml與requirements.toml中inline設定,觀察MCP tools以及apply_patch和長時間執行的Bash sessions;符合資格的ChatGPT方案預設使用Fast service tier,除非明確選擇退出。修正:Cloudflare cookies會在已核准的ChatGPT hosts之間保留(降低auth-failure)、負載下的websocket event draining + 更乾淨的shutdown、permission-mode drift可在side conversations後保留、mailbox work排入佇列時wait_agent會立即返回、local stdio MCP若relative commands未明確使用cwd,會使用正確path resolution、startup managed-config邊界案例(未知feature requirements改為警告而非中止,cloud-requirement錯誤更清楚)。v0.125.0(2026年4月24日):app-server integrations支援Unix socket transport、pagination-friendly resume/fork、sticky environments、remote thread config/store plumbing;app-server plugin management可安裝remote plugins並升級configured marketplaces;permission profiles可跨TUI sessions、user turns、MCP sandbox state、shell escalation與app-server APIs往返保留;model providers負責model discovery,並將AWS/Bedrock account state公開給app clients;codex exec --json為programmatic consumers回報reasoning-token usage;rollout tracing記錄tool、code-mode、session與multi-agent關係,並提供debug reducer command。修正:/reviewinterrupt不再卡住TUI、exec-server output handling與stream closure改進、app-server尊重明確untrusted project config、notification bursts期間的websocket client disconnection issues、Windows sandbox startup與background process handling、針對thread limits、agent paths與MIME types強化config-schema validation。 ↩↩↩ -
Codex CLI v0.128.0。2026年4月30日發布。新增持久化
/goalworkflows、codex update、可設定TUI keymaps、擴充permission profiles、plugin marketplace改進、external agent session import與MultiAgentV2 configuration updates;修正resume/interruption、TUI、network、Windows sandbox、Bedrock、MCP與plugin邊界案例;棄用--full-auto;移除js_repl。 ↩↩↩↩↩↩ -
OpenAI Codex configuration reference與Codex sandbox configure defaults。存取日期:2026年5月11日。記錄
approval_policy、sandbox_mode、default_permissions、[permissions.<name>.filesystem]、[permissions.<name>.network]、內建permission profiles與on-failure棄用。 ↩↩↩↩↩↩ -
OpenAI API deprecations: 2026-04-22 legacy GPT model snapshots。存取日期:2026年5月5日。列出2026年7月23日將關閉的legacy Codex-related model snapshots,包括
gpt-5.2-codex與gpt-5.1-codex-mini,替代模型為gpt-5.4與gpt-5.4-mini。 ↩↩↩ -
Codex CLI v0.129.0。發布時間:2026年5月7日17:02 UTC。新增composer中的modal Vim editing(
/vimcommand、可設定default-mode)、重新設計的TUI workflow picker(更易resume/fork、raw scrollback mode)、TUI內建/hooksbrowser用於discovery與切換lifecycle hooks、theme-aware status line並可選擇PR + branch-change summaries、plugin management升級(workspace sharing、share access controls、source filtering、可從/plugins執行marketplace operations)、/goallifecycle變更(experimental goals在resume後會保持paused,除非選擇恢復 — 變更v0.128.0先前預設行為)、Linux sandbox startup hardening、Windows sandbox可靠性改進,以及vendored Bubblewrap升級至0.11.2並納入upstream security patches。另請參閱:Codex Changelog與Codex CLI page — 後者記錄2026年5月用量限制提升(Codex Plus 5小時限制提高25倍,$100/month級距加倍,兩者皆至2026年5月31日)。 ↩↩↩↩↩↩↩↩↩↩↩↩ -
Codex for Chrome與Codex Changelog中2026年5月7日條目。根據公告:「With the new extension for Chrome, Codex is even better at working with apps and websites in your browser. It works in parallel across tabs in the background without taking over your browser, and you stay in control of which websites Codex can use.」 ↩↩↩↩↩
-
Codex CLI v0.130.0。發布時間:2026年5月8日23:09 UTC。新功能:
codex remote-control頂層command,作為headless app-server entrypoint(#21424);plugin details顯示bundled hooks,plugin sharing公開link metadata + discoverability controls + share settings updates(#21447、#21495、#21637);app-server thread pagination,提供unloaded / summary / full turn item views(#21566);透過AWSaws loginconsole-login credentials進行Bedrock auth(#21623);多環境sessions中,view_image會透過選定環境解析(#21143)。錯誤修正:live app-server threads不需重新啟動即可取得config changes(#21187);turn diffs在apply_patchoperations之間保持準確,包含partial failures(#21180、#21518);透過ThreadStore處理thread summaries / renames / resume / fork,包含pathless threads(#21264、#21265、#21266);remote compaction會為v2 streams發出response.processed,且在API-key compact requests中省略service_tier(#21642、#21676);Windows sandbox setup授予sandbox users存取desktop runtime binary cache的權限(#21564);codex execstartup banner不再印出「research preview」字樣(#21683)。例行維護:可設定OpenTelemetry trace metadata + 更豐富review/feedback analytics(#21556、#18747、#21434、#21498);Cargo profiling build profile、Dependabot cooldown、cargo-shearupgrade、完全限定的GitHub Action pins(#21436、#21547、#21574、#21584、#21599);移除未使用的device-key APIs / extra skills roots / remote thread-store impl / string-keyed MCP tool maps(#21487、#21485、#21596、#21454)。Compare URL:rust-v0.129.0...rust-v0.130.0。另請參閱:Codex Changelog。 ↩↩↩↩↩↩↩↩↩↩↩↩↩↩ -
Codex Changelog。2026年5月5日條目 — GPT-5.5 Instant已推出至免費級距;v0.131.0 alpha線自2026年5月9日起進行中 — 屬於pre-release builds,尚未升格為stable。 ↩↩
-
Build plugins — 從CLI新增marketplace。存取日期:2026年5月11日。記錄
codex plugin marketplace add、可接受的marketplace source types、--ref、--sparse與marketplace upgrade/remove commands。 ↩ -
Codex CLI v0.131.0-alpha.9。2026年5月12日發布。Prerelease alpha線,不是stable guide target。 ↩↩
-
作者於2026年5月15日執行的已清理本機Codex-harness hygiene audit。該次檢查將executable source、public/private docs、generated caches、session records、shell snapshots、logs與intentional secret stores分離;在適當處將helper credentials轉為需要環境變數的設定;針對高可信度secret形態遮蔽model-visible history;並記錄剩餘prevention-hook與forensic-history缺口。精確paths、token values、detector patterns與private workflow internals均刻意省略。 ↩↩↩