Skip to content
Codex

Getting Started with OpenAI Codex

Set up OpenAI Codex, write a task description with a real definition of done, and review what comes back like a real pull request.

Beginner7 min read

What Codex is built for

Codex is designed around delegation: you describe a task with a clear scope, it works semi-independently (locally via CLI or in a sandboxed cloud environment), and hands you back a diff or pull request to review — rather than a tight, line-by-line pairing session. See /tools/openai-codex for a full breakdown.

Step 1: Set up access

Install the CLI or open the cloud interface with an OpenAI account that has Codex access, then point it at the repository you want it to work in.

terminal
codex login
cd my-project
codex

Step 2: Write a task with an explicit definition of done

This matters more with Codex than with an interactive chat tool — because you're not steering it in real time, ambiguity in the task description turns directly into wasted iterations instead of a quick clarifying question.

Task description
Implement a /api/export endpoint that returns all of a user's orders as
CSV. Definition of done:
- The test in tests/export.test.ts passes
- Only the authenticated user's own orders are included
- Response has Content-Type: text/csv and a Content-Disposition header

Step 3: Let it run and check progress

In the sandboxed cloud mode, Codex works in isolation and reports back with a diff. Locally, it runs against your working directory. Either way, avoid interrupting mid-task with a completely different instruction — finish or cancel a task cleanly rather than redirecting it halfway through.

Step 4: Review the diff or pull request like any other contributor's

  • Read every changed file, not just the ones related to your task description
  • Run the test suite yourself — don't just trust that Codex reported it passing
  • Check for anything outside the stated scope — an agent that touches unrelated files on a well-scoped task is a signal to review more carefully, not less
  • Verify authentication and authorization logic manually on anything touching user data

Step 5: Run tasks in parallel once you trust the workflow

Codex's sandboxed model makes it reasonable to kick off several independent, well-scoped tasks at once — a bug fix here, a small feature there — rather than working through them one at a time. Keep each task's scope tight enough that reviewing the resulting diffs stays manageable.

Tips for better results

  • Reference an existing test file or acceptance criteria whenever one exists
  • Mention files it should not touch if the task is adjacent to sensitive code
  • Keep each task to one coherent unit of work — split a large feature into several scoped tasks instead of one sprawling description

Ready to build the next one?

Browse the full tutorial library or grab a ready-made prompt for your next step.