告別Claude代碼降智!OpenAI Codex深度配置與避坑指南(附完整AGENTS.md) 原創(chuàng)
最近Claude code降智嚴(yán)重,Codex強(qiáng)勢(shì)崛起,群里一些人還不太會(huì)用。本文將帶你從零開始掌握 OpenAI Codex,涵蓋配置、命令、工具調(diào)用、實(shí)戰(zhàn)技巧等各個(gè)方面。
基礎(chǔ)配置 config.toml
工欲善其事,必先利其器。強(qiáng)烈建議先閱讀官方配置文檔 ??config.md?? 了解各項(xiàng)配置的詳細(xì)作用。
在 ??~/.codex/config.toml?? 文件中進(jìn)行基礎(chǔ)配置:
# 模型配置
model = "gpt-5-codex" # Codex 0.36.0+ 支持
model_reasoning_effort = "high" # 使用最大推理能力
model_reasoning_summary = "detailed" # 終端顯示詳細(xì)推理總結(jié) (Ctrl+T查看)
model_verbosity = "high" # 高詳細(xì)度輸出
model_supports_reasoning_summaries = true # 強(qiáng)制啟用推理總結(jié)
# 代理配置
hide_agent_reasoning = false # 顯示 Agent 內(nèi)部思考過程
# 隱私配置
disable_response_storage = true # 禁止 OpenAI 存儲(chǔ)對(duì)話數(shù)據(jù)
# 權(quán)限配置 (建議通過 /approvals 命令配置)
approval_policy = "never"
sandbox_mode = "workspace-write"
# 網(wǎng)絡(luò)訪問配置
[sandbox_workspace_write]
network_access = true # 允許網(wǎng)絡(luò)訪問配置項(xiàng)詳解
- ?
?model_reasoning_effort???: 控制模型推理深度,??high?? 提供最佳效果 - ?
?model_reasoning_summary???: 推理總結(jié)詳細(xì)程度,??detailed?? 提供完整信息 - ?
?hide_agent_reasoning???: 設(shè)為??false?? 可查看更多內(nèi)部處理過程 - ?
?disable_response_storage??: 重要隱私設(shè)置,禁止數(shù)據(jù)存儲(chǔ)
核心命令
使用 ??codex --help?? 查看所有可用命令參數(shù),這是個(gè)好習(xí)慣!
啟動(dòng) Codex 后,輸入 ??/?? 可查看所有支持的快捷命令:
/status - 狀態(tài)檢查
最重要的命令,用于檢查:
- 當(dāng)前權(quán)限級(jí)別
- GPT-5 模型配置
- API Key 狀態(tài)
特別提醒: 使用自定義 API Key 時(shí),務(wù)必經(jīng)常檢查確保使用正確的模型配置。
/approvals - 權(quán)限管理
Codex 提供三種權(quán)限級(jí)別:
權(quán)限級(jí)別 | 功能范圍 | 適用場(chǎng)景 | 實(shí)際體驗(yàn) |
Read Only | 僅讀取文件 | 代碼審查、學(xué)習(xí) | 限制過多,頻繁需要確認(rèn) |
Auto | 讀寫文件、運(yùn)行命令 | 一般開發(fā) | 仍需較多手動(dòng)確認(rèn) |
Full Access | 完整權(quán)限 + 網(wǎng)絡(luò)訪問 | 完整開發(fā)流程 | 真正的自動(dòng)化體驗(yàn) |
推薦配置
對(duì)于日常開發(fā),推薦使用 ??Full Access?? 模式,可通過啟動(dòng)參數(shù)跳過權(quán)限確認(rèn):
codex --dangerously-bypass-approvals-and-sandbox安全提醒
??Full Access?? 模式具有完整系統(tǒng)權(quán)限,請(qǐng)確保在可信環(huán)境中使用。
/mcp - MCP 服務(wù)器配置
Windows 開發(fā)者按照 mcp_servers 官方文檔 配置通常會(huì)失敗!
常見錯(cuò)誤信息:
Program not found
# 或
request timed outWindows 下正確配置方法:
在原教程基礎(chǔ)上添加以下配置:
- 新增 ?
?command?? - 指向具體的 npx 位置 - 新增 ?
?env?? - 包含 SYSTEMROOT 環(huán)境變量
[mcp_servers.context7]
command = "C:\\Program Files\\nodejs\\npx.cmd"
args = ["-y", "@upstash/context7-mcp", "--api-key", "<your_api_key>"]
env = {SYSTEMROOT = 'C:\Windows'}正確配置后,你將看到類似下圖的顯示效果:

codex-mcp 配置成功示例
對(duì)話恢復(fù)功能
恢復(fù)/繼續(xù)對(duì)話功能仍在開發(fā)中,所以 ??--help?? 中暫未添加說明,但當(dāng)前可用。
Codex 的對(duì)話歷史保存在本地目錄 ??~/.codex/sessions?? 下:
選擇恢復(fù)對(duì)話:
codex resume # 顯示最近對(duì)話列表,手動(dòng)選擇工具調(diào)用優(yōu)化
為了最快、最準(zhǔn)確地幫助 Codex 完成任務(wù),我們需要針對(duì)性地使用不同的搜索工具。
平臺(tái)適配:本文主要針對(duì) Windows 平臺(tái),旨在引導(dǎo) Codex 使用正確的命令和工具,減少錯(cuò)誤重試、降低任務(wù)執(zhí)行時(shí)長。
倉庫規(guī)則配置:Codex 支持在代碼倉庫根目錄添加 ??AGENTS.md?? 文件指導(dǎo)工具使用規(guī)則。
三大搜索工具
工具類型 | 工具名稱 | 使用場(chǎng)景 | 命令示例 |
文件名搜索 | ? | 按文件名查找 | ? |
文本內(nèi)容搜索 | ? (ripgrep) | 按文本內(nèi)容查找 | ? |
代碼結(jié)構(gòu)搜索 | ? (ast-grep) | 按代碼語義查找 | ? |
Windows 安裝
winget install sharkdp.fd BurntSushi.ripgrep.MSVC ast-grepripgrep 安裝后需要手動(dòng)添加到環(huán)境變量,自行解決
AGENTS.md 配置指南
在實(shí)際操作中發(fā)現(xiàn),僅聲明可用工具而不引導(dǎo)具體用法,經(jīng)常會(huì)偏離預(yù)期。建議使用下方完整配置,按需調(diào)整。
## Tool Priority
- Filename search: `fd`.
- Text/content search: `rg` (ripgrep).
- AST/structural search: `sg` (ast-grep) — preferred for code-aware queries (imports, call expressions, JSX/TSX nodes).
### AST-grep Usage (Windows)
- Announce intent and show the exact command before running complex patterns.
- Common queries:
- Find imports from `node:path` (TypeScript/TSX):
- `ast-grep -p "import $$ from 'node:path'" src --lang ts,tsx,mts,cts`
- Find CommonJS requires of `node:path`:
- `ast-grep -p "require('node:path')" src --lang js,cjs,mjs,ts,tsx`
- Suggest rewrite (do not auto-apply in code unless approved):
- Search: `ast-grep -p "import $$ from 'node:path'" src --lang ts,tsx`
- Proposed replacement: `import $$ from 'pathe'`
### Search Hygiene (fd/rg/sg)
- Exclude bulky folders to keep searches fast and relevant: `.git`, `node_modules`, `coverage`, `out`, `dist`.
- Prefer running searches against a scoped path (e.g., `src`) to implicitly avoid vendor and VCS directories.
- Examples:
- `rg -n "pattern" -g "!{.git,node_modules,coverage,out,dist}" src`
- `fd --hidden --exclude .git --exclude node_modules --exclude coverage --exclude out --exclude dist --type f ".tsx?$" src`
- ast-grep typically respects `.gitignore`; target `src` to avoid scanning vendor folders:
- `ast-grep -p "import $$ from '@shared/$$'" src --lang ts,tsx,mts,cts`
- If needed, add ignore patterns to your ignore files rather than disabling ignores.系統(tǒng)通知配置
Codex 支持在任務(wù)執(zhí)行完成后執(zhí)行自定義事件,我們可利用這一特性實(shí)現(xiàn) Windows 系統(tǒng)彈窗通知。
參考文檔:Codex 通知配置
步驟 1:配置 config.toml
在 ??~/.codex/config.toml?? 中添加:
# 通知命令配置
notify = [
"powershell.exe",
"-NoProfile",
"-ExecutionPolicy","Bypass",
"-File","C:\\Users\\<username>\\.codex\\notify.ps1"
]步驟 2:創(chuàng)建通知腳本
在 ??~/.codex/notify.ps1?? 中創(chuàng)建:
param(
[Parameter(Mandatory = $true)]
[string]$json
)
# 解析 JSON(Codex 傳入的 JSON 參數(shù))
try {
$payload = $json | ConvertFrom-Json
} catch {
$payload = @{}
}
# 配置通知內(nèi)容
$title = 'Codex 任務(wù)完成'
$msg = $payload.'last-assistant-message'
if (-not $msg) {
if ($payload.type) {
$msg = "事件類型: $($payload.type)"
} else {
$msg = 'Codex 有新更新。'
}
}
# 文本截?cái)嗵幚恚ū苊膺^長顯示)
if ($msg -and $msg.Length -gt 240) {
$msg = $msg.Substring(0,240) + '...'
}
# 使用 BurntToast 模塊顯示通知
Import-Module BurntToast -ErrorAction Stop
New-BurntToastNotification -Text $title, $msg | Out-Null需要先安裝 BurntToast PowerShell 模塊:
Install-Module -Name BurntToast -Scope CurrentUser調(diào)試技巧與優(yōu)化
每次修改 ??AGENTS.md??? 后,多使用 ??Ctrl+T?? 查看思考過程,檢查命令調(diào)用和思考邏輯是否符合預(yù)期。
優(yōu)化流程

調(diào)試技巧
- 定期檢查- 使用?
?Ctrl+T?? 查看當(dāng)前任務(wù)的思考軌跡 - 及時(shí)調(diào)整- 發(fā)現(xiàn)偏差時(shí)直接與 Codex 對(duì)話詢問
- 多輪優(yōu)化- 重復(fù)調(diào)整直到獲得滿意結(jié)果
- 記錄經(jīng)驗(yàn)- 將有效的?
?AGENTS.md?? 配置保存為模板
Spec-kit 工作流
模仿 GitHub Spec-kit 建立的新功能實(shí)現(xiàn)規(guī)范,包含三個(gè)流程:spec、plan 和 do。
流程概覽
階段 | 命令 | 作用 | 輸出 |
規(guī)范 | ? | 生成功能規(guī)范 | ? 目錄下的 Markdown 文件 |
計(jì)劃 | ? | 根據(jù)規(guī)范生成實(shí)現(xiàn)計(jì)劃 | ? 目錄下的計(jì)劃文件 |
實(shí)現(xiàn) | ? | 按照計(jì)劃執(zhí)行實(shí)現(xiàn) | 實(shí)際代碼變更 |
注意事項(xiàng)
- 不必嚴(yán)格遵循三個(gè)階段順序
- 可以多輪對(duì)話調(diào)整 spec 文件直到滿意
- 仍在測(cè)試優(yōu)化中,未使用官方 prompts.md 方式
## Stage-Gated Workflow (spec/plan/do)
- Mode: Opt-in. The workflow applies only when the user explicitly uses `/spec`, `/plan`, or `/do`. Routine Q&A or trivial edits do not require these stages.
- Triggers: A message containing one of `/spec`, `/plan`, or `/do` activates or advances the workflow. Once active, stages must proceed in order with explicit user approval to advance.
- Guardrails:
- Do not modify source code before `/do`. Documentation/spec files may be edited only in `/spec`.
- Do not skip stages or proceed without user confirmation once the workflow is active.
- If scope changes, return to the appropriate prior stage for approval.
- Respect sandbox/approval settings for all actions.
- When to Use
- Use the workflow for new features, structural refactors, multi-file changes, or work needing traceability.
- Skip the workflow (no triggers) for routine Q&A, diagnostics, or one-off trivial edits.
- Entry Points and Prerequisites
- `/spec` is the canonical entry point for new efforts.
- `/plan` requires an approved `/spec`. If unclear which spec applies, pause and ask the user to identify the correct file(s) under `specs/`.
- `/do` requires an approved `/plan`.
- `/spec` (Specifications; docs only)
- Purpose: Capture a concrete, reviewable specification using spec-kit style.
- Output: Markdown spec(s) under `specs/` (no code changes). Share a concise diff summary and links to updated files; wait for approval.
- Style: Specs are canonical and final. Do not include change logs or “correction/更正” notes. Incorporate revisions directly so the document always reflects the current agreed state. Historical context belongs in PR descriptions, commit messages, or the conversation — not in the spec.
- Recommended contents:
- Problem statement and context
- Goals and non-goals
- Requirements and constraints (functional, UX, performance, security)
- UX/flows and API/IPC contracts (as applicable)
- Acceptance criteria and success metrics
- Alternatives considered and open questions
- Rollout/backout considerations and telemetry (if relevant)
- `/plan` (High-level Plan; docs only)
- Purpose: Turn the approved spec into an ordered, verifiable implementation plan.
- Inputs: Approved spec file(s) in `specs/`.
- Ambiguity: If the relevant spec is unclear, pause and request clarification before writing the plan.
- Style: Plans are canonical and should not include change logs or “correction/更正” notes. Incorporate revisions directly so the plan always reflects the current agreed state. Historical notes should live in PR descriptions, commit messages, or the conversation.
- Output:
- An ordered plan via `update_plan` (short, verifiable steps; Task is merged into Plan and tracked here).
- A plan document in `plans/` named `YYYY-MM-DD-short-title.md`, containing:
- Scope and links to authoritative spec(s)
- Assumptions and out-of-scope items
- Phases/milestones mapped to acceptance criteria
- Impacted areas, dependencies, risks/mitigations
- Validation strategy (tests/lint/build) and rollout/backout notes
- Approval status and next stage
- Handoff: Await user approval of the plan before `/do`.
- `/do` (Execution)
- Purpose: Implement approved plan steps with minimal, focused changes and file operations.
- Actions:
- Use `apply_patch` for file edits; group related changes and keep diffs scoped to approved steps.
- Provide concise progress updates and a final summary of changes.
- Validate appropriately: run `pnpm lint`, `pnpm format`, `pnpm build`, and relevant tests.
- If material changes to the plan are needed, pause and return to `/plan` (or `/spec`) for approval.
- Output: Implemented changes, validation results, and a concise change summary linked to the plan checklist.
### Plans Directory
- Location: `plans/` at the repository root.
- Filename: `YYYY-MM-DD-short-title.md` (kebab-case title; consistent dating).
- Style: Plan docs are the canonical source of truth for the implementation approach; avoid embedding change logs or “correction/更正” notes. Update the plan in place as decisions evolve.
- Contents:
- Title and summary
- Scope and linked specs (paths under `specs/`)
- Assumptions / Out of scope
- Step-by-step plan (short, verifiable)
- Validation strategy (tests/lint/build)
- Approval status and next stage
- Process:
- During `/plan`, create or update the relevant file in `plans/` and share a short summary in the conversation. Await approval before `/do`.WSL2
如果你在 Windows 下讓 Codex 執(zhí)行任務(wù),你會(huì)發(fā)現(xiàn)它經(jīng)常調(diào)用命令失敗然后重試,如此循環(huán)。雖然最終都會(huì)成功,但浪費(fèi)了很多時(shí)間,個(gè)人推測(cè)這是因?yàn)?GPT-5 Unix Shell 訓(xùn)練數(shù)據(jù)太多而 Powershell 數(shù)據(jù)太少導(dǎo)致的幻覺,Codex 總是下意識(shí)調(diào)用 Unix Shell 命令來處理。
那么有沒有辦法解決呢?當(dāng)然有!打不過就加入——WSL2。
以 Windows 11 為例,在 Powershell 執(zhí)行 ??wsl --install?? 即可安裝 WSL2。
這種情況下,有兩種方式選擇:
- Windows 端代碼+WSL2 Codex 環(huán)境,適用于開發(fā) Windows 端的程序,比如 Electron Windows,.NET 等
- WSL2 代碼 + WSL2 Codex 環(huán)境,比如 Vue Web 開發(fā)
對(duì)于后者,所有都能正常在 WSL2 環(huán)境內(nèi)運(yùn)行,就不做說明了,而前者 Windows + WSL2 混用就需要解決一個(gè)問題:如何在 WSL2 調(diào)用 Windows 端的 ??npm/pnpm???,執(zhí)行定義好的 ??pnpm typecheck????pnpm lint:fix?? 等。
在 WSL2 Codex 對(duì)話時(shí),要求其調(diào)用 pwsh.exe 來執(zhí)行 ??pnpm typecheck?? 來檢查,如此即可。
we're in WSL2, please using pwsh.exe to run `pnpm <script>`完整-agents-md
還在調(diào)整中,不要完全照抄,最好還是通過 ??ctrl+T??? 查看整個(gè)過程,如果遇到 Codex 經(jīng)常會(huì)出錯(cuò)的命令,選擇性的修刪適合自己的 ??AGENTS.md??。
主要適配內(nèi)容:
- Windows/WSL2 支持,優(yōu)先使用 Powershell 支持的命令,對(duì)于任何 npm 包安裝都必須請(qǐng)示用戶,避免混亂的依賴項(xiàng)
- 使用 fd,ripgrep,ast-grep 搜索文件、文本和代碼片段,更快更直接
- spec/plan/do 工作流,先確定規(guī)范,再編寫計(jì)劃,最后實(shí)現(xiàn)
# AGENTS Guidelines
## Windows Environment Notice
- Prefer PowerShell (`pwsh`/`powershell`) when on Windows.
- Prefer using pwsh.exe to run `pnpm <script>` when on WSL2.
- WSL2 may be used for non-package-manager commands only (e.g., `rg`, `tar`). Avoid running Node builds in WSL due to OS mismatch.
- WSL2 cross-drive performance: accessing repos under `/mnt/c|d|e/...` goes through a filesystem bridge and can be slower for full scans. Prefer scoping to subtrees, excluding heavy folders, or running the same searches with native Windows binaries in PowerShell for large/iterative scans.
- Do not auto-run dependency installs. The user must run `pnpm install` in Windows PowerShell manually and then confirm completion.
- Do not modify `package.json`/lockfiles to add or update dependencies without explicit user approval. Propose dependencies in `/spec` or `/plan`, and ask the user to run `pnpm add <pkg>` (or `pnpm install`) and confirm.
- Do not call Unix text tools directly in PowerShell (e.g., `sed`, `awk`, `cut`, `head`, `tail`). Use PowerShell-native equivalents instead:
- `head` → `Select-Object -First N`
- `tail` → `Get-Content -Tail N`
- paging → `Out-Host -Paging` or `more`
- substitution/replace → `-replace` with `Get-Content`/`Set-Content`
## Tool Priority
- Filename search: `fd`.
- Text/content search: `rg` (ripgrep).
- AST/structural search: `sg` (ast-grep) — preferred for code-aware queries (imports, call expressions, JSX/TSX nodes).
### AST-grep Usage
- Announce intent and show the exact command before running complex patterns.
- Common queries:
- Find imports from `node:path` (TypeScript/TSX):
- `ast-grep -p "import $$ from 'node:path'" src --lang ts,tsx,mts,cts`
- Find CommonJS requires of `node:path`:
- `ast-grep -p "require('node:path')" src --lang js,cjs,mjs,ts,tsx`
- Suggest rewrite (do not auto-apply in code unless approved):
- Search: `ast-grep -p "import $$ from 'node:path'" src --lang ts,tsx`
- Proposed replacement: `import $$ from 'pathe'`
### Search Hygiene (fd/rg/sg)
- Exclude bulky folders to keep searches fast and relevant: `.git`, `node_modules`, `coverage`, `out`, `dist`.
- Prefer running searches against a scoped path (e.g., `src`) to implicitly avoid vendor and VCS directories.
- Examples:
- `rg -n "pattern" -g "!{.git,node_modules,coverage,out,dist}" src`
- `fd --hidden --exclude .git --exclude node_modules --exclude coverage --exclude out --exclude dist --type f ".tsx?$" src`
- ast-grep typically respects `.gitignore`; target `src` to avoid scanning vendor folders:
- `ast-grep -p "import $$ from '@shared/$$'" src --lang ts,tsx,mts,cts`
- If needed, add ignore patterns to your ignore files rather than disabling ignores.
## Temporary Research Files
- Canonical location: store all temporary research artifacts (downloaded READMEs, API docs, scratch notes) under `docs/research/`.
- Do not place temporary files at the repository root or outside `docs/research/`.
- Commit policy: avoid committing temporary files unless they are necessary for traceability during `/spec` or `/plan`. If committed, keep the scope minimal and store them under `docs/` only.
- Naming: use descriptive names with date or task context (e.g., `docs/research/2025-09-11-wsl-notes.md`).
- Cleanup: after completing a task (`/do`), evaluate whether each temporary file is still required. Remove unneeded files, or promote essential content into curated docs under `docs/` or into `specs/`/`plans/`.
## Stage-Gated Workflow (spec/plan/do)
- Mode: Opt-in. The workflow applies only when the user explicitly uses `/spec`, `/plan`, or `/do`. Routine Q&A or trivial edits do not require these stages.
- Triggers: A message containing one of `/spec`, `/plan`, or `/do` activates or advances the workflow. Once active, stages must proceed in order with explicit user approval to advance.
- Guardrails:
- Do not modify source code before `/do`. Documentation/spec files may be edited only in `/spec`.
- Do not skip stages or proceed without user confirmation once the workflow is active.
- If scope changes, return to the appropriate prior stage for approval.
- Respect sandbox/approval settings for all actions.
- When to Use
- Use the workflow for new features, structural refactors, multi-file changes, or work needing traceability.
- Skip the workflow (no triggers) for routine Q&A, diagnostics, or one-off trivial edits.
- Entry Points and Prerequisites
- `/spec` is the canonical entry point for new efforts.
- `/plan` requires an approved `/spec`. If unclear which spec applies, pause and ask the user to identify the correct file(s) under `specs/`.
- `/do` requires an approved `/plan`.
- `/spec` (Specifications; docs only)
- Purpose: Capture a concrete, reviewable specification using spec-kit style.
- Output: Markdown spec(s) under `specs/` (no code changes). Share a concise diff summary and links to updated files; wait for approval.
- Style: Specs are canonical and final. Do not include change logs or “correction/更正” notes. Incorporate revisions directly so the document always reflects the current agreed state. Historical context belongs in PR descriptions, commit messages, or the conversation — not in the spec.
- Recommended contents:
- Problem statement and context
- Goals and non-goals
- Requirements and constraints (functional, UX, performance, security)
- UX/flows and API/IPC contracts (as applicable)
- Acceptance criteria and success metrics
- Alternatives considered and open questions
- Rollout/backout considerations and telemetry (if relevant)
- `/plan` (High-level Plan; docs only)
- Purpose: Turn the approved spec into an ordered, verifiable implementation plan.
- Inputs: Approved spec file(s) in `specs/`.
- Ambiguity: If the relevant spec is unclear, pause and request clarification before writing the plan.
- Style: Plans are canonical and should not include change logs or “correction/更正” notes. Incorporate revisions directly so the plan always reflects the current agreed state. Historical notes should live in PR descriptions, commit messages, or the conversation.
- Output:
- An ordered plan via `update_plan` (short, verifiable steps; Task is merged into Plan and tracked here).
- A plan document in `plans/` named `YYYY-MM-DD-short-title.md`, containing:
- Scope and links to authoritative spec(s)
- Assumptions and out-of-scope items
- Phases/milestones mapped to acceptance criteria
- Impacted areas, dependencies, risks/mitigations
- Validation strategy (tests/lint/build) and rollout/backout notes
- Approval status and next stage
- Handoff: Await user approval of the plan before `/do`.
- `/do` (Execution)
- Purpose: Implement approved plan steps with minimal, focused changes and file operations.
- Actions:
- Use `apply_patch` for file edits; group related changes and keep diffs scoped to approved steps.
- Provide concise progress updates and a final summary of changes.
- Validate appropriately: run `pnpm lint`, `pnpm format`, `pnpm build`, and relevant tests.
- If material changes to the plan are needed, pause and return to `/plan` (or `/spec`) for approval.
- Output: Implemented changes, validation results, and a concise change summary linked to the plan checklist.
### Plans Directory
- Location: `plans/` at the repository root.
- Filename: `YYYY-MM-DD-short-title.md` (kebab-case title; consistent dating).
- Style: Plan docs are the canonical source of truth for the implementation approach; avoid embedding change logs or “correction/更正” notes. Update the plan in place as decisions evolve.
- Contents:
- Title and summary
- Scope and linked specs (paths under `specs/`)
- Assumptions / Out of scope
- Step-by-step plan (short, verifiable)
- Validation strategy (tests/lint/build)
- Approval status and next stage
- Process:
- During `/plan`, create or update the relevant file in `plans/` and share a short summary in the conversation. Await approval before `/do`.經(jīng)驗(yàn)分享
主動(dòng)引導(dǎo)技巧
不要把所有注意事項(xiàng)都寫入 ??AGENTS.md??,用戶需要根據(jù)不同場(chǎng)景主動(dòng)引導(dǎo) Codex 使用適合的工具。
實(shí)用例子:
- 使用?
?git diff?? 提供更準(zhǔn)確的上下文 - 在查詢時(shí)直接給出關(guān)鍵信息(函數(shù)名、文件名等)
信息提供原則
盡可能提供完整信息:Codex 的代碼搜索方式相對(duì)原始,可能搜不到你想要的內(nèi)容。
最佳實(shí)踐:
- 直接提供函數(shù)名、文件名等關(guān)鍵信息
- 使用?
?@?? 快捷命令快速搜索文件名 - 減少 Codex 的誤判和搜索時(shí)間
網(wǎng)頁搜索建議
網(wǎng)頁搜索優(yōu)先使用網(wǎng)頁版 ChatGPT-5-Thinking:
- 搜索更快更完整
- 非常擅長 GitHub 項(xiàng)目檢索(源碼、項(xiàng)目結(jié)構(gòu)、issue、PR)
- 特別適合了解開源項(xiàng)目功能
總結(jié)
AI 工具日新月異,一個(gè)新工具崛起,不要妄想能三分鐘上手掌握,也不要過于依賴他人的博客文檔和結(jié)論。AI 工具千人千面,每個(gè)人都有各自的編程習(xí)慣,需要:
- 花幾天時(shí)間慢慢了解工具特性
- 理解背后的大語言模型習(xí)慣和特點(diǎn)
- 根據(jù)自己的需求和喜好調(diào)教獨(dú)屬的 AI 工具
官方資源
- 官方快速開始文檔
- GitHub 項(xiàng)目文檔
本文轉(zhuǎn)載自??AI 博物院?? 作者:longyunfeigu

















