Guilds AI / Blog

,

How to Use Codex in VS Code: Setup and Code Review Guide

Illustration of Codex integrated with a VS Code editor for setup and code review.

To use Codex in VS Code, install the official OpenAI extension, open its sidebar, and sign in. Give the agent a focused task using your project context, inspect the proposed changes, and verify the result independently. This guide also shows how to use the built-in code review command to inspect a Git diff. For a multi-provider alternative that can also connect to eligible OpenAI accounts, see our Cline vs Codex comparison. For subscription options and current usage limits, read our Codex Plus vs Pro comparison. For tasks that end in a business deliverable rather than a repository change, see our ChatGPT Work vs Codex comparison. If you are choosing between OpenAI and Google’s development tools, read our Gemini vs ChatGPT for coding comparison.

For a second-opinion review directly from Claude Code, see our Claude Code Codex plugin guide.

For choosing the appropriate model and effort in your repository session, see our best GPT for coding guide.

If you are considering GitHub Copilot or the Codex integration available through Copilot, see our Codex vs GitHub Copilot comparison.

For more repository-oriented tools and free options, see our Claude Code alternatives guide.

For a comparison with a dedicated AI-native editor, read our Codex vs Cursor guide.

Install the official Codex extension in VS Code

Open Visual Studio Code and choose Extensions. Search for Codex and check that OpenAI is the publisher before installing. The marketplace extension identifier is openai.chatgpt. Alternatively, if the VS Code launcher is installed on your PATH, run:

code --install-extension openai.chatgpt

Open a project folder rather than an isolated source file so the agent has the intended project context. Choose the Codex sidebar icon, or use the Command Palette (Command+Shift+P on macOS, Ctrl+Shift+P on Windows or Linux) and search for Codex: Open Codex Sidebar. Follow the authorized sign-in flow in the extension. Access and model usage depend on your account and authentication method; installation alone does not provide unlimited usage.

The official IDE quickstart also supports Cursor and Windsurf. If you use Cursor rather than VS Code, see our Codex in Cursor setup guide.

Give Codex the right editor context

Use an open file, a selection, or a specific file reference to direct the agent’s attention. Confirm that the workspace root is correct and that the referenced files are relevant to your objective. Avoid copying the entire repository into a prompt or including credentials and private data.

For an unfamiliar project, begin with a read-only request and restrict the session’s permissions accordingly. Ask the agent to identify the test command and explain one code path before allowing edits. Approval controls and sandboxing determine what the session can do; a prompt alone is not a security boundary.

An AGENTS.md file can record repository conventions, test commands and files that should not be edited. Our Codex AGENTS.md guide covers how to organize those instructions.

Try a small Python task in VS Code

Create a local learning project with a file called prices.py. This example intentionally accepts negative prices, even though the hypothetical application requires nonnegative integer prices in cents.

def total_cents(prices):
    return sum(prices)

Open the file in VS Code and give Codex a precise task. The following is an original sample prompt:

Inspect prices.py. Add validation that rejects a negative price with ValueError. Preserve the behavior for empty lists and valid nonnegative prices. Propose tests before editing; do not add dependencies.

Once you approve the plan, compare the proposed implementation with the expected behavior. One possible result is:

def total_cents(prices):
    if any(p < 0 for p in prices):
        raise ValueError('negative price')
    return sum(prices)

This exercise assumes a list of integers; a production API would also need to validate types and ranges. Check the proposed change with a separate Python script:

from prices import total_cents

assert total_cents([]) == 0
assert total_cents([120, 80]) == 200
try:
    total_cents([120, -1])
except ValueError:
    pass
else:
    raise AssertionError('negative price accepted')

Save this as check_prices.py in the same directory and run python check_prices.py from the integrated terminal. The equivalent three checks were executed locally and passed. This is a tested illustrative implementation, not a recorded Codex-generated patch. The authenticated editor extension was not run.

How to use Codex code review in VS Code

Codex code review analyzes changes in a Git repository and reports potential issues. It is distinct from asking the agent to implement a change and from the separate pull-request review integration. To use the built-in review in the IDE, open a Git project, type /review in the Codex composer, and choose whether to examine uncommitted changes or compare against a selected base branch.

For the small prices example, review the uncommitted changes. Ask whether the change preserves valid inputs and includes a regression test. The review command reports findings without editing the working tree; applying fixes is a separate action subject to the active permission controls.

Check each finding against the actual diff, intended behavior and test output. A plausible warning may be irrelevant, while a clean report may miss a real defect. Keep a Git checkpoint and inspect any subsequent fixes before committing. Our Codex agent guide explains why tool results and human verification remain important.

Choose local editing or cloud delegation

The IDE extension is useful for examining code and changes alongside your editor. Local tasks work against the configured project environment. For larger authorized tasks, supported cloud delegation can return a proposed change from a separate environment. Check the repository connection and review the result before applying it locally.

The CLI is a separate terminal interface. Use it when you prefer shell-based development or supported command-line workflows. It is not necessary merely to open the IDE extension. Avoid giving concurrent agents write access to the same files; separate branches or worktrees make overlapping changes easier to review.

Troubleshoot Codex in VS Code

Sidebar missing: Confirm the official extension is installed and enabled for the active profile. Use the Command Palette to open it; reload the editor if necessary.

Wrong project context: Check the opened workspace root, selected file and relevant project instructions. Do not bypass workspace trust just to enable more operations.

Review command missing: Open a project inside a Git repository. The official documentation states that /review is only offered for Git projects.

Authentication or quota failure: Check the account and access method, applicable model availability and usage limits. Do not create a separate billed API credential merely to fix a login problem.

Unexpected edits: Stop further changes, inspect Git status and the diff, and preserve your own work. Revert only changes you have identified and authorized for removal.

For a wider comparison of Python coding tools, see our AI Python code generators guide.

Frequently asked questions

Can I use Codex in VSCode without the CLI? Yes. The official extension has its own IDE workflow.

Is Codex the same as GitHub Copilot? No. They are separate coding products even when available inside the same editor.

What does /review do? It inspects a selected Git change set and returns findings for review rather than automatically fixing the files.

Does a successful review guarantee safe code? No. Independently test behavior and inspect security-sensitive changes.

Was the extension tested live? No. OpenAI’s IDE and code review documentation and three independent setup guides were reviewed on December 4, 2026. The Python implementation was tested locally; no authenticated model requests were made.