How do you use Codex?
To use Codex, install the CLI, run codex inside a Git project, sign in with your ChatGPT account or an API key, and describe a task in plain language. Codex reads your code, proposes and makes edits, runs commands inside a sandbox, and shows you a diff to review before you commit.
This tutorial walks through a first hour with the Codex CLI, OpenAI's open source coding agent, from install to a reviewed change. Every command comes from OpenAI's docs as of 26 October 2026. Each step links to a deeper guide when you want more.
You need a terminal, Git, and a small project you know well. A side project is ideal, because you can judge Codex's answers quickly.
Step 1: Which Codex should you start with?
Codex runs in several places: the CLI, an IDE extension for VS Code and compatible editors, the ChatGPT desktop app for macOS, Windows and Linux, and Codex cloud. The CLI and the IDE extension share the same configuration layers, so settings you make once apply to both.
This tutorial uses the CLI because every approval, diff and command is visible in one place. If you prefer an editor panel, the IDE extension guide covers the same flow, and the Codex app guide covers the desktop app.
Step 2: How do you check that your account can use Codex?
OpenAI's pricing page lists Codex plans for ChatGPT Free, Go, Plus, Pro, Business, Edu and Enterprise. Free and Go list GPT-6 Luna in the desktop app, subject to rollout, while Plus lists Codex in the CLI and the IDE extension. For the CLI, the README says: "We recommend signing into your ChatGPT account to use Codex as part of your Plus, Pro, Business, Edu, or Enterprise plan."
The other route is an OpenAI API key. The pricing page says an API key works with the CLI, SDK and IDE extension, billed at API rates, with "No cloud-based features." The Codex pricing guide compares the options.
Step 3: How do you install the Codex CLI?
Pick one method from the README:
# macOS and Linux
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# npm
npm install -g @openai/codex
# Homebrew
brew install --cask codex
On Windows, run this in PowerShell:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
Check that it worked with codex --version. If the shell cannot find codex, open a new terminal; the Codex CLI guide lists the common fixes.
Step 4: How do you sign in?
Move into your project and start Codex:
cd my-project
codex
Choose Sign in with ChatGPT. With no flags, the command reference says Codex "opens a browser for the ChatGPT OAuth flow." On a remote machine with no browser, or when you want to use an API key, sign in from the shell instead:
codex login --device-auth # no browser on this machine
printenv OPENAI_API_KEY | codex login --with-api-key
codex login status # exits 0 when signed in
Step 5: What should you ask Codex first?
Start with a question, not a change. Questions cost nothing to undo and show you how Codex reads your code.
Explain how this project is structured. Which folders matter most,
how do I run the tests, and where does a request enter the app?
While Codex works, a few keys help:
- Type
@to search for a file and add its path to your prompt. - Prefix a line with
!to run a shell command yourself, under the same sandbox rules. - Press Enter while Codex is working to add instructions to the current turn, or Tab to queue a follow-up.
- Press Ctrl+C or type
/exitto close the session.
Run /status to see the session configuration and token usage, and /model to switch models or reasoning effort. The models page currently describes gpt-6.1-sol as "Near-Astra performance for complex work at a lower cost than Astra," and gpt-6-luna as its most efficient model for focused, high-volume tasks.
Step 6: How do you give Codex your project rules with AGENTS.md?
Codex reads AGENTS.md files before it starts work. Type /init to generate an AGENTS.md scaffold in the current folder, then edit it so it matches how you really work:
# AGENTS.md
- Run tests with `npm test`. Run `npm run lint` before finishing.
- TypeScript strict mode. No new dependencies without asking.
- Keep changes small and explain what you changed.
Short and specific beats long and general. The AGENTS.md guide covers what to include.
Step 7: What permissions does Codex have by default?
Before you ask for edits, know what Codex can do. OpenAI's approvals and security page lists the defaults:
| Folder | Default mode | What it means |
|---|---|---|
| Under version control | Auto (workspace write plus on-request approvals) |
Reads, edits and runs commands in the project; asks before editing outside it or using the network |
| Not under version control | read-only |
Reads files and runs commands that do not write |
The page adds: "By default, the agent runs with network access turned off." Codex also keeps .git, .agents, .codex and .aws read-only inside the workspace, so it cannot rewrite your Git history on its own.
Use /permissions to switch modes during a session. Avoid --yolo while you learn; the reference says to use it only "inside an externally hardened environment." The approvals and sandbox guide explains every option.
Step 8: How do you plan and make your first change?
Commit or stash first so your working tree is clean. Then pick something small and testable, such as a failing test or a missing input check.
OpenAI's prompting guide says to "mention paths explicitly," give reproduction steps, and for multi-step work "investigate and propose an approach before editing." Use /plan to ask for a plan first:
/plan The signup form in src/components/SignupForm.tsx accepts an empty
email. Add validation that shows "Email is required" and add a test for it
in src/components/SignupForm.test.tsx. Run the tests when you're done.
Read the plan, push back on anything you disagree with, then tell Codex to go ahead. When it wants to do something outside its sandbox, it stops and asks. Read each request before you approve it.
When it finishes, type /diff to see the Git diff, including new files Git is not tracking yet.
Step 9: How do you review the change before committing?
Do not stop at "the tests pass." Ask Codex to review its own work with a fresh pass. Type /review and choose Review uncommitted changes. OpenAI's code review docs say the reviewer "reports prioritized, actionable findings without changing your working tree."
You can run the same review outside the terminal UI:
codex review --uncommitted # staged, unstaged and untracked changes
codex review --base main # your branch against main
Fix what matters, by asking Codex or by hand, then read the final diff yourself. You own the commit.
Step 10: How do you commit and pick up later?
Commit from your own shell:
git add -A
git commit -m "Validate empty email on signup"
If you ask Codex to commit, expect an approval prompt, because .git is read-only in the default sandbox.
Your chat is saved. Tomorrow, run codex resume --last in the same folder to continue it, or /new to start fresh. The Codex sessions guide covers resume, fork and history.
What should you learn after your first hour?
Once the loop of ask, plan, change, review and commit feels natural, these are the next steps:
| Next step | Guide |
|---|---|
Set defaults in ~/.codex/config.toml |
Codex config |
| Teach Codex repeatable workflows with skills | Codex skills |
| Connect docs and tools over MCP | Codex MCP |
| Run Codex in scripts and CI | codex exec |
| Hand long tasks to the cloud | Codex cloud |
| Compare Codex with other agents | Codex vs Claude Code, Codex vs Aider, Codex vs Cline |
A few habits help from day one: start every task from a clean Git tree, keep prompts small and specific, run /compact when a long chat fills up, and review every diff before you commit.
Save the prompts that worked
The prompts and rules you refine in your first week are worth keeping. Kipt keeps prompts and Agent Skills as Markdown in a private GitHub repo you own, with {{name}} blanks for the parts that change, and installs your skills into Codex with one npx skills add command. To turn a prompt you like into a skill, try the free SKILL.md generator.