Skip to content

OpenAI Codex: how to set up your workspace and start coding with it

A practical walkthrough of OpenAI's Codex coding agent — from workspace setup and project creation to task management, based on the official Academy guide.

OpenAI’s Codex is a cloud-based coding agent designed to handle software engineering tasks autonomously — writing features, fixing bugs, answering codebase questions, and running tests — all inside a sandboxed environment. OpenAI Academy recently published an official step-by-step guide covering how to set up and use Codex effectively. Here is what developers need to know to get started.

Problem

Codex is not a simple autocomplete tool. It is a full agent that spins up its own cloud sandbox, reads your repository, writes code, runs commands, and proposes changes. That flexibility comes with a learning curve: you need to understand how workspaces, threads, projects, and file management interact before you can use it productively. Without a clear onboarding path, developers risk wasting time on misconfigured environments or poorly scoped tasks.

Quick answer

The OpenAI Academy guide walks through the core workflow in a linear sequence: connect a repository, configure your workspace environment, create a project, start a thread (conversation), assign a task, review the output, and merge the results. If you have used GitHub-connected AI tools before, the mental model will feel familiar — but the details matter, especially around environment setup and how Codex handles file context.

Step-by-step workflow

1. Access Codex and connect your repository

Codex is available through the OpenAI platform. The first step is linking a GitHub repository to your Codex workspace. This gives the agent read access to your codebase so it can understand project structure, dependencies, and existing code patterns.

2. Set up your workspace environment

This is where Codex differs from simpler coding assistants. The workspace is a sandboxed cloud environment where the agent actually executes code. According to the OpenAI Academy guide, you need to configure this environment so that it mirrors your project’s requirements — think dependency installation, environment variables, and build tooling. Getting this right is critical: if the sandbox cannot build and run your project, the agent’s output quality drops significantly.

3. Create a project

Projects in Codex act as organizational containers. They group related tasks and conversations around a specific codebase or feature area. Creating a project scopes the agent’s context, which helps it produce more relevant suggestions. If you are working across multiple repositories or feature branches, separate projects keep things clean.

4. Start a thread

Threads are individual conversations with the Codex agent within a project. Each thread maintains its own context and history. You can think of a thread as a focused work session: you describe what you need, the agent works on it, and the conversation tracks the progression of that task.

5. Assign and describe tasks

Once inside a thread, you give Codex a task. The guide emphasizes being specific about what you want — writing a new function, refactoring a module, fixing a specific bug, or answering a question about how part of the codebase works. The agent then operates autonomously in its sandbox: reading files, writing code, running tests, and iterating until it has a proposed solution.

6. Review and manage files

Codex produces file changes that you can review before accepting. The file management interface lets you see diffs, understand what was modified, and decide whether to merge the changes into your repository. This review step is non-optional in any serious workflow — the agent is capable but not infallible.

7. Iterate or merge

If the output is not right, you can provide feedback in the same thread and ask Codex to revise. Once satisfied, you merge the proposed changes back into your codebase through your normal Git workflow.

Limits

A few things to keep in mind based on what the guide covers and what it implies:

  • Environment configuration is manual. If your project has complex build requirements, setting up the sandbox correctly may take real effort upfront.
  • Context windows still apply. While Codex can read your repository, very large codebases may exceed practical context limits, affecting the agent’s ability to reason about distant parts of the code.
  • Autonomous does not mean unsupervised. The review step exists for a reason. Codex can produce plausible-looking code that introduces subtle bugs, especially in edge cases or domain-specific logic.
  • Repository access is GitHub-based. The guide describes GitHub integration specifically. Developers using GitLab, Bitbucket, or other platforms may face limitations.

Alternatives

Codex is not the only AI coding agent available. Here is how it sits relative to other options:

  • GitHub Copilot (with Workspace and Agent mode): Tightly integrated into VS Code and GitHub. More incremental assistance than full autonomous task completion, though agent mode is closing that gap.
  • Cursor: An AI-native code editor with strong codebase-aware features. Works locally rather than in a cloud sandbox, which some developers prefer for latency and privacy reasons.
  • Claude Code (Anthropic): A terminal-based coding agent that operates directly in your local environment. Different interaction model — command-line rather than web-based — but similar autonomous capabilities.
  • Devin (Cognition): Another cloud-based autonomous coding agent. Positioned similarly to Codex but with a different approach to task planning and execution.

The right choice depends on your workflow preferences (cloud vs. local, web UI vs. terminal vs. IDE), your existing toolchain, and how much autonomy you want the agent to have.