OpenAI 官方指南:Codex 提示词 9 套工作流直接抄,修 bug、截图变原型、云端重构全在内
- ChatGPT 官方发布提示词指南,覆盖 Chat、Work、Codex 三个界面。
- 核心是一套四要素框架:目标、背景、输出、边界。按需选用,不必每项都填。
- 为 Codex 给出 9 套具体工作流:读代码库、修 bug、写测试、截图变原型、边改边看的 UI 迭代、委托云端重构、两条路径的代码 review、更新文档,每套都附可直接抄的提示词。
- Codex 运行中支持追加消息:steer 当场改当前任务方向,queue 把话攒到下一轮再处理。
- 本地 IDE 里定好的重构计划,可以带着完整上下文直接迁到云端环境继续执行。
不用背模板:四个要素,该填的才填
OpenAI 团队在 learn.chatgpt.com 发布了一份官方提示词指南,讲清楚在 Chat、Work、Codex 三个界面里到底该怎么写提示词。
一套原则统一了 Chat、Work、Codex 三个界面的写法,还给 Codex 配了 9 套拆到命令级别的可复制工作流。短任务一句话就够,大任务才补齐要素。
先说清「要什么结果」,别急着列步骤
从你想要的结果说起,把受众和格式一并交代,剩下怎么做的空间留给 ChatGPT 去搜索、比较、调整。流程本身重要时才描述流程。
Turn these meeting notes into a short update for the project team. Put the decisions and next steps first.
说清结果拿来干嘛,它才知道写多长多细
「输出」这一要素的诀窍是:告诉 ChatGPT 你打算怎么用这个结果,它就能自己选对长度、详略和组织方式。对重要的活,还可以在结尾要求一次终检,比如确认每个行动项都有负责人和截止日期,或者把它没能核实的信息标出来,然后你自己再审一遍。
Make this a one-page summary a director can scan before the meeting. Put the decision and next steps first. Turn these notes into a follow-up email with the decisions, owners, and due dates. Create a clear table of planned versus actual spending and highlight any difference over 10%.
最后是四个要素里最容易被漏掉的一项:边界。
边界是那几条防止 ChatGPT 帮倒忙或擅自动手的指令。判据很简单:当「改错一个细节就会让结果没法用」,或者「某个动作会影响到别人、你想先审一遍」时,就加一条。抓最关键的一两条即可,不用管住每一步。
Keep the approved dates and budget figures unchanged. Use only the supplied sources. Flag missing information instead of guessing. Keep recommendations within the stated budget. Prepare the message as a draft. Don't send it.
喂对背景:文件、截图、联网搜索、连接的软件
「背景」就是那些会改变结果的信息。原则是只给相关的来源,并说清楚要 ChatGPT 从每个来源里拿什么。有这么几种喂法:
| 喂法 | 什么时候用 |
|---|---|
| 上传文档 / 表格 / PPT / PDF | 要它总结、比较、改写,或产出可供审阅的文件时 |
| 截图 / 示意图 / 图片 | 任务依赖视觉信息时。配一句文字说清具体看图里哪块,别光甩一张图 |
| 联网搜索 | 答案取决于最新信息时。要核对结果,就顺带让它给出来源 |
| 连接的数据源(Drive / Slack 等) | 点名去哪找、找什么,不用把每一次检索都描述一遍 |
Use the latest project plan in Drive and relevant decisions and updates from the project's Slack channel to prepare a status update.
连接数据源要装对应插件,能不能用取决于你的套餐和工作区设置。想指定某个插件,在输入框打 @ 挑就行。还有一层要分清:每次都适用的偏好(默认语气、习惯)放进「设置 > 个性化」的自定义指令里,只对当前这个任务有用的细节写在这次的提示词里。
结果不满意不用重写:跟进消息 + 插队还是排队
第一条提示词不用一次到位。看完结果,直接说你要改的那一处,就能补来源、纠方向、换个版本、调详略,不必从头再来。
Make the opening more direct, keep the evidence, and move the recommendation above the background section.
在 Codex 里还多一层:它正在跑的时候,你也能再发消息,落在哪一轮取决于你怎么发。
像点餐时厨师已经开始炒这道菜。喊「steer」是让他现在就改配料,这盘当场按新要求做;喊「queue」是等这盘炒完再上你加的那道。
桌面 App 里,默认行为在「设置 > General > Follow-up behavior」里设;排队的消息会显示在输入框上方,可以编辑、重排、发送或删掉。Codex CLI 里,跑的时候按 Enter 是 steer 当前轮,按 Tab 是 queue 到下一轮。顺带一提,桌面 App 还支持语音口述:按住 Ctrl + M 说话,说的内容转成文字进输入框,发送前可以检查修改。
一个完整例子:把四要素在真实 prompt 里对上号
四要素不是死格子。下面这段真实的完整 prompt,四种颜色标出哪几句是目标、背景、输出、边界,看一遍就知道它们怎么揉进一段话里。
中文:[目标]为周一的管理层会议做一份一页的项目状态更新。[背景]用 Drive 里最新的项目计划,加上项目 Slack 频道里相关的决定和进展。[输出]开头先给管理层要拍板的决定和下一步,再总结进展、风险、负责人和截止日期。[边界]已批准的日期和预算数字保持不变;有冲突或缺失的信息标出来;任何东西都别发、别发布。[边界 · 终检]收尾前,检查每个下一步都有负责人和截止日期。
它覆盖了目标、背景、输出、边界,末尾加了一句终检,但没有把每一步都写死。这就是四要素「按需拼装」的样子。
日常提问用 Chat,出成品用 Work
Chat 适合提问、找点子、写草稿、做日常决定,从你要的结果说起,需要时再补细节。Work 适合要动用多个来源或工具、要走多步、要产出较大成品文件的活。下面是官方给的范例,每条都可直接抄改。
Chat:日常提问的四种范例
Explain how compound interest works for someone who has never invested. Use one concrete example and define any financial terms you introduce.
Draft a friendly email declining this invitation because I will be traveling. Keep it under 120 words and leave the door open for a future event.
Compare these two phone plans for one person who travels internationally twice a year. Show the important differences in a table, then recommend one and explain the tradeoff.
Plan five weekday dinners that take less than 30 minutes. Avoid peanuts, reuse ingredients across meals, and finish with one consolidated shopping list.
Work:出成品的三种范例
Use the attached quarterly reports to create a leadership brief and a six-slide presentation. The audience is the executive team. Lead with the three decisions they need to make, distinguish reported facts from your analysis, cite each number to its source file, and check that the brief and slides agree before you finish.
Research three customer-support platforms for a 50-person company. Compare pricing, security, integrations, and migration effort using current sources. Deliver a recommendation memo with links, assumptions, and the questions we should answer before signing a contract.
Create a launch plan for the attached product brief. Include the timeline, owners, dependencies, risks, announcement draft, customer FAQ, and a checklist for launch day. Flag any missing decisions before producing the final files.
用 Work 的建议:先从一个你能审查的小结果起步,控制来源范围、限定日期,把必做的活和可选的润色分开;方法本身重要时让它先出个计划,发送、发布、改动别人依赖的信息之前要求先经你批准。这一版跑通了,再把这套流程复用起来,重复性的活还可以直接从那个任务里设成定时自动执行。
Codex 基本功三件套:读代码、修 bug、写测试
当你想让 ChatGPT 处理代码、代码库或开发者工具时用 Codex。一条好的 Codex 提示词会点明要什么行为、指向相关代码或复现步骤、保住关键约束,并说清怎么验证。下面三套都可直接照抄。
先说两个背景:IDE 扩展会自动把你打开的文件当上下文;CLI 里要显式写路径,或用 @ 补全、/mention 附文件。另外,Codex 在本地跑命令时被关在一个沙盒里,文件和网络权限受限,一旦要越界(比如访问外网、改沙盒外的文件),得先过你设定的审批策略才放行。
读懂代码库
接手一个陌生服务、想理清某个协议或请求流程时用它。
Explain how the request flows through the selected code. Include: - a short summary of the responsibilities of each module involved - what data is validated and where - one or two "gotchas" to watch for when changing this (验证追问) Summarize the request flow as a numbered list of steps. Then list the files involved.
codex I need to understand the protocol used by this service. Read @foo.ts @schema.ts and explain the schema and request/response flow. Focus on required vs optional fields and backward compatibility rules.
修 bug
手上有个能复现的坏行为时用它。给一份复现配方、加上你怀疑的文件,比一句高层描述有用得多。
codex Bug: Clicking "Save" on the settings screen sometimes shows "Saved" but doesn't persist the change. Repro: 1) Start the app: npm run dev 2) Go to /settings 3) Toggle "Enable alerts" 4) Click Save 5) Refresh the page: the toggle resets Constraints: - Do not change the API shape. - Keep the fix minimal and add a regression test if feasible. Start by reproducing the bug locally, then propose a patch and run checks. (验证追问) After the fix, run lint + the smallest relevant test suite. Report the commands and results.
Find the bug causing "Saved" to show without persisting changes. After proposing the fix, tell me how to verify it in the UI.
写单元测试
想精确框定测哪一段时用它。IDE 里选中函数代码后问,CLI 里直接点名函数名。
(IDE,选中函数代码后) Write a unit test for this function. Follow conventions used in other tests. (CLI,直接点名函数) Add a test for the invert_list function in @transform.ts. Cover the happy path plus edge cases.
Codex 进阶三件套:截图变原型、边改边看、委托云端
三个更进阶的工作流:把设计截图直接变成能跑的原型、一边改代码一边在浏览器里看效果、把耗时的重构本地定好方案后交给云端跑。
截图变原型
想把设计稿、截图或 UI 参考变成一个能跑的原型时用它。图给的是视觉要求,框架、路由、组件风格这些实现约束还得你写;图上看不到的行为(hover 状态、校验规则、键盘交互)也要用文字补上。
一张设计截图 / UI 参考图,配上你补的实现约束(用什么框架、路由怎么走、组件风格),以及图里看不出的行为说明。
一个能跑的原型:新路由 / 页面 + 需要的小组件 + 一份 README。让 Codex 起开发服务器,告诉你在哪个本地地址能看到。
codex (拖入截图后) Create a new dashboard based on this image. Constraints: - Use react, vite, and tailwind. Write the code in typescript. - Match spacing, typography, and layout as closely as possible. Outputs: - A new route/page that renders the UI - Any small components needed - README.md with instructions to run it locally (验证追问) Start the dev server and tell me the local URL/route to view the prototype. (IDE版,贴截图) Create a new settings page. Use the attached screenshot as the target UI. Follow design and visual patterns from other files in this project.
边改边看的 UI 迭代
想要「设计 → 微调 → 刷新 → 再调」的小步快跑时用它。一边跑开发服务器,一边用小而具体的指令一轮轮收敛。
codex npm run dev 第一轮:Propose 2-3 styling improvements for the landing page. 第二轮(选定方向后细化到具体元素):Go with option 2. Change only the header: - make the typography more editorial - increase whitespace - ensure it still looks good on mobile 第三轮(继续收敛):Next iteration: reduce visual noise. Keep the layout, but simplify colors and remove any redundant borders.
每轮改完在浏览器里看效果,喜欢就 commit,不喜欢就 revert。如果你手动改过或回退过某处,记得告诉 Codex,免得它下一轮把你的改动覆盖掉。
把重构委托给云端
想先用本地上下文设计方案,再把耗时的实现丢给云端并行跑时用它。关键在于:本地定好的方案能带着完整上下文迁到云端。
先在本地 IDE 用 $plan 让 Codex 调查代码、出一份方案,你反复修订到满意。切到云端环境时,Codex 会新建一个云端任务,把已有上下文(含方案和你本地的改动)一并带过去。云端在隔离环境里跑完,直接出 diff,你 review 后可以直接建 PR,也可以拉回本地测。有了方案后还能用 /goal 开 Goal mode,给它设一个持续追踪的长期目标,让它自己往下推进多步。
本地规划: $plan We need to refactor the auth subsystem to: - split responsibilities (token parsing vs session loading vs permissions) - reduce circular imports - improve testability Constraints: - No user-visible behavior changes - Keep public APIs stable - Include a step-by-step migration plan 修订计划: Revise the plan to: - specify exactly which files move in each milestone - include a rollback strategy 切到云端环境后: Implement Milestone 1 from the plan.
委托到云端的任务跑在隔离环境里,agent 阶段默认关网,除非你为该环境开了联网。里程碑 1 跑通后,再一个个推进后面的里程碑。
Codex 也能帮你审代码:本地一条命令,或 GitHub 里 @ 它
提交或建 PR 前想要第二双眼睛时,有两条路:本地用斜杠命令,或在 GitHub 评论区 @ 它。两条都能给定向聚焦指令,比如只看安全问题。
| 本地 /review | GitHub @codex review | |
|---|---|---|
| 什么时候用 | 提交 / 建 PR 前,自己先过一遍工作区 | 不想把分支拉到本地,直接在 PR 上要反馈 |
| 怎么触发 | Codex 里输入 /review | PR 评论区留言 @codex review |
| 定向聚焦 | /review Focus on... | @codex review for... |
| 前提 | 无,Codex 里直接用 | 先在仓库开启 Codex 的 Code review |
/review (定向聚焦) /review Focus on edge cases and security issues
@codex review (定向聚焦) @codex review for security vulnerabilities and security concerns
本地 review 完,按反馈改完再跑一遍 /review 确认问题都解了。
顺带一条:更新文档
需要一处准确、清楚的文档改动时,圈定要改的文件、说明范围,并要求它校验。
Update the "advanced features" documentation to provide authentication troubleshooting guidance. Verify that all links are valid.
怎么开始:先挑一个最简单的工作流(比如读懂代码库)试着跑通,再把这套写法复用到别的任务上。
写提示词不需要技术语法或固定公式。用你自己的话开头,看它的回应,再用跟进消息把结果一点点塑造成你要的样子。ChatGPT Learn · Prompting
ChatGPT 官方教你写提示词:从「把话说一半让 AI 猜」到「四件事说清,它就不跑偏」
OpenAI 官方指南:一套四要素框架统一 Chat、Work、Codex 三个界面,外加 9 套能直接抄的编程工作流,一页带图讲完。
↓ 一页读完 · 有一张会动的图
OpenAI 在官网发了一份提示词(你给 AI 的指令)指南,把散落各处的技巧收成一套,管着 ChatGPT 的三个界面:Chat(聊天)、Work(出成品文件)、Codex(写代码的模式)。它要治的,是普通人给 AI 下指令时的老毛病。
官方的答案是四件事:目标(要什么结果)、背景(给它哪些料)、输出(要什么格式)、边界(什么绝对不能碰)。按需选用,不必每项都填;其中「边界」最容易被漏,却最能防止跑偏和误操作。同一个活儿,说半句和说清楚,差别是这样的:
「帮我把这些会议记录整理一下。」
没说给谁看、要多长、什么不能改,AI 只能猜,结果常要返工重写。
一段话里四块齐了:做什么 · 用哪些料 · 什么放最前 · 什么不能动。一遍就能用。
这四块到底怎么揉进一句话、喂进去出结果,用小互的活儿走一遍。
小互手上有一次会议的记录,想整理成给团队看的更新。他要做的,就是把上面四块信息,拼成一句完整指令喂给 AI。
同一套原则落在三处:日常提问用 Chat,要成品文件用 Work,碰代码用 Codex。结果不满意也不用重写,直接说改哪一处;Codex 正在跑的时候还能追加消息,当场改方向(steer,插进正在跑的这轮)或排到下一轮(queue,排队等下一轮)。
Codex 尤其给了 9 套拆到命令级的工作流:读懂代码、修 bug、写测试、把截图变原型、边改边看调界面、把重构交给云端跑、审代码、更新文档,正文里每套都附了能直接抄的提示词。
4、3、9 这三个数字都出自 OpenAI 官方文档;正文里的英文 prompt 范例按原文原样保留,没有第三方评测。
给团队的更新,谢啦
- × 没说给谁看
- × 没说要多长
- × 没说什么不能碰
后……
预算也顺手改了
就不跑偏
都得填吗?
别发出去
现成流程可抄
Chat·Work·Codex
先做草稿,别发出去
该说的说清,
AI 就不跑偏
