BLOG


本文作者 Eric Provencher,在 OpenAI 负责 Codex 开发者体验(DX),此前是 Repo Prompt 的作者。原文是 OpenAI 官方文档中的 Prompting 指南,以下为逐段中英对照翻译


OpenAI 官方 Prompt 指南


learn.chatgpt.com/docs/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.


Prompt 就是你告诉 ChatGPT 你想知道什么、想做什么、想改什么。它可以是一个问题、一条指令,或者一个目标。你不需要技术语法,也不需要固定套路。用自己的话开头,看看回复,再用后续消息把结果修成你要的样子


A short prompt is often enough. For larger or more important tasks, include the parts that matter:


一句短 prompt 往往就够了。任务更大或更重要时,把关键的几块信息带上:


Goal: What should ChatGPT do?


目标(Goal):ChatGPT 该做什么?


Context: What information or sources will help?


上下文(Context):哪些信息或来源能帮上忙?


Output: What format, length, or level of detail do you need?


输出(Output):你需要什么格式、多长、多细?


Boundaries: What must stay unchanged? What should ChatGPT avoid or check with you before it acts?


边界(Boundaries):哪些东西不能动?哪些事 ChatGPT 该避开,或者动手前先来问你?


Use only the parts that help. You don’t need to fill in every item or follow a required format.


只用对你有帮助的部分就行。不需要每一项都填,也没有什么必须遵守的格式


描述你要的结果


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.


把可能改变结果的信息给它。只加真正相关的来源,并且说明每个来源里 ChatGPT 该取什么


Attach documents, spreadsheets, presentations, or PDF files when you want ChatGPT to summarize, compare, transform, or create files for review.


想让 ChatGPT 总结、比对、转换内容,或者生成待审阅的文件时,附上文档、电子表格、演示文稿或 PDF


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.


答案依赖最新信息时,让 ChatGPT 用网页搜索。需要核对结果时,让它给出来源


Use a project when related chats or tasks should share files, sources, or a local folder.


相关的对话或任务需要共享文件、来源或本地文件夹时,用 project 来组织


使用已连接的数据源


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.


当 ChatGPT 能访问已连接的数据源时,点名它该去哪找、找什么。不需要把每一次检索都描述出来


Use the latest project plan in Drive and relevant decisions and updates from the project’s Slack channel to prepare a status update.


用 Drive 里最新的项目计划,加上项目 Slack 频道里相关的决策和进展,准备一份状态通报


Connected sources require the matching plugin, and availability can depend on your plan and workspace settings.


已连接的数据源需要对应的插件,能不能用还取决于你的订阅方案和工作区设置


使用插件


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 从可用的工具里自己挑。想指定某个插件,在输入框里输入 @


个性化 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.


边界是那么几条指令,用来防止 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.


把消息准备成草稿,不要发出去


Focus on the one or two boundaries that matter most. You don’t need to control every step ChatGPT takes.


盯住最要紧的一两条边界就好。不需要控制 ChatGPT 走的每一步


让结果拿来就能用


Tell ChatGPT how you plan to use the result. This helps it choose the right length, level of detail, and organization.


告诉 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%.


做一张计划支出和实际支出的对照表,差异超过 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 收尾时做一次终检,比如确认每个行动项都有负责人和截止日期,或者把它没法核实的信息标出来。然后你自己再过一遍,再去用、再去分享


用追问改进结果


Your first prompt doesn’t need to be perfect. Review the result, then ask for the specific change you want.


第一条 prompt 不需要完美。看完结果,把你想要的具体改动说出来


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.


你可以补一个漏掉的来源、纠正方向、再要一个方案,或者调整详细程度,不用从头再来


Steer 与 Queue


When Codex is already working, you can send another message without waiting for the current run to finish:


Codex 干活的时候,你不用等当前这轮跑完,就能发下一条消息:


Steer adds the message to the current run. Use it to change direction, add a missing detail, or share new information.


Steer(转向)把消息加进当前这一轮。用来改方向、补细节、给新信息


Queue saves the message for the next run. Use it for a follow-up that should wait until the current work finishes.


Queue(排队)把消息留到下一轮。适合那些该等当前工作干完再说的追问


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.


在 ChatGPT 桌面应用里,默认行为在「设置 > 通用 > 追问行为」里选。排队中的消息显示在输入框上方,可以编辑、调整顺序、发送或删除。这个设置页还会显示一个快捷键,让你在不改默认的前提下,单条消息临时用另一种行为


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 CLI 里,Codex 工作时按 Enter 是 steer 当前这一轮,按 Tab 是把消息 queue 到下一轮。细节见交互快捷键文档


把这些拼在一起


For a project update that uses connected sources, a complete prompt might look like this:


一份用到已连接数据源的项目通报,完整的 prompt 大概长这样:


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.


为周一的管理层会议准备一份一页纸的项目状态通报。用 Drive 里最新的项目计划,加上项目 Slack 频道里相关的决策和进展。管理层需要拍板的决策和下一步行动放在最前面。总结进度、风险、负责人和截止日期。已批准的日期和预算数字保持不动。有冲突或缺失的信息就标出来,任何东西都不要发送或发布。收尾前,检查每个下一步都有负责人和截止日期


This prompt covers the Goal, Context, Output, and Boundaries, then asks for a final check without spelling out every step.


这条 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 会把你说的话转写进输入框,发送前可以检查和修改


OpenAI 官方 Prompt 指南


输入框里的语音听写指示条,转写好的 prompt 就在里面


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 适合提问、找点子、打草稿和日常决策。从你想要的结果说起,细节只在它会改变答案的时候再加


理解一个话题


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.


起草一封友好的邮件,婉拒这个邀请,理由是我届时在外出差。控制在 120 词以内,给以后的活动留个口子


比较选项


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.


规划五顿工作日晚餐,每顿 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.


快问快答、小段改写、头脑风暴、轻量草稿,用 Chat。需要调多个来源或工具、包含一串步骤、要做修改、或者要产出较大交付物的任务,用 Work


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.


Work 任务里,描述你要的结果,给出源材料,点名受众,说明你会怎么审这份活。让 ChatGPT 先规划、再收集所需信息、生成文件,收尾前自查一遍


高效使用 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.


Work 适合耗时的活、重复出现的活,以及能复用的成品文件。一个任务多花些 credits 也可能划算,只要它省了时间、提了质量,或者帮你做成了一个重要决定


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.


做法本身重要时,先要一份计划。ChatGPT 发送、发布或修改别人依赖的信息之前,必须经你批准


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.


审第一版结果,打磨指令,跑通了就复用这套流程


把源材料变成成品文件


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.


为一家 50 人的公司调研三个客服平台。用最新的资料比较定价、安全性、集成能力和迁移成本。产出一份推荐备忘录,附上链接、假设,以及签合同前我们该回答的问题


协调一次发布


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.


根据附件里的产品简报做一份发布计划。包含时间线、负责人、依赖项、风险、公告草稿、客户 FAQ 和发布日检查清单。产出最终文件之前,把还没定的决策标出来


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.


重复性的工作,先在普通任务里把 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.


想让 ChatGPT 处理代码、代码库或者开发者工具,用 Codex。一条有用的 Codex prompt 会写明你要的行为,指向相关代码或复现步骤,保住重要的约束,并说清怎么验证这次改动


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.


多步骤任务,想让 Codex 先调查、先提方案再动手改,就在应用输入框里输 /plan。Goal 模式可用时,计划定了之后用 /goal 设一个持续目标。当前的命令列表见应用的斜杠命令文档


怎么读这些示例


Each workflow includes:


每个工作流都包含:


When to use it and which Codex surface fits best (IDE, CLI, or cloud).


什么时候用,以及哪个 Codex 载体最合适(IDE、CLI 还是云端)


Steps with example user prompts.


步骤,配上用户 prompt 示例


Context notes: what Codex automatically sees vs what you should attach.


上下文说明:哪些是 Codex 自动能看到的,哪些需要你自己附上


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.


注意:IDE 插件会自动把你打开的文件带进上下文。CLI 里要显式提到路径,或者用 /mention 和 @ 路径补全来附文件


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 在一个限制文件和网络访问的沙箱(sandbox)里跑本地命令。任务需要越过这条边界时,Codex 会先按你的审批策略来,再继续


解释一个代码库


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.


1.打开最相关的文件


2. Select the code you care about (optional but recommended).


2.选中你关心的代码(可选,但推荐)


3. Prompt Codex:


3.给 Codex 下 prompt:


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.


把请求链路总结成一个带编号的步骤列表,然后列出涉及的文件


CLI 工作流(想要完整记录和 shell 命令时好用)


1. Start an interactive session:


1.启动一个交互会话:


codex


2. Attach the files (optional) and prompt:


2.附上文件(可选),然后下 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.


我需要理解这个服务用的协议。读一下 @foo.ts 和 @schema.ts,解释 schema 和请求 /响应链路。重点讲必填字段和可选字段