进阶 A · 本地工具与配置Advanced A · Local Tools and Configuration.
需要终端或更细控制时再读:CLI、IDE、配置层级、权限、AGENTS.md 与 Skills。用本机版本核对命令, 不照抄旧开关。Read this when you need the terminal or finer control: CLI, IDE, configuration layers, permissions, AGENTS.md, and skills. Verify commands against your installed version.
如果前面的文件、旅行和表格流程已经够用, 可以跳过本附录。只有当你要反复处理本机目录、维护个人小工具, 或希望看清每一条命令与修改时, 才需要走进终端。这里的目标是完成一次有边界的本地修改, 留下能复跑的检查。Skip this appendix if the file, travel, and spreadsheet workflows already serve you. Use a terminal when you repeatedly process local folders, maintain a personal tool, or want to inspect commands and edits directly. The goal is one bounded local change with a check you can run again.
— I
安装以后, 先确认在哪里工作After Installation, Check Your Working Directory.
桌面 Codex、CLI 和 IDE 扩展是不同操作入口。已有编辑器项目, 可用 IDE 扩展查看选中代码与 diff;已有终端流程, 用 CLI 更容易接上命令。不要为练习同时安装三个入口。以下命令以已安装 Node.js 的终端为例, 安装会下载软件;先确认包名和发布者。本轮帮助核验版本是 codex-cli 0.160.1, 日期为 2026-10-09。1注 1Note 1OpenAI · Developer commands。命令及参数对照当前文档,并以本机 codex-cli 0.160.1 的 --help 复核;截至 2026-10-09。OpenAI · Developer commands. Commands and flags were compared with the current docs and local codex-cli 0.160.1 help on 2026-10-09.Desktop Codex, the CLI, and the IDE extension offer different controls. An IDE is convenient for selected code and diffs; the CLI fits an existing terminal workflow. You do not need all three. The following assumes Node.js is installed; installation downloads software, so verify the package and publisher. Local help was checked with codex-cli 0.160.1 on 2026-10-09.1注 1Note 1OpenAI · Developer commands。命令及参数对照当前文档,并以本机 codex-cli 0.160.1 的 --help 复核;截至 2026-10-09。OpenAI · Developer commands. Commands and flags were compared with the current docs and local codex-cli 0.160.1 help on 2026-10-09.
安装一次;在你选定的小项目目录里启动Install once; start inside your chosen small project
用 ChatGPT 账号登录, 才按该账号适用的 included usage / credits 计费。API key 是独立账本, 不会消费你的 ChatGPT 订阅内含额度, 也不提供同一套云端集成。不要把「已订阅」理解成「API 免费」。账号、平台与灰度决定具体可用入口;没有 CLI 资格时继续使用账号可见的桌面体验, 不必先买 key。5注 5Note 5OpenAI · Pricing。ChatGPT 登录与 API key 的额度和功能边界不同;截至 2026-10-09。OpenAI · Pricing. ChatGPT sign-in and API-key usage have different billing and feature boundaries; checked 2026-10-09.ChatGPT sign-in uses the account's applicable included usage and credits. An API key has separate billing and does not draw from your ChatGPT subscription allowance or unlock the same cloud integrations. A subscription does not make API usage free. Access depends on account, platform, and rollout; if the CLI is unavailable, keep using the desktop experience your account offers instead of buying an API key by default.5注 5Note 5OpenAI · Pricing。ChatGPT 登录与 API key 的额度和功能边界不同;截至 2026-10-09。OpenAI · Pricing. ChatGPT sign-in and API-key usage have different billing and feature boundaries; checked 2026-10-09.
提示词PromptCodex · Local
先只读检查这个项目。目标:<我要修改的行为>。请找出入口文件、相关测试和最小修改范围, 给出计划。不要改文件、安装依赖、连接外部账号或上传内容。遇到不清楚的需求先问我。Inspect this project read-only first. Goal: <behavior to change>. Find the entry point, relevant tests, and smallest change scope. Return a plan. Do not edit files, install dependencies, connect accounts, or upload content. Ask about unclear requirements.
先只读检查我的文件改名预览器。找出生成新文件名和检测重名的逻辑, 以及对应测试。我要让它识别 Unicode 组合形式不同但显示相同的名字。给最小修改计划, 不改文件、不安装依赖、不上传原文件。Inspect my file-renaming preview tool read-only. Find name generation, collision detection, and related tests. I want it to recognize names that look identical but use different Unicode compositions. Give the smallest plan; do not edit, install dependencies, or upload original files.
看完计划再准许修改, 说明允许的目录和检查命令。若你在只读会话中, 通过客户端权限设置切换到需要的工作区权限, 或退出后用下一条命令重新打开;不要要求它暗中绕过沙箱。最后看 diff、跑测试、用副本手工试一次, 再决定保留。Approve implementation only after reviewing the plan, naming allowed directories and checks. In a read-only session, change permissions through the client or restart with the following command; do not ask it to evade the sandbox. Inspect the diff, run tests, and try a copy manually before keeping the change.
权限的三件事:读写、审批、信任Three Separate Controls: Access, Approval, Trust.
沙箱决定工具通常能访问什么;审批决定越界时怎样处理;项目信任决定是否加载仓库附带的本地配置。read-only 仍可读取允许访问的文件, 不等于隐私隔离。workspace-write 允许工作区写入, 也不表示可以随意改受保护路径或访问网络。never 的含义是「不弹审批」, 被边界拦下的动作会失败, 并非「全部允许」。3注 3Note 3OpenAI · Agent approvals & security。untrusted 审批策略已退役;沙箱、审批与项目信任分别配置;截至 2026-10-09。OpenAI · Agent approvals & security. The untrusted approval policy is retired; sandboxing, approvals, and project trust are separate settings; checked 2026-10-09.The sandbox controls normal tool access; approval policy handles requests beyond it; project trust controls loading repository-local configuration. read-only can still read accessible files and is not a privacy boundary. workspace-write does not imply unrestricted access to protected paths or the network. never means no approval prompts: blocked actions fail, rather than receiving blanket permission.3注 3Note 3OpenAI · Agent approvals & security。untrusted 审批策略已退役;沙箱、审批与项目信任分别配置;截至 2026-10-09。OpenAI · Agent approvals & security. The untrusted approval policy is retired; sandboxing, approvals, and project trust are separate settings; checked 2026-10-09.
需要Need
起点Starting point
你仍要做的事Your responsibility
调查与审查Investigation and review
read-only + on-request
不要批准与目标无关的扩大访问Reject unrelated access expansion
修改已选项目Edit a selected project
workspace-write + on-request
备份, 限定目录, 验收 diffBack up, limit scope, inspect the diff
无人值守检查Unattended checks
read-only + never
接受遇阻失败, 保存错误记录Let blocked work fail and record errors
个人默认在 ~/.codex/config.toml;项目默认在 .codex/config.toml, 只在受信项目里加载。当前优先级从高到低为:命令行覆盖、离工作目录更近的项目配置、选中的 profile 文件、用户配置、云端管理默认、系统配置、内置默认。组织强制要求另行约束这些默认。2注 2Note 2OpenAI · Config basics。个人、profile、受信项目与命令行的配置层级;截至 2026-10-09。OpenAI · Config basics. User, profile, trusted-project, and command-line configuration layers; checked 2026-10-09.一次尝试先用命令行, 确认好用再保存, 不必先抄一整份别人的配置。Personal defaults live in ~/.codex/config.toml; trusted projects can load .codex/config.toml. Current precedence runs from command-line overrides through nearest project configuration, selected profile, user configuration, cloud-managed defaults, system configuration, and built-in defaults. Enforced organizational requirements constrain these choices separately.2注 2Note 2OpenAI · Config basics。个人、profile、受信项目与命令行的配置层级;截至 2026-10-09。OpenAI · Config basics. User, profile, trusted-project, and command-line configuration layers; checked 2026-10-09. Try a setting on the command line before saving it; do not begin by copying someone else's entire configuration.
当前 profile 是独立的 inspect.config.toml, 不再照抄旧教程里的 [profiles.inspect]。--strict-config 帮你发现当前版本不认识的键, 但不能证明权限合理、模型有资格使用或外部工具已经连通。先看 codex --help, 再核对 schema 与实际客户端。1注 1Note 1OpenAI · Developer commands。命令及参数对照当前文档,并以本机 codex-cli 0.160.1 的 --help 复核;截至 2026-10-09。OpenAI · Developer commands. Commands and flags were compared with the current docs and local codex-cli 0.160.1 help on 2026-10-09.A current profile is a separate inspect.config.toml file; do not copy an old [profiles.inspect] example. --strict-config catches unrecognized keys, but cannot prove permissions are appropriate, a model is available to your account, or tools are connected. Check codex --help, the schema, and your actual client.1注 1Note 1OpenAI · Developer commands。命令及参数对照当前文档,并以本机 codex-cli 0.160.1 的 --help 复核;截至 2026-10-09。OpenAI · Developer commands. Commands and flags were compared with the current docs and local codex-cli 0.160.1 help on 2026-10-09.
— IV
项目约定:只留下会反复用到的规则Project Guidance: Keep Only Reusable Rules.
把能反复检验的工作约定写进 AGENTS.md:项目怎么运行、哪些数据不碰、交付前执行什么。当前发现顺序包括个人层, 再从项目根目录到当前工作目录逐层读取;同一目录优先 AGENTS.override.md, 然后 AGENTS.md, 每层最多一份。更近的规则补充或覆盖先前项目约定, 不能推翻上层安全约束。默认合并上限为 32 KiB, 截至 2026-10-09。4注 4Note 4OpenAI · Custom instructions with AGENTS.md。指令发现顺序、目录覆盖与截断条件;截至 2026-10-09。OpenAI · Custom instructions with AGENTS.md. Instruction discovery, directory overrides, and truncation; checked 2026-10-09.Put repeatedly testable agreements in AGENTS.md: how to run the project, data to leave untouched, and checks before handoff. Discovery includes personal guidance, then directories from project root to the working directory; each directory prefers AGENTS.override.md, then AGENTS.md, taking at most one file. More local instructions refine earlier project guidance without overriding higher-level safety constraints. The default combined limit is 32 KiB as of 2026-10-09.4注 4Note 4OpenAI · Custom instructions with AGENTS.md。指令发现顺序、目录覆盖与截断条件;截至 2026-10-09。OpenAI · Custom instructions with AGENTS.md. Instruction discovery, directory overrides, and truncation; checked 2026-10-09.
AGENTS.md
# Working agreements / 工作约定- Source files are private. Do not upload their contents. 原文件属私人资料, 不上传内容。- Keep original files unchanged; write previews to a separate folder. 保留原文件, 预览结果另存。- Ask before installing dependencies, deleting files, or publishing anything. 安装依赖、删除文件、公开发布前先确认。- Run `node --test` after changes and report the command and exit status. 修改后运行 `node --test`, 报告命令与退出状态。- Test duplicate names, empty input, and non-ASCII names. 检查重名、空输入与非 ASCII 文件名。
个人文件工具的一份小约定A small agreement for a personal file utility
个人偏好属于记忆或个人指导;项目不变量属于 AGENTS.md;可重复的操作步骤适合 任务卡与 skill;模型和权限默认属于配置文件。不要在四个地方各复制一遍。改完约定, 重新启动会话并让它列出本次实际读取的规则来源;回答与文件不符时先查工作目录和 override, 不要继续叠加提示。Personal preferences belong in memory or personal guidance; project invariants in AGENTS.md; repeatable procedures in task cards and skills; model and permission defaults in configuration. Avoid four duplicate copies. Restart after changing guidance and ask which files were actually loaded. If the answer differs, inspect the working directory and overrides before adding more instructions.
— V
中断、继续与交付Interrupt, Resume, and Hand Off.
方向错了就中断, 指出一处可观察的问题。继续原目标可以 resume;试另一方案可以 fork, 并说明不要动原方案的文件。分出新对话并不自动隔离文件, 同时写入应使用独立 worktree。每次恢复先检查当前目录、Git 状态和未完成的步骤, 不把旧聊天的成功声明当作当前文件状态。Interrupt when the direction is wrong and name an observable problem. Resume the same goal; fork to explore an alternative, explicitly protecting the original work. A new chat does not isolate files: concurrent edits need separate worktrees. Before resuming, check the directory, Git state, and unfinished steps rather than trusting an old success message.
codex resumecodex forkcodex --worktree
把权限开到任务需要的位置, 把结果留在你能检查的地方.
Grant the access the task needs, and keep the result where you can inspect it.
LOCAL · KEEP THE LOOP VISIBLE
— 讨论Discussion
讨论Discussion.
评论区初始化中…Initializing comments…
01 / 01
没有匹配结果No matches.
换个关键词,或按 Esc 回到页面Try another keyword, or press Esc to return