Getting Started with Codex
Codex by OpenAI is a coding agent. Give it a task in the cloud, and it writes code, runs tests, and opens a pull request on your GitHub repo in the background, like having a developer on your team.
In this chapter
- How to set up Codex and start your first project
- 3 starter prompts you can copy-paste right now
- Tips and tricks specific to Codex
- Common first-time issues and how to avoid them
How to Get Started
-
1
Open Codex in ChatGPT Sign in at chatgpt.com. Codex comes with every ChatGPT plan, including Free. Start a chat and choose Work in > Cloud (on the web or the desktop app).
-
2
Connect your GitHub repo Link your GitHub account and choose the repository you want Codex to work on, or pick the default environment to try it without one. Codex needs access to read and write to your repo.
-
3
Assign a task Describe what you want built. Codex creates a new branch, writes the code, runs tests, and opens a pull request for you to review.
Your First 3 Prompts
1. Add a new feature
“Add a dark mode toggle to the site. Use next-themes, add a button in the header, and make sure all components respect the theme. Create the PR when done.”
2. Fix a bug
“The contact form on /contact doesn't show a success message after submission. Add a success toast that appears after the form is submitted, then clear the form fields.”
3. Write tests
“Write unit tests for the utility functions in src/lib/utils.ts using Vitest. Cover all edge cases and aim for 100% coverage.”
Tips for Working with Codex
Think of it as a junior developer
Give clear, specific instructions. 'Add a footer with 4 columns of links' works better than 'improve the page layout'.
Always review the PR
Codex creates pull requests for you to review. Read the changes before merging. It's good practice and catches issues early.
One task per request
Codex works best with focused tasks. 'Add search to the blog' is better than 'add search, fix the nav, and update the footer'.
Use it for tedious work
Codex shines at repetitive tasks: writing tests, adding types, fixing lint errors, updating dependencies, and documentation.
Pair with hands-on tools
Use Codex for background tasks while you work on the fun parts in Cursor or Claude Code.
Common First Issues
Real projects need a repo
You can try a cloud task in the default environment, but for a real project connect a GitHub repo (even an empty one) so Codex can open pull requests.
Review PRs before merging
Codex sometimes makes extra changes you didn't ask for. Always review the diff before merging.
Cloud tasks can't see local changes
Cloud tasks work on what's pushed to GitHub, so push your latest code first. The Codex CLI and editor extension work with the code on your computer instead.