# How to Use Codex in VS Code: From First Task to Reliable Agent Workflow

> Source: <https://pub.towardsai.net/how-to-use-codex-in-vs-code-from-first-task-to-reliable-agent-workflow-3f31c424d11a?source=rss----98111c9905da---4>
> Published: 2026-09-11 20:01:01+00:00

*You thought you invited a helper who would whisper the next line. Instead something started moving files while you watched, or froze on a spinner, or asked permission for every folder it touched. The install looked finished. The work was not.*

To use Codex in VS Code, install the official openai.chatgpt extension, sign in, open a project folder, and use Agent mode for a clearly scoped task that names the relevant files. Review every workspace change and test result before accepting it. For longer jobs, choose cloud delegation; for repeated approvals, remote authentication, or a Windows WSL loading freeze, use the source-backed configuration and troubleshooting paths below.

*Last verified: 2 September 2026*

This will not cover a full terminal install, the Cursor plugin path, usage dashboards, or a Claude comparison. Those jobs live on their own pages. What follows is the VS Code surface: a first bounded task, then the controls that keep the agent predictable.

Before: a ghost-text habit. You type, a suggestion appears, you keep or ignore it, and the rest of the tree stays still. After: a vs code codex session where the panel reads files, edits the working tree, and runs checks while you are still holding coffee. If you treat those as the same motion, the first Agent run feels like a break-in. It is not. It is a different job.

You have asked a passenger for the next turn a hundred times. They point at the sign. You keep both hands on the wheel. The car only moves because you move it.

Then one afternoon you hand over the keys, walk inside for coffee, and come back to a different parking space. The trunk is rearranged. The odometer has moved.

Nobody asked you about the route. The errand happened without you.

That is the difference you are about to configure. Inline autocomplete is the passenger pointing. Codex for VS Code, in Agent mode, is the set of keys. If you skip the recovery point, you are not testing a model. You are lending write access to a repo that still has your uncommitted afternoon in it.

The current Codex IDE extension is an asynchronous coding agent: a background worker that can read the repository, change files on disk, and run terminal commands instead of only suggesting the next token. It is not the 2021 Codex autocomplete API, and it is not GitHub Copilot's ghost text. Tutorials that still describe it as "smarter tab-complete" are describing a different product.

In Agent mode, Codex works across the repository and the terminal. That is why scope and a recovery point matter more here than they do with autocomplete. A one-line suggestion lives in the editor until you accept it. An agent task can land in src/ while you are reading the first paragraph of its plan.

Chat mode, when the composer offers it, is discussion only: no file edits, no command execution. Use it when you want a read of the problem. Switch to Agent when you actually want the tree to move.

OpenAI's own IDE docs and the practical VS Code writeups agree on a blunt UX fact: local Agent mode applies edits directly to the workspace directory. There is no inline accept-or-reject diff workflow in the extension the way some other editors present one. Git is your undo. If Git is not initialized, you do not have a clean unwind.

Do this before the first prompt:

A careful prompt on a dirty tree is more dangerous than a messy prompt on a committed branch.

If you have ever hit this wall, it usually looks ordinary: a small rename, a helper extracted into the wrong file, tests that were not run. None of that is exotic. It is what happens when an agent has a working tree and you assumed it had a suggestion box.

This will not work if you skip the folder open, skip Git, or ask for "improve the codebase" with no file names. The extension will still run. That is the problem.

The clean path is short. The identity check is the part most install GIFs skip.

To add Codex to VS Code, install the official Codex VS Code extension from the Marketplace, not a community wrapper with a similar name. The product listing is titled *Codex - OpenAI's coding agent*, the publisher is OpenAI, and the unique identifier is openai.chatgpt. That identifier is how you tell a vscode Codex extension from a leftover autocomplete plugin.

Open Quick Open with Cmd+P on macOS or Ctrl+P on Windows and Linux, paste the install command, and press Enter:

```
ext install openai.chatgpt
```

Or open the Extensions view, search for that exact title, and confirm publisher plus identifier before you click Install. Do not use install counts, ratings, or a version string as proof. Those numbers move and they are not how you verify the openai Codex vscode extension.

The listing is the [Visual Studio Marketplace page for](https://marketplace.visualstudio.com/items?itemName=openai.chatgpt) [openai.chatgpt](https://marketplace.visualstudio.com/items?itemName=openai.chatgpt). Official capability and layout notes live on OpenAI's [Codex IDE extension docs](https://developers.openai.com/codex/ide). Bookmark both. This page is the workflow around them, not a rewrite of them.

If you want the clicks in motion, this verified walkthrough shows Marketplace install, ChatGPT sign-in, a local folder, and a first interaction:

After install, drag the Codex icon to the right activity bar if you want code on the left and the agent on the right. That split is the layout most people keep. If the icon vanishes after an update, skip reinstalling and jump to the sidebar recovery later in this guide.

Open the Codex panel and choose Sign in with ChatGPT. Complete the browser redirect on the ChatGPT account that actually holds your plan. Plus, Pro, Business, Edu, and Enterprise are the families named on the Marketplace listing.

GitHub Copilot Pro+ and Copilot Max have a separate Insiders path (Sign in with Copilot and the Agent Sessions view). Do not mix those two login stories. They are both real, and they are not the same button.

Some first-run carousels include a sandbox setup step. One widely used install video walks through clicking through the welcome screens and then choosing setup use backup sandbox so the local container can start. If you see that control, it is initializing the isolated environment the agent will use, not installing a second product.

ChatGPT Codex VS Code access is subscription-tied on this path. Message budgets, model pickers, and dollar figures change. Treat any specific Plus or Pro allowance you saw in a June 2026 roundup as dated, and check your account's current usage UI before you plan a long session around it.

Bring-your-own-key (BYOK) means you authenticate with an OpenAI API key instead of a ChatGPT login. The extension exposes a Use API Key button on the sign-in card. That path is useful when a ChatGPT quota is exhausted, or when a team already bills through the API.

It is not a silent equivalent of Plus. Source-backed pricing writeups in 2026 note that API-key billing in the extension and CLI drops cloud delegation and GitHub code review. If you need those, stay on a ChatGPT plan.

When the button is not enough, set the shared config explicitly:

```
preferred_auth_method = "apikey"
```

Then place a placeholder-only key file at ~/.codex/auth.json:

```
{"OPENAI_API_KEY": "YOUR_API_KEY_HERE"}
```

If the panel still insists on ChatGPT, export the key in the same shell that launches the editor, then open the folder from that shell:

```
export OPENAI_API_KEY="your-api-key-here"code .
```

On Windows PowerShell the equivalent is $env:OPENAI_API_KEY="your-api-key-here" followed by code .. Never paste a real key into a screenshot, a ticket, or a blog comment. The JSON above is a schema, not a credential.

Community threads also report a WSL-specific bug with the Use API Key option. If you are inside Windows Subsystem for Linux (the Linux environment Microsoft runs on Windows) and the API-key button fails, prefer the config.toml plus environment-variable path, or run the editor from a shell that already has the key.

The point of the first task is not to impress anyone. It is to prove that Codex with VS Code will touch the files you named, run the check you named, and leave a diff you can read.

Use File > Open Folder and select the project root: the directory with the lockfile, pyproject.toml, or solution file you actually build. Initialize Git if it is not already there. Then open the Codex panel and set the composer to Agent.

Write the outcome as if a tired teammate had to verify it at 6pm:

A prompt that works for a first session looks like this teaching example:

```
Update token expiry handling in @src/auth.ts. Run the existing tests and summarize changed files.
```

That sentence names the file, the outcome, and the evidence. "Make auth better" does not.

If the panel is hidden, open the Command Palette and run Codex: Open Codex Sidebar. Do not hunt the left activity bar first. Updates have moved the icon to the upper right toolbar more than once.

The @filename syntax is how you feed the agent a file without dumping the whole tree into context. Attach the files that matter. Mention the files that must not change. If you have project conventions, put them in an AGENTS.md at the repo root on later sessions. For the first task, the prompt is enough.

Keep the first job inside one concern: expiry handling, a failing test, a log line, a types fix. Multi-file refactors are a later route, often a cloud route. Local Agent mode will happily start them. Your review time will not.

When the run finishes, look at three things in this order:

If the result card says Passed and src/auth.ts is the only changed file, you still read the diff. Passing tests do not mean the comment it added belongs in the public API.

What you now have: an authenticated panel, a scoped Agent run, and a Git-visible change. Time invested, if the repo was already clean: about eight minutes.

Keep the change or reset it. Then stop. The second task is how people accidentally start a rewrite.

Three routes share the Codex name inside VS Code. They do not share the same blast radius. Which one do you actually need today?

Local Agent mode is the default teaching path in this article. Work happens in your workspace. Review happens through changed files, tests, and Git. The constraint is the one already named: edits land in the working tree. Use it for bounded workspace edits you can watch.

Cloud delegation offloads a longer job to an isolated cloud environment so you can keep using the editor, or close it. Official Marketplace copy frames this as "Delegate to Codex in the cloud." Practical 2026 guides describe connecting a repository under chatgpt.com/codex/settings/environments, picking that environment in the sidebar, then choosing Run in the cloud with a base branch such as main or your current branch.

Use this when the task is large, slow, or better as a returned diff than as live writes. It requires supported cloud access on the ChatGPT side. API-key-only setups are the wrong auth route if this is the feature you wanted.

The Codex CLI is the terminal-native agent: the same family of models, driven from a shell instead of the sidebar. You can run it in VS Code's integrated terminal. You should not treat that as a second install tutorial. Platform install, updates, and sandbox flags belong in the Codex CLI install guide.

What belongs here is the decision: use the CLI when you want terminal-first control, when the sidebar is lying to you, or when a long /review in the extension keeps dying (more on that below). Typical commands from the 2026 VS Code writeups look like codex for an interactive session and codex exec "Fix all linting errors in src/" for a non-interactive pass. Install the CLI only if you do not already have it.

If you are choosing a tool rather than a surface, the Claude Code vs OpenAI Codex comparison is the spoke for that job. This page stays on how the VS Code agent actually runs.

Here is the architectural fact most Marketplace pages never say out loud. The VS Code extension is closed-source. Maintainers have described it as a UI wrapper around the open-source Codex CLI. That is why one folder can change behavior in both places.

On macOS and Linux the shared directory is ~/.codex/. Two files matter first: config.toml for defaults, and auth.json for credentials. The extension and the CLI both read that layer. Change it once. Watch both surfaces pick it up.

Windows users have the same idea under the user profile. Remote and code-server layouts add extra copies of auth.json inside the extension folder. Those copies are a workaround, not a second source of truth. Prefer ~/.codex/ when you can.

Do not turn this folder into a screenshot. The values are easier to get right as text you can copy.

A commonly cited global example from 2026 VS Code guides looks like this:

```
# ~/.codex/config.tomlmodel = "gpt-5.3-codex"approval_mode = "agent"
```

Treat the model string as source-qualified and perishable. Model names in tutorials already drift from GPT-5.1 to GPT-5.3-Codex to later GPT-5.x families. If the panel throws unexpected status 400 Bad Request: {"detail":"Unsupported model"}, the picker is on a name your current extension build does not serve. Choose a supported model in the UI. Then, if you still want a default, write the name you actually selected.

approval_mode = "agent" is the default-shaped setting: workspace reads and edits, commands in the working directory, restricted network. Chat is discussion only. Agent Full Access widens local execution and allows internet lookup. Match the mode to the task. Do not leave Full Access on because last Tuesday's npm install needed the network.

The API-key preference from the previous section lives in the same file. Keep auth policy and approval policy in one place so you can read the whole contract in twenty seconds.

This is the part setup articles skip, and the part people search when Codex is not working in VS Code.

But here is the thing. The approval loop and the Windows spinner look like product defects. Sometimes they are. Sometimes they are the sandbox telling you the agent is about to do something you did not watch. Reducing friction is not the same as reducing risk.

Windows users, especially, report a permission loop: every file read or write pauses for a click. The composer offers Chat, Agent, and Agent Full Access. Full Access stops a lot of nags because it authorizes broader local action and network use. That is the honest trade. It is also how a "rename this function" task becomes a package fetch you did not budget.

A community config workaround, widely repeated in VS Code Codex writeups, is:

```
approval_mode = "auto"
```

Other threads mention workspace-write as a middle setting, and danger-full-access as the loud one. Those strings are community-derived. They are not a license to aim the agent at your home directory.

Use auto or a wider composer mode only when all of this is true:

If any row fails, keep the prompts. The loop is annoying. A silent write to .env is worse.

I tried Full Access as the "just make it stop asking" fix. It did not work the way I expected. The nags ended. The session also had a path to the network I did not need for a local rename. The config line is a scalpel. Full Access is a bucket.

There is a documented Windows 11 case where the Codex panel sits on Loading forever. In [openai/codex issue #7082](https://github.com/openai/codex/issues/7082), users isolated it to the WSL integration setting. Early maintainer comments blamed a regional outage. Later comments had the fix that still gets cited.

Open Settings, search Codex WSL, find Run Codex In Windows Subsystem For Linux, and turn it off. Reopen the Codex panel in the runtime you actually intended. This is a Settings action, not a CLI flag. Do not invent a codex --no-wsl switch. It is not in the sources.

If you genuinely want Codex inside WSL2, keep the project on the Linux filesystem and keep tools inside that environment. Mixing a Windows-path repo with a Linux agent is how file-limit and permission bugs show up as "the panel is haunted."

After you change the setting, confirm the CLI still starts in the terminal you trust. If the CLI is healthy and the panel is not, you have a WebView or extension problem, not an auth problem. If both are stuck, fix auth first.

Codex chat histories are isolated between Windows and WSL filesystems. Switch modes and you will not see the same threads. That is not a sync bug. It is two homes.

Pick one runtime for a given repo and stay there for the week. If you must switch, assume the conversation does not come with you. Copy any durable instructions into AGENTS.md in the repository, not into a sidebar thread you will lose on Tuesday.

Start with the symptom. Applying the WSL fix to a hidden icon wastes twenty minutes. If the panel is missing, the model name is rejected, a review dies, and a remote login never returns, those are four different repairs. Pick the matching path. Do not stack them.

If the Codex icon is gone from the left bar, look up and right before you reinstall. [Issue #14586](https://github.com/openai/codex/issues/14586) describes updates that leave access on an Open Codex Sidebar control in the upper right toolbar. The Command Palette command is Codex: Open Codex Sidebar.

If the panel opens and immediately errors with unexpected status 400 Bad Request: {"detail":"Unsupported model"}, the selected model is not valid for that extension build. Open the model picker at the bottom of the Codex panel and choose a supported model. Then update ~/.codex/config.toml so a stale model = "..." line does not send you back into the same 400.

Blank panels and sign-in loops are a different layer: WebView, cookies, or a dead token. Signing out, clearing the ChatGPT session in the browser, and signing in again is the boring fix. Reinstalling over a bad token just gives you a fresh icon on top of the same auth file.

The extension's /review path has a cited timeout around 5 minutes. On a large repository the agent can abort with a reasoning step that says, in effect, too many fixes have been made and time constraints prevent pinpointing exact issues.

Two numbers sit next to each other here. Five minutes in the sidebar. No equivalent cap called out for the same review in the CLI.

If you came to VS Code for review and the panel keeps dying, run the review from Codex CLI in the integrated terminal and inspect the result in Git. Deeper review workflow, including how to ask for a review without turning it into a rewrite, belongs in Codex code review. Do not keep retrying /review in the sidebar hoping the clock will change its mind.

Browser OAuth fails in the usual way on remote SSH, Docker, vscode-server, and other headless boxes: the login page cannot bounce back to the machine that needs the token. [GitHub Discussion #4650](https://github.com/openai/codex/discussions/4650) is the community thread for this.

The supported-feeling workaround inside VS Code is port forwarding. Open the PORTS view, choose Forward a Port, enter 1455, confirm the forwarded address is localhost:1455, then run:

```
codex login
```

Complete the browser step on the machine that can open a browser. The forwarded port is how the callback reaches the remote session.

The heavier workaround is credential copy. Log in on a laptop where OAuth works, then copy ~/.codex/auth.json to the remote extension path. Community examples include ~/.local/share/code-server/extensions/openai.chatgpt-[version]/auth.json for code-server and %USERPROFILE%\.vscode\extensions\openai.chatgpt-[version]\auth.json on Windows.

Replace [version] with the installed folder name. Do not commit that file or paste it into chat logs. Treat it like a session cookie, because that is what it is.

Port forwarding first. File copy only if forwarding cannot work.

You do not need a second install novel for JetBrains on this URL. You need a current boundary so 2025 pages do not send you into a dead plugin hunt.

VS Code uses the official Codex IDE extension, identifier openai.chatgpt. That is the how to use Codex in VS Code path this article teaches.

JetBrains IDEs are a different surface. Older PyCharm posts said native Codex in PyCharm did not exist. That advice is stale. JetBrains announced native Codex support in January 2026, starting from IDE version 2025.3, including IntelliJ IDEA, PyCharm, WebStorm, and Rider. IntelliJ Codex and Codex IDEA searches are that native path, not the VS Code Marketplace identifier. PyCharm Codex / Codex PyCharm is the same JetBrains family.

Keep this page for VS Code mechanics. Use JetBrains' own AI Assistant plus Codex docs when that is the editor you actually live in. The official demo below is enough to confirm the native surface exists without turning this article into a PyCharm tutorial:

If your day job is Cursor rather than VS Code, that is also a different install and panel. Use how to use the Codex plugin in Cursor instead of forcing the Marketplace VS Code flow into Cursor's extension host.

Visual Studio Community 2022 is not in the cited supported-client list for GPT-5.1-Codex. GitHub's community thread on the topic names VS Code, JetBrains, Xcode, and Eclipse as the surfaces in that preview. C# developers who still compile in Visual Studio often keep that IDE for build, and run VS Code beside it for the Codex extension on the same files. Awkward. Also the currently documented split.

Install the official openai.chatgpt extension, sign in, and open a project folder. Open the Codex sidebar (Command Palette: Codex: Open Codex Sidebar if the icon is hidden), set the composer to Agent, and write a task that names files with @filename. Review Git diffs and test output before you keep the result; use cloud delegation for longer jobs and the CLI when the sidebar timeout or layout gets in the way.

Open Quick Open (Cmd+P or Ctrl+P) and run ext install openai.chatgpt, or search the Extensions view for *Codex - OpenAI's coding agent* published by OpenAI with identifier openai.chatgpt. Click Install, then Sign in with ChatGPT, or Use API Key if that tradeoff fits. Confirm publisher and identifier before you install anything with a similar name.

The cited fix for the infinite Loading spinner is to disable Run Codex In Windows Subsystem For Linux under Settings, using the search Codex WSL. Reopen Codex in the runtime you meant to use. If the CLI runs and the panel does not, treat it as a UI or WebView issue after the setting change, not as a missing Marketplace install.

Forward port 1455 with VS Code's Forward a Port action so localhost:1455 is available, then run codex login and complete the browser step on a machine that has a browser. If that cannot work, copy auth.json from a local login into the remote openai.chatgpt extension folder. Keep that file off git and out of screenshots.

Raise autonomy only for a bounded, Git-clean task: Agent Full Access in the composer, or the community approval_mode = "auto" line in ~/.codex/config.toml. Broader access includes broader file and network reach. If the loop is happening on Windows because of sandbox limits, fix the scope first. Do not default to Full Access for every chat.

Yes. Use the Use API Key button, or set preferred_auth_method = "apikey" in ~/.codex/config.toml and put {"OPENAI_API_KEY": "YOUR_API_KEY_HERE"} in ~/.codex/auth.json. Launching with export OPENAI_API_KEY="..." && code . forces the editor past a sticky ChatGPT prompt. API-key billing is widely reported to drop cloud delegation and GitHub review.

No. GitHub issue #2938 records that the VS Code extension is not open sourced. It is a proprietary UI wrapper around the open-source Codex CLI. File CLI bugs and contributions against the CLI. Do not expect a public repo for the Marketplace package, and do not trust a 404 license link on the Marketplace as a source dump.

Yes, as of JetBrains' January 2026 announcement, native Codex support ships in JetBrains IDEs from version 2025.3, including PyCharm and IntelliJ IDEA. That is not the openai.chatgpt VS Code extension. Visual Studio Community 2022 remains outside the cited GPT-5.1-Codex client list; use VS Code or a supported JetBrains IDE for the agent surface.

Pick a repository you already understand. Make the working tree boring: commit or stash until git status is quiet. Install the official extension if it is missing, sign in, and open that folder. Send one Agent task that names a single file, names a test, and fits on one screen of diff.

Watch the files change. Read the diff. Keep it or reset it. That loop is how to use Codex in VS Code when you actually mean "use," not "install."

The editor will keep growing new buttons. Cloud delegation will get smoother. Model names will churn again. The part that stays expensive is handing write access to a tree you cannot unwind. Get that boring, and the rest of the agent is allowed to be interesting.

Until then...

— Sage 🍓

*PS. Next time the panel asks you to approve a file write, say out loud the exact Git command you would run if that write was wrong. If you cannot finish the sentence, stash first and ask again. The pause is the whole review.*

[How to Use Codex in VS Code: From First Task to Reliable Agent Workflow](https://pub.towardsai.net/how-to-use-codex-in-vs-code-from-first-task-to-reliable-agent-workflow-3f31c424d11a) was originally published in [Towards AI](https://pub.towardsai.net) on Medium, where people are continuing the conversation by highlighting and responding to this story.
