The IDE Extension
Codex in VS Code, Cursor, Windsurf & JetBrains
- Install the Codex IDE extension and sign in across VS Code, Cursor, Windsurf, and JetBrains on macOS, Windows, or Linux
- Explain the three editor modes (Chat, Agent, Agent Full Access) and exactly how each maps to a sandbox mode and an approval policy
- Use the in-editor context features — @filename references, open files/selection, the model switcher, and reasoning effort — to steer a task efficiently
- Describe how web search behaves for local IDE tasks and why it is cached
- Hand a long-running task off to Codex cloud with 'Run in the cloud' and apply the resulting diffs back locally without losing context
- Choose deliberately between the IDE, the CLI, and cloud delegation for a given piece of work
The Codex IDE extension brings the same Codex agent you'd run in the terminal directly into VS Code, Cursor, Windsurf, and JetBrains — sharing one ChatGPT account, one AGENTS.md, and the same sandbox/approval model as the CLI. This lesson covers installing and signing in, the three editor modes and exactly how they map to Codex's independent sandbox and approval controls, the in-editor context features (@filename, open files, model + reasoning effort), and the 'Run in the cloud' hand-off that offloads a long task while preserving context. You'll leave able to choose deliberately between IDE, CLI, and cloud for any given task.
- 1The mental model: same agent, new surface
- 2Install & sign in
- 3The three modes — and what they really control
- 4In-editor context: @filename, selections, model & effort
- 5Web search, on by default — but cached
- 6'Run in the cloud': the local → cloud hand-off
- 7Choosing: IDE vs. CLI vs. cloud
The mental model: same agent, new surface
Start with the idea everything else hangs on: the IDE extension is not a different product — it is the same Codex agent, rendered inside your editor.
Codex is an umbrella over a family of surfaces — the CLI, the IDE extension, cloud/web, the desktop app, mobile, GitHub — that all share one model family and one ChatGPT account. The extension is the editor surface of that single agent. It reads the same AGENTS.md, obeys the same sandbox and approval controls, and runs the same agent loop (inspect repo → propose changes/commands → pause for approval → iterate) that you met in the CLI lessons. The window dressing changes; the engine does not.
Why use the editor surface at all, when the CLI already does everything? Three concrete wins:
- Native diff review. Proposed edits show up as real editor diffs, in the files you already have open, with your syntax highlighting and gutters.
- Effortless context. The files you're looking at and the code you've selected become context automatically — no copy-pasting paths into a prompt.
- A door to the cloud. A single click ("Run in the cloud") offloads a long task to an isolated cloud environment and brings the diff back, all without leaving the editor.
Keep the surface/agent distinction crisp: when you change the model in the IDE, or approve a command, or edit AGENTS.md, you are configuring Codex, not "the VS Code plugin." That is why the skills transfer cleanly between terminal and editor.
Key insight
One agent, many windows
The extension shares your ChatGPT account, your AGENTS.md, and the same sandbox/approval model as the CLI. Learn the agent once and the editor is just a nicer pane onto it — most of what you already know about the CLI applies unchanged.
Install & sign in
The extension ships from the Visual Studio Code Marketplace under the id openai.chatgpt (the same one the CLI's codex lineage lives under), and OpenAI provides install links for each supported editor.
Supported editors and platforms:
| Editor | Notes |
|---|---|
| VS Code (+ Insiders) | The reference editor |
| Cursor | VS Code fork |
| Windsurf | VS Code fork |
| JetBrains | IntelliJ, PyCharm, WebStorm, Rider |
It runs on macOS, Windows, and Linux. On Windows you can run it natively (the Windows sandbox) or via WSL2 — the same options as the CLI.
After install, Codex opens in the right sidebar by default (you can drag it to the left). On a VS Code fork like Cursor, moving the icon may require toggling the activity bar orientation.
Signing in mirrors the CLI exactly: on first run the extension prompts you to sign in with your ChatGPT account or with an API key.
- ChatGPT account (recommended) — plans that include Codex (e.g. Plus/Pro/Business/Edu/Enterprise) carry Codex usage with no separate setup. This is the path most people want.
- API key — usage-based billing through the API; useful for shared or automation-leaning setups.
Because the account is shared, signing in once ties the editor to the very same Codex identity as your terminal — your sessions, history, and entitlements come along.
Note
Plan lists rot — check the live page
Exactly which plans include Codex (and how usage is metered) changes over time. Treat any plan list as volatile and confirm against the live pricing/plan page: https://developers.openai.com/codex/pricing
Tip
Open the right folder in a monorepo
Codex anchors its workspace on the folder you open. In a monorepo, open the directory that holds the .codex / AGENTS.md you want in effect, so the extension picks up the intended project context.
The three modes — and what they really control
The extension's mode switcher offers three modes. They look like a simple dropdown, but each one is really a pairing of two independent controls you already know from the CLI: a sandbox mode (WHERE Codex may act) and an approval policy (WHEN it must stop and ask). The modes are just friendly presets over that pair.
| IDE mode | What it does | Sandbox (WHERE) | Approval (WHEN) |
|---|---|---|---|
| Chat | Conversation only — no automatic file edits or commands | read-only | on-request |
| Agent (default) | Read, edit, and run commands within the working directory; asks approval for network or out-of-workspace access | workspace-write | untrusted |
| Agent (Full Access) | Unrestricted file ops + network with no approval prompts — use cautiously | danger-full-access | never |
The single most important thing to internalize: sandbox and approval are independent axes. Sandbox is an OS-enforced read/write/network boundary; approval is the policy for when the agent pauses for a human. The IDE bundles them into three sensible presets, but under the hood they are the same two knobs the CLI exposes via --sandbox/sandbox_mode and --ask-for-approval/approval_policy. Understanding the pairing is what lets you reason about "what can actually go wrong here?" instead of trusting a label.
A few practical implications:
- Agent is the everyday default. It can edit and run routine commands inside your workspace, but it will pause and ask before reaching the network or touching files outside the working directory.
- Agent (Full Access) removes both guardrails — it maps to
danger-full-accesswith no approvals. That is genuinely useful for trusted, well-scoped work, but it is the editor equivalent of the CLI's most permissive posture. Reach for it deliberately, not by habit. - Chat is the safe place to think: ask questions, plan, and read the code with zero risk of an unexpected edit or command.
Key insight
Two knobs, three presets
Sandbox (read-only / workspace-write / danger-full-access) and approval (on-request / untrusted / never) are separate. Chat, Agent, and Agent (Full Access) are just OpenAI's pre-paired combinations of those two knobs — exactly the model you learned for the CLI, with a friendlier front end.
Watch out
Full Access = danger-full-access
Agent (Full Access) drops the sandbox boundary and turns off approval prompts at the same time. Untrusted web content or a prompt injection has far more room to do damage. Default to Agent; switch up only for trusted repos and scoped tasks.
In-editor context: @filename, selections, model & effort
The editor's biggest ergonomic advantage is how naturally it feeds context to the agent. You spend far less effort telling Codex what to look at, because the editor already knows.
Pointing Codex at code:
@filenamereferences — type@and pick a file to attach it explicitly to the conversation.- Open files + selected code are used as context automatically. Select the function you're worried about, write a short prompt, and Codex already has the relevant snippet — shorter prompts, faster results.
Choosing the brain:
- A model switcher sits under the chat input. Pick the model that fits the task; leaving it on the recommended default lets ChatGPT-auth users track whatever OpenAI currently recommends.
- A reasoning effort control offers low / medium / high, with medium as the recommended default. Higher effort means deeper reasoning but more tokens (and latency); lower is snappier for simple edits. This is the same
model_reasoning_effortconcept from the CLI config, exposed as a picker.
Model names and the exact default rotate frequently, so don't memorize a specific string — pick from what the switcher offers and confirm the current recommendation on the live models page.
┌──────────────────────────────────────────────┐
│ Codex chat (editor sidebar) │
│ @auth.ts @rate-limit.ts [+ selection] │
│ > Add rate limiting to the login route │
│ │
│ [ model: <recommended> ▾ ] [ effort: medium ▾ ]│
└──────────────────────────────────────────────┘Tip
Select first, prompt second
Because open files and your current selection are automatically in context, you often don't need to describe the code at all. Highlight the offending function, then ask "why does this throw on empty input?" — Codex already has the snippet.
Note
Don't hard-code the model name
The recommended default model and the catalog shift often. Pick from the in-editor switcher and verify the current recommendation live: https://developers.openai.com/codex/models
Web search, on by default — but cached
For local IDE tasks, web search is enabled by default. That lets Codex pull in current information — an error message, a library's current API — without you switching to a browser.
The important nuance is how it searches: results come from an OpenAI-maintained web search cache (an index of web results), not a live hit to the open internet for every query. That distinction matters for two reasons:
- Speed and consistency — cached lookups are fast and don't depend on a live fetch round-trip.
- Security — every piece of retrieved web content is untrusted input and a vector for prompt injection. Serving from a cache reduces exposure compared with live, arbitrary fetches. Codex's broader security stance treats all web results, MCP output, and external content as untrusted, with the sandbox as the primary defense.
So: web search is a feature you get for free locally, but keep the security framing in mind. The safest posture is the default Agent mode (workspace-write, approval for network/out-of-workspace), which limits what a malicious search result could actually cause the agent to do.
Watch out
Treat search results as untrusted
Anything Codex reads from the web — even via the cache — is untrusted content that could carry a prompt-injection payload. The sandbox is your primary defense: keep approvals and sandbox tight (Agent mode), and don't run trusted-only tasks in Full Access just because web search is on.
'Run in the cloud': the local → cloud hand-off
The headline feature unique to the editor surface is the local → cloud hand-off. When a task is too long to babysit locally — a big refactor, a sweep across many files, something you'd rather run in the background — you offload it to Codex cloud without leaving the IDE, and the context comes with it.
The flow:
- Configure a cloud environment in settings (a container that checks out your repo at a branch/commit, runs your setup script, and installs dependencies).
- Click "Run in the cloud" to offload the task. Codex spins up an isolated cloud sandbox for it.
- Monitor progress without leaving the IDE.
- Preview the cloud's proposed changes and ask follow-up questions.
- Apply the resulting diffs locally to test and finish.
The property that makes this more than "open the web app" is that context persists across the local → cloud transition — the cloud task starts with what you were already working on, rather than from a blank prompt. It is the same one-account, one-agent design paying off: the cloud run is the same Codex, just on a beefier, isolated host.
A couple of details worth carrying over from the cloud lesson: cloud tasks run in their own containers (so several can run in parallel), and internet access is OFF by default during the agent phase (setup scripts keep it on for dependency installs). You configure that per environment.
Example
When to hand off vs. stay local
Local IDE: a focused change you want to watch and iterate on, with selections and open files as context. Run in the cloud: a long, background-able task (large refactor, many-file change, dependency upgrade) you'd rather not tie up your editor — kick it off, keep coding, review the diff when it lands.
Note
Cloud details live in their own lesson
Environment setup, internet-access policy, and PR creation are covered fully in the Codex cloud lesson. From the IDE you mainly need: configure an environment once, then 'Run in the cloud' and apply diffs back.
Choosing: IDE vs. CLI vs. cloud
Because all three are the same agent, the choice is about ergonomics and where the work should run, not capability. Use this as a decision guide:
| Use the… | When… | Because… |
|---|---|---|
| IDE extension | You're actively coding and want to see diffs, lean on open-file/selection context, and iterate tightly | Native diff review + automatic context + a click to the cloud |
| CLI | You want scripting, headless exec runs, fine-grained flags, or you live in the terminal | Maximum control, composability, and automation surface |
| Cloud (Run in the cloud) | The task is long, background-able, or best run in an isolated, parallelizable environment | Offload + parallelism + isolation; brings a diff/PR back |
The through-line: start where the work is. If you're reading and editing code, the editor is the lowest-friction home and the hand-off to cloud is one click away. If you're automating or scripting, the CLI is your surface. And because configuration (AGENTS.md, sign-in, sandbox/approval posture) is shared, you can move between them mid-project without re-learning anything.
Reviewing diffs is the same discipline everywhere: Codex always surfaces a transcript and a diff, and there is no /undo — you roll back through your normal git workflow. The editor just makes that diff prettier to read.
Tip
One project, three surfaces
You don't have to pick one forever. Plan in the IDE's Chat mode, let Agent mode make the change, hand a long follow-up to the cloud, and script the repetitive parts from the CLI — all on the same account, same AGENTS.md, same agent.
Try it: Drive Codex from your editor — and hand a task to the cloud
Goal: feel the editor surface and the local→cloud hand-off firsthand. 1) Install & sign in. Install the Codex extension (id openai.chatgpt) from the VS Code Marketplace in VS Code, Cursor, Windsurf, or a JetBrains IDE, and sign in with your ChatGPT account. Confirm Codex opens in the sidebar. 2) Start in Chat mode. Open a small repo of yours. In Chat mode (read-only) ask a question — "Where is request rate limiting handled, if anywhere?" — and notice it never edits anything. 3) Use editor-native context. Select a function, then with a short prompt and an @filename reference ask Codex to explain or improve it. Observe that your open files and selection were already in context — you didn't paste any code. 4) Switch to Agent and make a real change. In the default Agent mode, give it a task with a verifier: "Add input validation to this handler and run the tests." Watch it pause and ask before anything network or out-of-workspace. 5) Tune the brain. Open the model switcher and set reasoning effort to high for one tricky step, then back to medium. 6) Hand off to the cloud. Configure a cloud environment in settings, then click Run in the cloud for a longer follow-up (e.g. "refactor this module and update all call sites"). Monitor it in-IDE, preview the diff, and apply it locally. 7) Reflect (3 sentences): how did open-file/selection context change your prompting versus the CLI; what did the Agent-mode approval prompt stop it from doing; and what carried over when you ran in the cloud? Note for yourself one task you'd keep in the IDE, one you'd script from the CLI, and one you'd send to the cloud.
Key takeaways
- 1The IDE extension is the editor surface of the same Codex agent — one ChatGPT account, one AGENTS.md, same sandbox/approval model as the CLI; learn the agent once and the editor is just a nicer pane onto it.
- 2Install it from the VS Code Marketplace (extension id openai.chatgpt) for VS Code (+ Insiders), Cursor, Windsurf, and JetBrains on macOS/Windows/Linux; sign in with a ChatGPT account or an API key.
- 3The three modes are presets over two independent knobs — Chat (read-only / on-request), Agent (workspace-write / untrusted, the default), and Agent Full Access (danger-full-access / never). Sandbox is WHERE; approval is WHEN.
- 4Context is effortless in the editor: @filename references plus automatic open-files/selection context, with a model switcher and a low/medium/high reasoning-effort control (medium is the default).
- 5Web search is on by default for local tasks but served from a cache; treat all retrieved content as untrusted, and default to Agent mode so the sandbox limits what an injection could do.
- 6'Run in the cloud' offloads a long task to an isolated cloud environment while preserving context, then lets you preview and apply diffs locally — pick IDE vs. CLI vs. cloud by ergonomics and where the work should run, not by capability.
Quiz
Lock in what you learned
Check your understanding
0 / 4 answered
1.In the Codex IDE extension, what does selecting the default 'Agent' mode actually configure under the hood?
2.Which statement about the sandbox and approval controls behind the IDE's modes is correct?
3.A teammate says: 'Web search is on by default in the IDE, so every query hits the live internet and that's fine because results are trustworthy.' What's wrong?
4.You click 'Run in the cloud' on a long refactor from the IDE. What is the key benefit over just opening chatgpt.com/codex and starting fresh?
Go deeper
Hand-picked sources to keep learning
Install links for VS Code, Cursor, Windsurf, and JetBrains; sign-in, supported platforms, and the right-sidebar layout.
The three modes, @filename context, model + reasoning-effort controls, web search, images, and the Run-in-the-cloud hand-off.
The independent sandbox (read-only / workspace-write / danger-full-access) and approval (on-request / untrusted / never) controls the IDE modes map onto.
Where 'Run in the cloud' tasks execute: isolated containers, parallel background tasks, and PR creation.
The live model catalog and current recommended default — check here instead of memorizing a model name from the switcher.
Which plans include Codex and how usage is metered — the volatile plan/pricing details to confirm live.