本文作者 Eric Provencher,现 OpenAI Codex 开发者体验(DX)负责人,Repo Prompt 工具的原作者。原文出自 OpenAI 官方文档中的 Prompting 指南,下文为逐段中英对照翻译与润色。

一、Prompting 是什么
Prompting is how you tell ChatGPT what you want to know, make, or change. A prompt can be a question, an instruction, or a goal. You don't need technical syntax or a rigid formula. Start in your own words, review the response, and use follow-up messages to shape the result.
A short prompt is often enough. For larger or more important tasks, include the parts that matter:
Goal: What should ChatGPT do?
Context: What information or sources will help?
Output: What format, length, or level of detail do you need?
Boundaries: What must stay unchanged? What should ChatGPT avoid or check with you before it acts?
Use only the parts that help. You don't need to fill in every item or follow a required format.
Prompt(提示词)是你跟 ChatGPT 沟通的方式——告诉它你想知道什么、想做什么、想改什么。一条 prompt 可以是个问题、一条指令,也可以是个目标。你不必套用技术语法,也不必硬记固定公式。先用自己的话开个头,看它的回复,再用追问把结果调成你想要的。
简短一句 prompt 通常就够了。任务更大或更重要时,把以下几块关键信息带上:
目标(Goal):希望 ChatGPT 做什么。
上下文(Context):哪些信息或资料能帮上忙。
输出(Output):你希望它用什么格式、多长、细致到什么程度。
边界(Boundaries):哪些东西不能动?哪些事 ChatGPT 应当避开,或者动手前先来问你?
挑对你有帮助的几项带上就行——不必每一项都填,也不存在什么必须遵守的格式。
二、描述你要的结果
Start with the result, not a detailed list of steps. Include the audience or format when those details change what ChatGPT should produce.
Turn these meeting notes into a short update for the project team.
Put the decisions and next steps first.
This prompt explains what to create and who will read it. Describe a process when the process itself matters. Otherwise, leave ChatGPT room to search, compare information, and adjust its approach.
从结果说起,别从一长串步骤说起。当读者或格式会影响产出时,把这些信息也写进去。
把这份会议纪要整理成一条简短的进展通报,发给项目组。 决策和下一步行动放在最前面。
这条 prompt 把要产出什么、给谁看都写清楚了。只有当过程本身很重要时,才去描述过程;其他时候,把搜索、比对、调整的空间留给 ChatGPT。
三、补充有用的上下文
Share the information that could change the result. Add only the sources that matter, and explain what ChatGPT should take from each one.
Attach documents, spreadsheets, presentations, or PDF files when you want ChatGPT to summarize, compare, transform, or create files for review.
Add a screenshot, diagram, or other image input when the task depends on visual context. Point out the area that matters instead of relying on the image alone.
Ask ChatGPT to use web search when the answer depends on current information, and ask for sources when you need to check the result.
Use a project when related chats or tasks should share files, sources, or a local folder.
把可能影响结果的信息给它。只挑真正相关的资料附上,并说明每个资料里 ChatGPT 该看什么。
想让 ChatGPT 总结、对比、转换内容,或者产出待审阅的文件时,附上文档、表格、演示稿或 PDF。
任务依赖视觉信息时,加一张截图、示意图或其他图片。同时指出图里关键的那块区域——别光丢一张图过去。
答案依赖最新信息时,让 ChatGPT 开启联网搜索。需要核实结果时,让它附上信息来源。
相关的对话或任务需要共享文件、信息源或本地文件夹时,用 project 来组织。
3.1 用已连接的数据源
When ChatGPT has access to connected sources, name where it should look and what it should find. You don't need to describe every search it should run.
Use the latest project plan in Drive and relevant decisions and updates from the project's Slack channel to prepare a status update.
Connected sources require the matching plugin, and availability can depend on your plan and workspace settings.
ChatGPT 能访问已连接的数据源时,指明它该去哪里找、找什么,不必把每次搜索都写出来。
用 Drive 里最新的项目计划,加上项目 Slack 频道里相关的决策和进展,整理一份状态通报。
已连接的数据源需要对应插件,能否使用还取决于你的订阅方案和工作区设置。
3.2 用插件
Plugins give ChatGPT reusable instructions and connections to tools such as Google Drive, Gmail, Slack, and GitHub. Ask for the result you need and let ChatGPT choose from the tools available to it. To choose a specific plugin, type @ in the composer.
插件给 ChatGPT 提供两类能力:可复用的指令,以及到 Google Drive、Gmail、Slack、GitHub 这类工具的连接。直接说你要的结果,让 ChatGPT 从可用的工具里自己挑。想指定某个插件,在输入框里敲 @。
3.3 个性化 ChatGPT
Put preferences that should apply across chats and tasks in Settings > Personalization as custom instructions. Keep details that matter only to the current task in the prompt.
想在所有对话和任务里都生效的偏好,写到「设置 > 个性化」里的自定义指令中;只对当前任务有用的细节,写在 prompt 里。
四、设定能防住真麻烦的边界
Boundaries are the few instructions ChatGPT needs to avoid creating extra work or taking an action you didn't intend. Add one when changing the wrong detail would make the result unusable, or when you want to review something before it affects other people.
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.
Focus on the one or two boundaries that matter most. You don't need to control every step ChatGPT takes.
边界是那么几条护栏,用来防止 ChatGPT 制造额外工作,或做出你没想让它做的动作。什么时候加一条?改错一个细节结果就没法用的时候;或某件事影响别人之前,你想先过目的时候。
已批准的日期和预算数字,保持不动。
只用我给的资料。缺信息就标出来,不要猜。
建议控制在既定预算内。
消息先写成草稿,不要发出去。
盯住最要紧的一两条边界即可,不必把 ChatGPT 走的每一步都管起来。
五、让结果拿来就能用
Tell ChatGPT how you plan to use the result. This helps it choose the right length, level of detail, and organization.
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%.
For important work, ask ChatGPT for a final check, such as confirming every action item has an owner and due date or flagging information it couldn't verify. Then review the result yourself before you use or share it.
告诉 ChatGPT 你打算怎么用这个结果,它就能挑对长度、详细程度和组织方式。
做成一页纸的摘要,让总监开会前扫一眼就行。决策和下一步放在最前面。
把这些笔记整理成一封跟进邮件,写明决策、负责人、截止日期。
做一张计划支出 vs 实际支出的对照表,差异超过 10% 的都标出来。
重要的工作,让 ChatGPT 收尾时做一次终检——比如确认每个行动项都有负责人和截止日期,或者把没能核实的信息标出来。终检完之后,自己再过一遍,再去用、再去分享。
六、用追问改进结果
Your first prompt doesn't need to be perfect. Review the result, then ask for the specific change you want.
Make the opening more direct, keep the evidence, and move the recommendation above the background section.
You can add a missing source, correct the direction, ask for another option, or change the level of detail without starting over.
第一条 prompt 不必完美。看完结果,把你想要的具体改动说出来。
开头写得更直接一些。证据保留,但把建议挪到背景部分之前。
可以补一个漏掉的来源、纠正方向、再要一个方案,或者调整详细程度——不必从头再来。
6.1 Steer 与 Queue
When Codex is already working, you can send another message without waiting for the current run to finish:
Steer adds the message to the current run. Use it to change direction, add a missing detail, or share new information.
Queue saves the message for the next run. Use it for a follow-up that should wait until the current work finishes.
In the ChatGPT desktop app, choose the default under Settings > General > Follow-up behavior. Queued messages appear above the composer, where you can edit, reorder, send, or delete them. The setting also shows the shortcut for using the other behavior for one message without changing your default.
In Codex CLI, press Enter while Codex is working to steer the current turn, or press Tab to queue the message for the next turn. See the interactive shortcuts for details.
Codex 还在干活时,不必等当前这轮跑完,你就能发下一条消息:
Steer(转向):把消息合进当前这一轮。适合临时改方向、补细节、塞新信息。
Queue(排队):把消息留到下一轮。适合那些该等当前工作干完再说的追问。
在 ChatGPT 桌面应用里,默认行为在「设置 > 通用 > 追问行为」里选。排队中的消息会显示在输入框上方,可以编辑、调整顺序、发送或删除。这个设置页还会显示一个快捷键,让你在不改动默认的情况下,让单条消息临时使用另一种行为。
在 Codex CLI 里,Codex 工作时按 Enter 是 Steer 当前这一轮,按 Tab 是把消息 Queue 到下一轮。细节见交互快捷键文档。
七、把以上几块拼在一起
For a project update that uses connected sources, a complete prompt might look like this:
Prepare a one-page project status update for Monday's leadership meeting. Use the latest project plan in Drive and relevant decisions and updates from the project's Slack channel.
Lead with the decisions leadership needs to make and the next steps. Summarize progress, risks, owners, and due dates. Keep approved dates and budget figures unchanged. Flag any conflicting or missing information, and don't send or publish anything.
Before you finish, check that every next step has an owner and due date.
This prompt covers the Goal, Context, Output, and Boundaries, then asks for a final check without spelling out every step.
一份用到已连接数据源的项目通报,完整的 prompt 大概长这样:
为周一的管理层会议准备一份一页纸的项目状态通报。用 Drive 里最新的项目计划,加上项目 Slack 频道里相关的决策和进展。
开头先写管理层需要拍板的决策和下一步行动。再总结进度、风险、负责人、截止日期。已批准的日期和预算数字保持不动。有冲突或缺失的信息标出来,任何东西都不要发送或发布。
收尾前,确认每个「下一步」都有负责人和截止日期。
这条 prompt 覆盖了目标、上下文、输出、边界四要素,并要求做一次终检,但没有把每一步都写死。
八、用语音听写
In the ChatGPT desktop app, hold Ctrl+M while the composer is visible, then start talking. ChatGPT transcribes your speech into the composer so you can review and edit it before sending the prompt.
在 ChatGPT 桌面应用里,输入框可见时按住 Ctrl+M,然后开口说话。ChatGPT 会把你的语音转写到输入框里,发送前你可以检查、修改。
九、Chat 的 prompt 示例
Use Chat for questions, ideas, drafts, and everyday decisions. Start with the outcome you want, then add detail only when it changes the answer.
Chat 适合提问、找点子、打草稿、做日常决策。从你想要的结果说起,细节只在它会影响答案时才加。
9.1 理解一个话题
Explain how compound interest works for someone who has never invested.
Use one concrete example and define any financial terms you introduce.
给一个从没投资过的人讲清楚复利是怎么回事。用一个具体的例子,引入的金融术语都给出定义。
9.2 起草和打磨文字
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.
起草一封友好的邮件,婉拒这个邀请,理由是我届时在外出差。控制在 120 词以内,给以后的活动留个口子。
9.3 比较选项
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.
帮一个每年出国两次的人比较这两个手机套餐。重要差异用表格列出来,然后推荐一个,并说明代价在哪里。
9.4 做一个实用的计划
Plan five weekday dinners that take less than 30 minutes. Avoid peanuts, reuse ingredients across meals, and finish with one consolidated shopping list.
规划五顿工作日晚餐,每顿 30 分钟以内做完。避开花生,食材尽量跨餐复用,最后汇总成一张购物清单。
十、Work 的 prompt 写法
Use Chat for quick questions, short rewrites, brainstorming, and lightweight drafts. Use Work for tasks that draw on different sources or tools, involve a sequence of steps, make changes, or produce a larger deliverable.
For Work tasks, describe the result you need, provide the source material, name the audience, and explain how you'll review the work. Ask ChatGPT to plan, gather the needed information, create files, and check them before it finishes.
快问快答、小段改写、头脑风暴、轻量草稿,用 Chat。需要调多个来源或工具、包含一连串步骤、要做修改、或者要产出较大交付物的任务,用 Work。
Work 任务里:说清楚要的结果,给出源材料,点名受众,说明你会怎么审。让 ChatGPT 先规划,再去收集所需信息、产出文件,收尾前自己先检查一遍。
10.1 高效用 Work
Work is useful for time-consuming or recurring tasks, or for finished files you can reuse. A task that uses more credits can still be worthwhile if it saves time, improves quality, or helps you make an important decision.
Start with one result you can review:
Include only relevant sources and limit the date range when appropriate.
Define the audience, output format, and desired length.
Separate required work from optional improvements or polish.
Ask for a plan when the approach matters. Require your approval before ChatGPT sends, publishes, or changes information other people rely on.
Narrow or stop the task if it starts doing work you no longer need.
Review the first result, refine the instructions, and reuse the workflow when it works.
Work 适合耗时的活、重复出现的活,以及能复用的成品文件。一个任务多花一些 credits 也可能划算——只要它省了时间、提了质量,或者帮你做成了一个关键决策。
从一个你审得过来的结果开始:
只带相关的资料,合适的话限定一下时间范围。
定好受众、输出格式、期望长度。
把必须做的事和可选的优化、润色分开。
做法本身重要时,先要一份计划。ChatGPT 在发送、发布或修改别人依赖的信息之前,必须先经你批准。
它开始干你不再需要的活时,及时收窄任务,或者直接叫停。
审第一版结果,打磨指令,跑通了就复用这套流程。
10.2 把源材料变成成品文件
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.
用附件里的季度报告,做一份管理层简报和一份 6 页的演示文稿。
受众是高管团队。开头先写他们需要拍板的三个决策,报告里事实和你的分析要分清,每个数字都注明来源文件,收尾前检查简报和幻灯片口径一致。
10.3 为一个决策做调研
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.
为一家 50 人的公司调研三个客服平台。用最新资料比较定价、安全性、集成能力、迁移成本。产出一份推荐备忘录,附上链接、假设,以及签合同前我们该回答的问题。
10.4 协调一次发布
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.
For recurring work, first refine the prompt in a normal task. After the output is reliable, schedule work from that task. Create a standalone scheduled task instead when each scheduled run should start a new task.
根据附件里的产品简报做一份发布计划。包含时间线、负责人、依赖项、风险、公告草稿、客户 FAQ、发布日检查清单。产出最终文件之前,把还没定的决策标出来。
重复性的工作,先在普通任务里把 prompt 打磨好;输出稳定之后,从那个任务里设置定时执行。如果每次定时运行都该新开一个任务,就单独建一个定时任务。
十一、Codex 的 prompt 写法
Use Codex when you want ChatGPT to work with code, a codebase, or developer tools. A useful Codex prompt names the behavior you want, points to the relevant code or reproduction steps, preserves important constraints, and says how to verify the change.
For a multi-step task, enter /plan in the app composer when you want Codex to investigate and propose an approach before editing. When Goal mode is available, use /goal after the plan to set a persistent goal. See the app slash commands for the current command list.
想让 ChatGPT 处理代码、代码库或开发者工具,用 Codex。一条好用的 Codex prompt 会写明:要的行为、相关的代码或复现步骤、不能动的约束、以及怎么验证这次改动。
多步骤任务,想让 Codex 先调查、先提方案再动手改,就在应用输入框里输入 /plan。Goal 模式可用时,计划定了之后用 /goal 设一个持续目标。当前的斜杠命令列表见应用文档。
11.1 怎么读这些示例
Each workflow includes:
When to use it and which Codex surface fits best (IDE, CLI, or cloud).
Steps with example user prompts.
Context notes: what Codex automatically sees vs what you should attach.
Verification: how to check the output.
Note: The IDE extension automatically includes your open files as context. In the CLI, mention paths explicitly, or attach files with /mention and @ path autocomplete.
Codex runs local commands inside a sandbox that limits file and network access. If a task needs to cross that boundary, Codex follows your approval policy before continuing.
每个工作流都包含:
什么时候用,以及哪个 Codex 载体最合适(IDE、CLI 还是云端)。
步骤,配上用户 prompt 示例。
上下文说明:哪些是 Codex 自动能看到的,哪些需要你自己附上。
验证方式:怎么检查产出。
注意:IDE 插件会自动把你打开的文件带进上下文;CLI 里要显式写路径,或者用 /mention 和 @ 路径补全来附文件。
Codex 在一个限制文件和网络访问的沙箱(sandbox)里跑本地命令。任务需要越过这条边界时,Codex 会先按你的审批策略来,再继续。
11.2 解释一个代码库
Use this when you are onboarding, inheriting a service, or trying to reason about a protocol, data model, or request flow.
适用场景:刚加入项目、接手一个服务,或者想弄清楚某个协议、数据模型、请求链路。
IDE 插件工作流(本地探索最快)
1. Open the most relevant files.
2. Select the code you care about (optional but recommended).
3. Prompt 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
Verification: Ask for a diagram or checklist you can verify:
Summarize the request flow as a numbered list of steps. Then list the files involved.
- 打开最相关的文件。
- 选中你关心的代码(可选,但推荐)。
- 给 Codex 下 prompt:
解释请求是怎么流经这段选中代码的。
包含:涉及每个模块的职责简述;数据在哪里校验;改这段代码时要留神的一两个坑。
验证方式:让它给一份你能核对的图或清单:
把请求链路总结成一个带编号的步骤列表,然后列出涉及的文件。
CLI 工作流(想要完整记录和 shell 命令时更好用)
1. Start an interactive session:
2. Attach the files (optional) and prompt:
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.
Context notes: You can use @ in the composer to insert file paths from the workspace, or /mention to attach a specific file.
- 启动一个交互会话:
- 附上文件(可选),然后下 prompt:
我需要理解这个服务用的协议。读一下@foo.ts和@schema.ts,解释 schema 和请求/响应链路。重点讲必填字段和可选字段的区别,以及向后兼容的规则。
上下文说明:输入框里可以用 @ 插入工作区的文件路径,或者用 /mention 附上指定文件。
11.3 修一个 bug
Use this when you have a failing behavior you can reproduce locally.
适用场景:你手头有一个能在本地复现的异常行为。
CLI 工作流(复现和验证的闭环最紧)
1. Start Codex at the repo root:
2. Give Codex a reproduction recipe, plus the file(s) you suspect:
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.
Context notes:
Supplied by you: the repro steps and constraints (these matter more than a high-level description).
Supplied by Codex: command output, discovered call sites, and any stack traces it triggers.
Verification: Codex should re-run the repro steps after the fix. If you have a standard check pipeline, ask it to run it:
After the fix, run lint + the smallest relevant test suite. Report the commands and results.
- 在仓库根目录启动 Codex:
- 给 Codex 一份复现配方,加上你怀疑的文件:
Bug:在设置页点「保存」,有时显示「已保存」,但改动没有真正落盘。
复现步骤:
1)启动应用:npm run dev。
2)打开/settings。
3)切换「启用提醒」开关。
4)点保存。
5)刷新页面:开关弹回去了。
约束:不改动 API 的形状。修复保持最小化,可行的话加一个回归测试。
先在本地复现这个 bug,然后提出补丁并跑检查。
上下文说明:
你提供:复现步骤和约束(这比一段高层描述有用得多)。
Codex 提供:命令输出、找到的调用点,以及它触发的堆栈信息。
验证方式:修完之后,Codex 应该重跑一遍复现步骤。如果你有标准的检查流水线,让它跑一下:
修完之后,跑 lint 加上最小相关的测试集。报告用了哪些命令、结果如何。
IDE 插件工作流
1. Open the file where you think the bug lives, plus its nearest caller
2. Prompt Codex:.
Find the bug causing "Saved" to show without persisting changes. After proposing the fix, tell me how to verify it in the UI.
- 打开你觉得 bug 所在的文件,以及离它最近的调用方。
- 给 Codex 下 prompt:
找到那个显示「已保存」却没真正保存的 bug。提出修复方案后,告诉我怎么在界面上验证。
11.4 写一个测试
适用场景:你想精确圈定要测的范围。
IDE 插件工作流(基于选中代码)
1. Open the file with the function.
2. Select the lines that define the functioFind the bug causing "Saved" to show without persisting changes. After proposing the fix, tell me how to verify it in the UI.
3. Prompt Codex:
Write a unit test for this function. Follow conventions used in other tests.
- 打开包含那个函数的文件。
- 选中定义这个函数的那几行。在命令面板里选「Add to Codex Thread」,把这几行加进上下文。
- 给 Codex 下 prompt:
给这个函数写一个单元测试,遵循其他测试里的惯例。
上下文说明:「Add to Codex Thread」命令提供:选中的那几行(即「行号」级别的范围),加上已打开的文件。
CLI 工作流(在 prompt 里写路径和行范围)
1. Start Codex:
2. Prompt with a function name:
Add a test for the invert_list function in @transform.ts. Cover the happy path plus edge cases.
- 启动 Codex:
- 在 prompt 里点名函数:
给@transform.ts里的invert_list函数加一个测试。覆盖正常路径,加几个边界情况。
11.5 从一张截图做原型
Use this when you want to turn a design mock, screenshot, or UI reference into a working prototype.
适用场景:想把设计稿、截图或界面参考图变成能跑的原型。
CLI 工作流(图 + prompt)
1. Save your screenshot locally (for example ./specs/ui.png).
2. Run Codex:
3. Drag the image file into the terminal to attach it to the prompt.
4. Follow up with constraints and structure:
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
Context notes:
The image provides visual requirements, but you still need to specify the implementation constraints (framework, routing, component style).
Include behavior the image doesn't show in text, such as hover states, validation rules, or keyboard interactions.
Verification:
Ask Codex to run the dev server (if allowed) and tell you exactly where to look:
Start the dev server and tell me the local URL/route to view the prototype.
- 把截图存到本地(比如
./specs/ui.png)。 - 运行 Codex:
把图片文件拖进终端,附到 prompt 上。 - 接着给出约束和结构:
- 照这张图做一个新的 dashboard。
约束:用 react、vite 和 tailwind,代码写 typescript。间距、字体、布局尽量贴近原图。
产出:一个渲染这个界面的新路由/页面;需要用到的小组件;一份README.md,写明本地怎么跑起来。
上下文说明:
图片给的是视觉要求,实现层面的约束(框架、路由、组件风格)还得你自己写清楚。
图里看不出来的行为要用文字补上,比如悬停状态、校验规则、键盘交互。
验证方式:让 Codex 把开发服务器跑起来(如果允许的话),并告诉你具体看哪里:
启动开发服务器,告诉我本地哪个 URL/路由能看到原型。
IDE 插件工作流(图 + 已有文件)
1. Attach the image in the Codex task (drag-and-drop or paste).
2. Prompt Codex:
Create a new settings page. Use the attached screenshot as the target UI.
Follow design and visual patterns from other files in this project.
- 在 Codex 任务里附上图片(拖拽或粘贴都行)。
- 给 Codex 下 prompt:
做一个新的设置页。以附件截图为目标界面,遵循这个项目里其他文件的设计和视觉模式。
11.6 边看边改,迭代 UI
Use this when you want a tight "design → tweak → refresh → tweak" loop while Codex edits code.
适用场景:想要一个「设计 → 微调 → 刷新 → 再微调」的紧凑循环,Codex 在旁边改代码。
CLI 工作流(先跑 Vite,再用小 prompt 迭代)
1. Start Codex:
2. Start the dev server in a separate terminal window:
3. Prompt Codex to make changes:
Propose 2-3 styling improvements for the landing page.
4. Pick a direction and iterate with small, specific prompts:
Go with option 2.
Change only the header: – make the typography more editorial – increase whitespace – ensure it still looks good on mobile
5. Repeat with focused requests:
Next iteration: reduce visual noise.
Keep the layout, but simplify colors and remove any redundant borders.
Verification:
Review changes in the browser as Codex updates the code.
Commit changes that you like and revert those that you don't.
If you revert or change an edit, tell Codex so it doesn't overwrite your edit when it works on the next prompt.
- 启动 Codex:
- 另开一个终端窗口,启动开发服务器:
- 让 Codex 提改动:
给落地页提两三个样式改进方案。 - 挑一个方向,用小而具体的 prompt 迭代:
就按方案二来。
只改头部:字体排印做得更有杂志感。留白加大。保证移动端依然好看。 - 用聚焦的请求重复这个过程:
下一轮:降低视觉噪音。布局保持,颜色做减法,多余的边框都去掉。
验证方式:
Codex 改代码的同时,在浏览器里看效果。
喜欢的改动就提交,不喜欢的就回滚。
你回滚或者手改了某处,要告诉 Codex,免得它跑下一条 prompt 时把你的修改覆盖掉。
11.7 把重构交给云端
Use this when you want to design an approach with local context, then delegate the long implementation to a cloud task that can run in parallel.
适用场景:想借助本地上下文把方案设计好,再把漫长的实现交给一个能并行跑的云端任务。
本地规划(IDE)
1. Make sure your current work is committed or at least stashed so you can compare changes cleanly.
2. Ask Codex to produce a refactor plan. If you have the $plan skill available, invoke it explicitly:
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
3. Review the plan and negotiate changes:
Revise the plan to: – specify exactly which files move in each milestone – include a rollback strategy
Context notes: Planning works best when Codex can scan the current code locally (entrypoints, module boundaries, dependency graph hints).
- 确保手头的工作已经提交,至少 stash 起来,之后才能干净地比对改动。
- 让 Codex 出一份重构计划。如果有
$plan这个 skill,显式调用它:
我们要重构鉴权子系统,目标:拆分职责(token 解析、会话加载、权限各归各位)。减少循环引用。提升可测试性。
约束:用户可见的行为不变。公开 API 保持稳定。给出分步骤的迁移计划。 - 审这份计划,跟它讨价还价:
修改计划:每个里程碑具体动哪些文件,写清楚;再加一份回滚策略。
上下文说明:规划这一步,Codex 能在本地扫当前代码时效果最好(入口、模块边界、依赖图线索)。
云端委派(IDE → 云端)
1. If you haven't already done so, set up a Codex cloud environment.
2. Click on the cloud icon beneath the prompt composer and select your cloud environment.
3. When you enter the next prompt, Codex creates a new task in the cloud that carries over the existing task context (including the plan and any local source changes).
Implement Milestone 1 from the plan.
4. Review the cloud diff, iterate if needed.
5. Create a PR directly from the cloud or pull changes locally to test and finish up.
6. Iterate on additional milestones of the plan.
Tasks delegated to the cloud run in isolated environments. Internet access is off during the agent phase unless you enable it for the environment. Learn more about cloud internet access.
- 还没配的话,先配一个 Codex 云环境。
- 点输入框下方的云图标,选中你的云环境。
- 你输入下一条 prompt 时,Codex 会在云端新建一个任务,带上现有任务的上下文(包括计划和本地的源码改动)。
- 实现计划里的里程碑一。
审云端的 diff,需要就再迭代。 - 直接从云端建 PR,或者把改动拉到本地测试收尾。
- 按计划推进后续里程碑。
交给云端的任务在隔离环境里跑。Agent 执行阶段默认断网,除非你给这个环境开了网络。细节见云端网络访问文档。
11.8 做一次本地 code review
Use this when you want a second set of eyes before committing or creating a PR.
适用场景:提交或建 PR 之前,想找双眼睛帮你把把关。
CLI 工作流(审查你的工作区)
1. Start Codex:
2. Run the review command:
3. Optional: provide custom focus instructions:
Verification: Apply fixes based on review feedback, then rerun /review to confirm you resolved the issues.
- 启动 Codex:
- 跑审查命令:
- 可选:给出自定义的关注点:
验证方式:按审查反馈修完,再跑一遍/review,确认问题都解决了。
11.9 审一个 GitHub PR
Use this when you want review feedback without pulling the branch locally.
Before you can use this, enable Codex Code review on your repository. See Code review.
适用场景:不想把分支拉到本地,也想拿到审查反馈。
用之前,先在你的仓库上启用 Codex 的 Code review 功能。详见 Code review 文档。
GitHub 工作流(靠评论驱动)
1. Open the pull request on GitHub.
2. Leave a comment that tags Codex with explicit focus areas:
3. Optional: Provide more explicit instructions.
@codex review for security vulnerabilities and security concerns
- 在 GitHub 上打开那个 PR。
- 留一条评论 @ Codex,写明关注点:
- 可选:给更明确的指令。
@codex review 重点审安全漏洞和安全隐患
11.10 更新文档
Use this when you need an accurate, clear documentation change.
适用场景:需要一次准确、清晰的文档修改。
IDE 或 CLI 工作流(本地改 + 本地验证)
1. Identify the doc file(s) to change and open them (IDE) or @ mention them (IDE or CLI).
2. Prompt Codex with scope and validation requirements:
Update the "advanced features" documentation to provide authentication troubleshooting guidance. Verify that all links are valid.
3. After Codex drafts the changes, review the documentation and iterate as needed.
Verification: Read the rendered page.
- 找到要改的文档文件,打开它们(IDE),或者用
@提到它们(IDE 和 CLI 都行)。 - 给 Codex 下 prompt,写明范围和验证要求:
更新「高级功能」文档,补充鉴权排障指引。检查所有链接都有效。 - Codex 起草完改动之后,审一遍文档,需要就继续迭代。
验证方式:读一遍渲染后的页面。
写在最后
这一篇是 OpenAI 官方 Prompting 指南的中英对照润色版。如果你懒得逐条对照英文原文,只看中文也完全够用——但还是建议偶尔扫一眼英文原段,因为有些术语(比如 Steer / Queue / $plan / composer)官方一直保留英文用法。
作者 Eric Provencher 是 OpenAI Codex DX 负责人、Repo Prompt 工具的原作者,他的写作风格本身就很工程师化。这份指南的好处是:没有空话、每条建议都给得出具体的 prompt 模板,比市面上那些「学会 5 个 prompt 技巧让你成为 AI 沟通高手」的文章实在得多。
如果你是用 ChatGPT 写邮件、做计划、查资料——读前面「Chat / Work」两节就够。如果你是开发者,Codex 那 9 个工作流(解释代码库、修 bug、写测试、从截图做原型、迭代 UI、把重构交给云端、本地 code review、审 GitHub PR、更新文档)才是真正的干货。