写码 · 从 Canvas 到 CodexWrite Code · From Canvas to Codex.
如果你完全不碰代码,这章可以跳过 —— 这正是把它单拎出来的原因。从聊天里改一段,到 Canvas 里就着一个文件来回改,再到 Codex 在你的仓库里跑命令、改文件、审 diff —— 投入和能力一路加重。2026 年 7 月的新 ChatGPT app 把 Chat、Work、Codex 放到一起,但分工没含糊:成品研究交 Work,软件开发才进 Codex 的桌面、CLI 或 IDE。If you never touch code, skip this chapter — which is exactly why it is separate. From editing a snippet in chat, to revising one file in Canvas, to Codex running commands, editing files, and reviewing diffs in your repo, the investment and power climb together. The July 2026 ChatGPT app brings Chat, Work, and Codex together, but the line stays sharp: finished research goes to Work; software development belongs in Codex on desktop, CLI, or IDE.
如果你完全不碰代码,这章可以跳过。把它单拎出来,就是为了让你能干净地跳过;但只要你会改一点脚本、配置、网页,这章会省很多试错。If you never touch code, skip this chapter. It is separate precisely so you can skip it cleanly; but if you ever edit scripts, configs, or web pages, this chapter saves a lot of trial and error.
— I
聊天、Canvas、Codex 是三档Chat, Canvas, Codex Are Three Rungs.
改动类型Change type
入口Entrance
边界Boundary
一段代码、一个报错、一个命令解释One snippet, one error, one command explanation
Chat
你复制粘贴,自己落地You paste and apply it yourself
一个文档或一个文件反复改One document or file revised repeatedly
能改仓库,但 merge 仍归你Can edit the repo, but merge remains yours
Canvas 官方定位是 ChatGPT 里的写作和编码编辑界面,适合选中局部内容、要求定点修改、查看版本和建议。4注 4Note 4OpenAI 帮助中心 · Canvas —— Canvas 是 ChatGPT 中用于写作和编码的编辑界面,适合在单个文档或代码片段上定点修改、查看建议和版本。OpenAI Help · Canvas — Canvas is an editing interface inside ChatGPT for writing and coding, suited to targeted edits, suggestions, and versions on one document or code snippet.它的边界也因此很硬:它不理解整个仓库的真实约束,不跑你的 lint / test / typecheck / build,也不能替你确认跨文件影响。Canvas is officially an editing interface inside ChatGPT for writing and coding work, useful for selecting local content, targeted edits, versions, and suggestions.4注 4Note 4OpenAI 帮助中心 · Canvas —— Canvas 是 ChatGPT 中用于写作和编码的编辑界面,适合在单个文档或代码片段上定点修改、查看建议和版本。OpenAI Help · Canvas — Canvas is an editing interface inside ChatGPT for writing and coding, suited to targeted edits, suggestions, and versions on one document or code snippet. Its boundary is therefore hard: it does not understand the real constraints of the whole repo, does not run your lint / test / typecheck / build, and cannot confirm cross-file effects.
— II
Codex 是请进仓库的开发 agentCodex Is the Development Agent You Invite Into a Repo.
官方帮助把 Codex 定义为帮助写、审、修、交付代码的 AI agent;它包含在 ChatGPT 计划中,但各档额度不同。1注 1Note 1OpenAI 帮助中心 · Using Codex with your ChatGPT plan —— Codex 是帮助写、审、修、交付代码的 AI agent;包含在 ChatGPT 计划中,但各档额度不同。Codex、ChatGPT Work、ChatGPT for Excel 与 Workspace Agents 在可用时共用同一个 agentic usage / credit pool。OpenAI Help · Using Codex with your ChatGPT plan — Codex is an AI agent for writing, reviewing, fixing, and shipping code; it is included in ChatGPT plans with plan-dependent allowances. Codex, ChatGPT Work, ChatGPT for Excel, and Workspace Agents share the same agentic usage / credit pool when available.2026 年 7 月的新 ChatGPT 桌面 app 把 Quick Chat、Work 与 Codex 放到一起:Work 处理研究、分析和文档 / 表格 / 演示等成品,Codex 才处理带代码库上下文和开发工具的软件工作。开发者仍可在 terminal 用 CLI,或在编辑器用 IDE extension。2注 2Note 2OpenAI Developers · ChatGPT quickstart —— 2026 年 7 月的新 ChatGPT 桌面 app 把 Quick Chat、Work 与 Codex 放在一个 app;Work 处理研究、分析与成品,Codex 处理带代码库上下文和开发工具的软件工作。开发者仍可在 terminal 使用 Codex CLI,或在编辑器使用 Codex IDE extension。OpenAI Developers · ChatGPT quickstart — the July 2026 ChatGPT desktop app brings Quick Chat, Work, and Codex together; Work handles research, analysis, and deliverables, while Codex handles software work with codebase context and developer tools. Developers can still use Codex CLI in a terminal or the Codex IDE extension in an editor.入口合并了,职责没有。Official Help defines Codex as an AI agent for writing, reviewing, fixing, and shipping code; it is included in ChatGPT plans with different allowances by tier.1注 1Note 1OpenAI 帮助中心 · Using Codex with your ChatGPT plan —— Codex 是帮助写、审、修、交付代码的 AI agent;包含在 ChatGPT 计划中,但各档额度不同。Codex、ChatGPT Work、ChatGPT for Excel 与 Workspace Agents 在可用时共用同一个 agentic usage / credit pool。OpenAI Help · Using Codex with your ChatGPT plan — Codex is an AI agent for writing, reviewing, fixing, and shipping code; it is included in ChatGPT plans with plan-dependent allowances. Codex, ChatGPT Work, ChatGPT for Excel, and Workspace Agents share the same agentic usage / credit pool when available. The July 2026 ChatGPT desktop app brings Quick Chat, Work, and Codex together: Work handles research, analysis, and deliverables such as documents, spreadsheets, and presentations; Codex handles software work with codebase context and developer tools. Developers can still use the CLI in a terminal or the IDE extension in an editor.2注 2Note 2OpenAI Developers · ChatGPT quickstart —— 2026 年 7 月的新 ChatGPT 桌面 app 把 Quick Chat、Work 与 Codex 放在一个 app;Work 处理研究、分析与成品,Codex 处理带代码库上下文和开发工具的软件工作。开发者仍可在 terminal 使用 Codex CLI,或在编辑器使用 Codex IDE extension。OpenAI Developers · ChatGPT quickstart — the July 2026 ChatGPT desktop app brings Quick Chat, Work, and Codex together; Work handles research, analysis, and deliverables, while Codex handles software work with codebase context and developer tools. Developers can still use Codex CLI in a terminal or the Codex IDE extension in an editor. The entrances converged; the jobs did not.
提示词PromptCodex 任务模板Codex task template
任务:<要改什么、达到什么效果>
范围:只动<这些文件 / 这个目录>,不要碰<明确排除>
约束:沿用现有风格;不要重构无关代码;不要改格式化规则
验证:改完运行<测试 / lint / typecheck / build 命令>
交付:先列计划等我确认;最后给 diff 摘要、风险和未做事项。Task: <what to change and outcome>
Scope: touch only <files / directory>, do not touch <explicit exclusions>
Constraints: follow existing style; do not refactor unrelated code; do not change formatting rules
Verification: after editing, run <test / lint / typecheck / build command>
Deliver: first list a plan and wait for approval; end with diff summary, risks, and remaining items.
任务:给用户导出功能加一个 CSV 格式选项,默认仍是 JSON。
范围:只动 src/export/ 和 src/api/export.ts,不要碰鉴权和数据库层
约束:沿用现有风格;不要重构无关代码;不要改格式化规则
验证:改完运行 npm test 和 npm run typecheck
交付:先列计划等我确认;最后给 diff 摘要、风险和未做事项。Task: add a CSV format option to the user export feature; default stays JSON.
Scope: touch only src/export/ and src/api/export.ts, do not touch the auth or database layer
Constraints: follow existing style; do not refactor unrelated code; do not change formatting rules
Verification: after editing, run npm test and npm run typecheck
Deliver: first list a plan and wait for approval; end with diff summary, risks, and remaining items.
— III
用量跟范围走Usage Follows Scope.
用量也要讲边界。Codex 消耗取决于模型、任务大小 / 复杂度,以及本地或云端执行;小脚本消耗少,大仓库、长任务、长上下文会消耗更多。3注 3Note 3OpenAI Developers · Codex pricing / usage —— Codex 消耗取决于模型、任务大小 / 复杂度,以及本地或云端执行;小任务消耗少,大仓库、长任务和长上下文消耗更多。OpenAI Developers · Codex pricing / usage — Codex consumption depends on model, task size / complexity, and whether execution is local or cloud; small tasks consume less, while large repos, long tasks, and long context consume more.而且 Codex、Work、ChatGPT for Excel 与 Workspace Agents 在可用时共用 agentic usage / credit pool。1注 1Note 1OpenAI 帮助中心 · Using Codex with your ChatGPT plan —— Codex 是帮助写、审、修、交付代码的 AI agent;包含在 ChatGPT 计划中,但各档额度不同。Codex、ChatGPT Work、ChatGPT for Excel 与 Workspace Agents 在可用时共用同一个 agentic usage / credit pool。OpenAI Help · Using Codex with your ChatGPT plan — Codex is an AI agent for writing, reviewing, fixing, and shipping code; it is included in ChatGPT plans with plan-dependent allowances. Codex, ChatGPT Work, ChatGPT for Excel, and Workspace Agents share the same agentic usage / credit pool when available.所以不要让它「随便看看大仓库能不能优化」,那等于把范围和额度都放开。好任务是窄的:这个 bug、这组文件、这条测试、这个验收标准。Usage has boundaries too. Codex consumption depends on model, task size / complexity, and whether it runs locally or in the cloud; small scripts consume little, while large codebases, long-running tasks, and long context consume more.3注 3Note 3OpenAI Developers · Codex pricing / usage —— Codex 消耗取决于模型、任务大小 / 复杂度,以及本地或云端执行;小任务消耗少,大仓库、长任务和长上下文消耗更多。OpenAI Developers · Codex pricing / usage — Codex consumption depends on model, task size / complexity, and whether execution is local or cloud; small tasks consume less, while large repos, long tasks, and long context consume more. Codex, Work, ChatGPT for Excel, and Workspace Agents also share the agentic usage / credit pool when available.1注 1Note 1OpenAI 帮助中心 · Using Codex with your ChatGPT plan —— Codex 是帮助写、审、修、交付代码的 AI agent;包含在 ChatGPT 计划中,但各档额度不同。Codex、ChatGPT Work、ChatGPT for Excel 与 Workspace Agents 在可用时共用同一个 agentic usage / credit pool。OpenAI Help · Using Codex with your ChatGPT plan — Codex is an AI agent for writing, reviewing, fixing, and shipping code; it is included in ChatGPT plans with plan-dependent allowances. Codex, ChatGPT Work, ChatGPT for Excel, and Workspace Agents share the same agentic usage / credit pool when available. So do not ask it to "look around this big repo and optimize anything"; that opens both scope and usage. A good task is narrow: this bug, these files, this test, this acceptance criterion.
能在一个文件里改完的,先用 Canvas。If one file is enough, start with Canvas.
需要跑命令、跨文件、改测试,才请 Codex。Call Codex when commands, cross-file edits, or tests are needed.