Codex — The Complete Guide to Deploying OpenAI's Coding Agent to VSCode

Codex/VS Code image

Looking for the fastest, safest way to start using Codex — OpenAI’s coding agent — in VS Code? This guide walks you through installation, sign-in, safe operating modes, practical prompts, and when to offload work to the cloud. No API key is required; you simply sign in with your ChatGPT account.


What You’ll Learn

  • How to install the Codex extension and sign in
  • When to use each mode (Chat, Agent, Agent — Full Access) safely
  • Productive workflows for running locally and delegating to the cloud
  • Troubleshooting tips (Windows notes, WSL recommendation, network access)
  • Clear answers to common questions (e.g., “Do I log in with GitHub?”)

1. What Is Codex?

  • An AI coding agent from OpenAI designed to read, write, test, refactor, and debug code directly in your editor.
  • Can execute tasks locally via the VS Code extension and seamlessly delegate heavier work to an isolated cloud sandbox.
  • Helps prepare commits and PRs, including diffs, logs, and test results.
  • Uses your existing ChatGPT account for sign-in (no separate API key required).

2. Install the VS Code Extension

  1. Open the Extensions view in VS Code (Cmd/Ctrl + Shift + X).
  2. Search for “Codex — OpenAI’s coding agent” and install it.
  3. The “Codex” panel appears in the sidebar after installation.

3. Sign In and Initial Setup

  • Open the Codex panel and sign in with your ChatGPT account.
  • Open the project folder (repository) you want Codex to work in.

4. Choose the Right Mode (Safety First)

  • Chat
    Conversational help only. No file editing or command execution.

  • Agent (default, recommended)
    Reads/writes files and runs commands in your workspace. Attempts to access the network or files outside the workspace require your approval.

  • Agent (Full Access)
    Broad local and network access without prompts. Use sparingly and only when you explicitly need it.


5. Your First Prompts (Run Locally)

Examples:

  • “Remove unused TypeScript imports under src/ and show a diff.”
  • “Jest tests are failing — identify the failures and fix them with minimal changes.”
  • “Improve the accessibility of components/Button.tsx and explain what changed.”

Codex will propose diffs, show logs and test results, and help you prepare commits and PRs.


6. Delegate Work to the Cloud

  • Start a cloud run from the Codex panel when tasks are long-running, resource‑intensive, or require network access.
  • Your local conversation context carries over so you can pick up where you left off.
  • Review results in VS Code and apply only the changes you want.
  • Cloud runs execute in an isolated sandbox with network access available when required.

7. Optional: Use the Codex CLI (Advanced)

  • Install

    • npm: npm install -g @openai/codex
    • Homebrew: brew install codex
  • Launch

    • Interactive UI: codex
    • One‑shot task: codex exec "fix the CI failure"
  • Approval Mode

    • Auto / Read Only / Full Access

Note: Windows support is experimental. WSL is recommended.


8. Practical Prompt Templates

  • Bug fix: “Tests in tests/ are failing. Identify the failures and make the smallest changes needed to pass.”
  • Refactor: “Make components/Button.tsx accessible (ARIA/keyboard) and show a diff.”
  • Types/Lint: “Enable strict TypeScript + ESLint and update existing code to comply.”
  • Create PR: “Bundle the changes into one commit and draft a PR with summary, intent, and test results.”

9. Safety Checklist

  • Start in Agent mode; use Full Access only when necessary.
  • Read approval prompts carefully and grant only what’s needed.
  • Review diffs and test results before committing.
  • Delegate long, heavy, or networked tasks to the cloud.

10. Troubleshooting

  • Can’t find the extension → Open the Extensions view and search “Codex”.
  • Sign‑in fails → Use your ChatGPT account (GitHub is not required).
  • Unstable on Windows → Use WSL.
  • Needs network access → Prefer a cloud run and allow network as prompted.

11. Frequently Asked Questions

  • Q. Do I log in with my GitHub account?
    A. No. Sign in with your ChatGPT account. GitHub is only used when creating PRs.

  • Q. Should I use local or cloud?
    A. Run quick, incremental tasks locally. Use the cloud for large, long‑running, or networked work.

  • Q. Can I use Full Access regularly?
    A. Avoid it. Use Full Access temporarily and only when you truly need it.


Conclusion

  • Codex is easy to adopt: install the VS Code extension and sign in with ChatGPT.
  • Use Agent mode for everyday development and delegate heavy work to the cloud.
  • Review diffs, logs, and tests — used responsibly, Codex becomes a powerful coding partner.

Related articles:
VS Code × GPT‑5 “Thinking Mode”