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.
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.
codex login
cd my-project
codexStep 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.
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 headerStep 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
Tools used in this tutorial
OpenAI Codex
OpenAI's cloud and CLI coding agent that can work on tasks in an isolated sandboxed environment.
Claude Code
A terminal-based agentic coding tool from Anthropic that reads, edits and runs code in your own repository.
Cursor
An AI-native code editor built on VS Code, with deep inline editing, chat, and agent capabilities.
Prompts to pair with this
Integrate a third-party API with proper error handling and retries
Gets an AI to build a production-grade API client — authentication, retries, rate limiting, and typed responses — instead of a bare fetch call.
Copy prompttestingGenerate a thorough unit test suite for existing code
Generates a unit test suite that actually covers edge cases and failure paths for existing code, instead of only testing the happy path.
Copy promptRelated tutorials
Getting Started with Claude Code
Install Claude Code, set project-level conventions, and complete your first real task inside an existing codebase.
BeginnerGit Basics for AI-Assisted Coding
Git isn't optional once an AI tool is editing your code for you — it's the only reliable way to review, commit and roll back changes.
BeginnerHow to Debug AI-Generated Code
A repeatable method for tracking down bugs in AI-generated code — reproduce, isolate, prompt with real context, and verify with a test.
IntermediateReady to build the next one?
Browse the full tutorial library or grab a ready-made prompt for your next step.