OpenAI's Official Guide: 9 Copy-Ready Codex Prompt Workflows for Fixing Bugs, Turning Screenshots into Prototypes, and Cloud Refactors

OpenAI rolled the prompting tips scattered across its product pages into one framework: goal, context, output, boundaries — plus workflow examples built specifically for Codex.
By ChatGPT Learn07-11 · 9 min read⚑ Tutorial / how-to
🎧 Listen to the podcast0:00 / --:--
0:00 / --:--
Deep Dive · XiaoHu Explains
Quick take
  • ChatGPT's official prompting guide covers three surfaces: Chat, Work, and Codex.
  • The core is a four-element framework: goal, context, output, boundaries. Use what you need — you don't have to fill in every element.
  • For Codex, it gives 9 concrete workflows: understanding a codebase, fixing bugs, writing tests, turning a screenshot into a prototype, iterating on UI with live preview, delegating refactors to the cloud, two paths for code review, and updating docs — each with a copy-paste-ready prompt.
  • While Codex is running, you can send follow-up messages: steer to redirect the current task mid-run, or queue to save it for the next turn.
  • A refactor plan you worked out locally in your IDE can carry its full context straight over to a cloud environment to keep executing.
⚑This is an official OpenAI document (learn.chatgpt.com) on prompting methodology. The methods and examples below all come from OpenAI's official material, and every prompt example is preserved exactly as written for you to copy directly.
1Framework

No template to memorize: four elements, fill in only what matters

OpenAI's team published an official prompting guide at learn.chatgpt.com laying out exactly how to write prompts across three surfaces: Chat, Work, and Codex.

Its core is a four-element framework: goal, context, output, boundaries. You don't need to memorize a fixed syntax, and you don't need to fill in every element — just write the ones that will actually change the result.
🎯

One set of principles unifies how you write for Chat, Work, and Codex, and pairs it with 9 command-level, copy-ready workflows for Codex. A short task just needs a sentence; only big tasks need the full set of elements.

4
Optional framework elements: goal / context / output / boundaries
3
Surfaces covered: Chat / Work / Codex
9
Concrete Codex workflow examples given
Goal GOAL what to achieve Context CONTEXT what info to give it Output OUTPUT format / length / detail Boundaries BOUNDARIES what not to touch Assembles into one complete, ready-to-use prompt Use as needed · a short task is one sentence · big tasks need the full set
Four blocks assembled as needed: goal is mandatory; context, output, and boundaries get filled in only when they'd change the result

Say what result you want first — don't jump to listing steps

Start from the result you want, spell out the audience and format, and leave the rest — how to search, compare, and adjust — to ChatGPT. Only describe the process itself when the process actually matters.

Goal example · one sentence for what and for whom
Turn these meeting notes into a short update for the project team.
Put the decisions and next steps first.

Say what the result is for, and it'll pick the right length and detail on its own

The trick with the "output" element: tell ChatGPT how you plan to use the result, and it can choose the right length, level of detail, and structure on its own. For anything that matters, you can also ask for a final check at the end — say, confirming every action item has an owner and a deadline, or flagging anything it couldn't verify — and then review it yourself.

Output example · three ways to spell out "what it's for"
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%.

Last is the element in the four that's easiest to forget: boundaries.

Boundaries · the one most often skipped

Boundaries are the instructions that stop ChatGPT from making things worse or acting on its own. The rule of thumb is simple: add one whenever "getting a single detail wrong would make the result unusable," or when "an action affects someone else and you want to review it first." Nail down the one or two that matter most — you don't need to lock down every step.

Boundaries example · four phrases that save you the most often
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.
2Context

Feeding it the right context: files, screenshots, web search, connected apps

"Context" is any information that would change the result. The rule is: give it only relevant sources, and say clearly what to pull from each one. Here are the main ways to feed it context:

MethodWhen to use it
Upload docs / spreadsheets / slides / PDFsWhen you want it to summarize, compare, rewrite, or produce a file you can review
Screenshots / diagrams / imagesWhen the task depends on visual information. Add a sentence pointing to the specific part of the image — don't just drop an image with nothing else
Web searchWhen the answer depends on current information. If you need to verify results, also ask it to cite its sources
Connected data sources (Drive / Slack, etc.)Name where to look and what to find — no need to describe every single lookup
Connected data source example · name where to look and what to pull
Use the latest project plan in Drive and relevant decisions and updates from
the project's Slack channel to prepare a status update.

Connected data sources need the matching plugin installed, and whether you can use them depends on your plan and workspace settings. To point at a specific plugin, type @ in the input box and pick it. One more distinction worth keeping straight: preferences that apply every time (default tone, habits) belong in the custom instructions under "Settings > Personalization"; details that only matter for this one task belong in that task's prompt.

3Iteration

Don't rewrite when the result's off: follow-up messages, plus steer vs. queue

Your first prompt doesn't need to nail it in one shot. Look at the result, say exactly what to change, and you can add sources, correct direction, swap versions, or adjust detail level — without starting over.

Follow-up message example · what to change, what to keep, where to move it
Make the opening more direct, keep the evidence, and move the recommendation
above the background section.

Codex adds another layer: while it's running, you can send another message, and where it lands depends on how you send it.

An analogy

Think of it like the chef already cooking your order. Calling out "steer" means change the ingredients right now — this plate gets made with the new instructions. Calling out "queue" means finish this plate first, then bring out the one you just added.

In progress
Codex is running turn 1 of the task.
You send a follow-up message
Press Enter (CLI), and the message cuts into the turn that's currently running.
Redirected on the spot
Turn 1 finishes with your new instructions and new details folded in — redirected right then and there.
In progress
Codex is running turn 1 of the task.
You send a follow-up message
Press Tab (CLI), and the message queues up without interrupting the current work.
Finishes as planned
Turn 1 is unaffected and finishes exactly as planned.
Handled next turn
When turn 2 starts, it picks up your queued message and works on it then.

In the desktop app, the default behavior is set under "Settings > General > Follow-up behavior"; queued messages show above the input box, where you can edit, reorder, send, or delete them. In Codex CLI, while it's running, Enter steers the current turn and Tab queues for the next one. Worth noting: the desktop app also supports voice dictation — hold Ctrl + M to talk, and what you say gets transcribed into the input box for you to review and edit before sending.

4Worked example

One full example: mapping the four elements onto a real prompt

The four elements aren't rigid boxes. Below is a real, complete prompt with four colors marking which sentences are goal, context, output, and boundaries — one look and you'll see how they weave into a single passage.

Goal Context Output Boundaries
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.

Breakdown: [Goal] Prepare a one-page project status update for Monday's leadership meeting. [Context] Use the latest project plan in Drive plus relevant decisions and updates from the project's Slack channel. [Output] Lead with the decisions leadership needs to make and the next steps, then summarize progress, risks, owners, and due dates. [Boundaries] Keep approved dates and budget figures unchanged; flag any conflicting or missing information; don't send or publish anything. [Boundaries · final check] Before finishing, check every next step has an owner and a due date.

It covers goal, context, output, and boundaries, with a final check tacked on at the end — but it doesn't spell out every single step. That's what "assemble as needed" looks like for the four elements.

5Chat vs. Work

Everyday questions go to Chat, finished deliverables go to Work

Chat is for asking questions, brainstorming, drafting, and everyday decisions — start from the result you want, then add detail as needed. Work is for tasks that pull from multiple sources or tools, run multiple steps, or produce a larger finished file. Below are official examples, each ready to copy and adapt.

Chat: four examples for everyday questions

Explaining a concept to a non-expert
Explain how compound interest works for someone who has never invested.
Use one concrete example and define any financial terms you introduce.
Drafting an email with a fixed tone and length
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.
Comparing options in a table, then recommending one
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.
Making a practical plan under constraints
Plan five weekday dinners that take less than 30 minutes. Avoid peanuts, reuse
ingredients across meals, and finish with one consolidated shopping list.

Work: three examples for finished deliverables

Turning source files into an executive brief + slide deck
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.
Researching and producing a decision memo with assumptions and open questions
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.
Coordinating the full material set for a product launch
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.

Tips for using Work: start with a small result you can actually review, keep the source range tight and dates specific, and separate the must-do work from optional polish. When the process itself matters, have it draft a plan first, and require your approval before it sends, publishes, or changes information others depend on. Once a workflow like this is working, reuse it going forward — and for repetitive work, you can set it to run automatically on a schedule right from that task.

Related on this site
OpenAI Launches ChatGPT Work, Powered by GPT-5.6 — Produces Docs, Spreadsheets, and Slides Across Tools
XiaoHu's explainer site already covered what the Work surface is and what it can do in full, in a previous article — we won't repeat that here.
6Codex Basics

Codex's three fundamentals: understanding code, fixing bugs, writing tests

Use Codex whenever you want ChatGPT working with code, a codebase, or developer tools. A good Codex prompt names the behavior you want, points at the relevant code or repro steps, states the constraints that matter, and says how to verify the result. All three below are ready to copy directly.

Two bits of background first: the IDE extension automatically treats your open files as context; in the CLI you need to name paths explicitly, or use @ autocomplete or /mention to attach files. Also, when Codex runs commands locally it's confined to a sandbox with restricted file and network access — anything that would cross that boundary (like reaching the internet, or editing files outside the sandbox) has to clear your approval policy first.

Understanding a codebase

Use this when you're picking up an unfamiliar service, or want to untangle a protocol or request flow.

IDE version · select code, ask about the data flow
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.
CLI version · @-mention specific files, ask about protocol details
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.

Fixing a bug

Use this when you have reproducible bad behavior in hand. A repro recipe plus the files you suspect is far more useful than a high-level description.

Reproducetrigger the bad behavior locally
→
Locatetrace the call path to the root cause
→
Fixsmallest patch that works
→
Verifyrerun repro + lint / tests
CLI version · repro steps + constraints + verification, all in one
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.
IDE version · open the suspect file and just ask
Find the bug causing "Saved" to show without persisting changes. After proposing the fix, tell me how to verify it in the UI.

Writing unit tests

Use this when you want to scope precisely what gets tested. In the IDE, select the function's code and ask; in the CLI, name the function directly.

Writing tests · two paths: select code, or name it via 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.
7Codex Advanced

Codex's three advanced workflows: screenshot to prototype, live-preview iteration, delegating to the cloud

Three more advanced workflows: turning a design screenshot, mockup, or UI reference directly into a working prototype; iterating on code while watching it live in the browser; and taking a plan you worked out locally for a time-consuming refactor and handing the execution off to the cloud.

Screenshot to prototype

Use this when you want to turn a design mockup, screenshot, or UI reference into a working prototype. The image gives the visual requirements — you still need to spell out implementation constraints like framework, routing, and component style in words, and describe any behavior the image can't show (hover states, validation rules, keyboard interactions).

Input

A design screenshot or UI reference, plus your implementation constraints (framework, routing, component style) and a description of any behavior the image doesn't show.

Output

A working prototype: a new route/page plus whatever small components it needs, plus a README. It has Codex start the dev server and tell you the local address where you can see it.

Screenshot to prototype · constraints + deliverables spelled out together
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 iteration with live preview

Use this for the "design → tweak → refresh → tweak again" style of quick iteration. Run the dev server on one side, and converge over a few rounds using small, specific instructions.

Propose 2-3 changesgive a rough direction
→
Pick a directiongo with option 2
→
Narrow to a specific elementchange only the header…
→
Keep convergingreduce noise, drop extra borders
UI iteration · three rounds of progressive instructions
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.

Check the browser after each round; commit if you like it, revert if you don't. If you've manually edited or reverted something yourself, tell Codex — otherwise the next round might overwrite your change.

Delegating a refactor to the cloud

Use this when you want to plan locally with local context first, then hand the time-consuming implementation off to run in parallel in the cloud. The key part: a plan worked out locally can migrate to the cloud with its full context intact.

Delegate · to the cloud

Start locally in your IDE with $plan — have Codex investigate the code and produce a plan, which you revise until you're satisfied. When you switch to a cloud environment, Codex creates a new cloud task and carries over the existing context, including the plan and your local changes. It runs in an isolated environment in the cloud and produces a diff directly; after you review it, you can open a PR right away or pull it back down to test locally. Once you have a plan, you can also open Goal mode with /goal to give it a standing goal it tracks and works toward across multiple steps on its own.

Plan locally in the IDE$plan produces a plan
→
Switch to the cloudwith full context
→
Execute isolated in the cloudby milestone
→
Get a diff / PRmerge after review
Delegating to the cloud · plan locally with $plan, execute by milestone in the cloud
本地规划:
$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.

Tasks delegated to the cloud run in an isolated environment, and the agent stage has no network access by default unless you've enabled it for that environment. Once Milestone 1 works, move on to the next milestones one at a time.

8Codex Review

Codex can review your code too: one local command, or @-mention it on GitHub

When you want a second pair of eyes before a commit or a PR, there are two routes: a local slash command, or @-mentioning it in a GitHub comment thread. Both support targeted focus instructions — say, only looking at security issues.

Local /reviewGitHub @codex review
When to use itReviewing your own working tree before committing or opening a PR
How to triggerType /review in CodexComment @codex review on the PR
Targeted focus/review Focus on...@codex review for...
PrerequisiteNone — use directly in CodexCode review must first be enabled for Codex on the repo
Local code review · slash command + targeted focus
/review

(定向聚焦) /review Focus on edge cases and security issues
GitHub PR review · @-mention it + targeted focus
@codex review

(定向聚焦) @codex review for security vulnerabilities and security concerns

After the local review, once you've addressed the feedback, run /review again to confirm everything's resolved.

One more: updating docs

When you need one accurate, clear documentation change, pin down the files to edit, state the scope, and ask it to verify.

Updating docs · scope + verification in one go
Update the "advanced features" documentation to provide authentication troubleshooting guidance. Verify that all links are valid.

How to start: pick the simplest workflow first (like understanding a codebase), get it working, then reuse that pattern for the rest.

Writing a prompt doesn't take technical syntax or a fixed formula. Open with your own words, look at what comes back, and shape the result into what you actually want with follow-up messages.ChatGPT Learn · Prompting
This article is based on OpenAI's official document, ChatGPT Learn's "Prompting" (learn.chatgpt.com/docs/prompting). Every prompt example in this piece is preserved exactly as it appears in the original. Official vendor documentation — the methods and wording reflect OpenAI's own position.
Source
ChatGPT LearnChatGPT Learn·Read the source
↑ End of article
✓ This article is free to read in full

Members can copy or download the full Markdown, and let their AI subscribe and ask.

Read the original ↗
📮 New explainers, straight to your inbox

Found this useful? Leave your email — every new explainer, the moment it's out. Unsubscribe anytime.