Run your first Codex task

Start your first Codex task inside a Git repository with a clean working tree. Run codex, then ask it to explain the project. Next, ask for one small, specific change, review the diff, run your tests, and commit. If you don't like the result, git restore or git stash brings your files back. OpenAI recommends Git checkpoints before and after each task.

1. Make a checkpoint

cd path/to/your/project
git status          # should say "nothing to commit, working tree clean"

If there are uncommitted changes, commit or stash them first. Codex’s review view reflects your Git state, so a clean starting point makes its changes easy to see.

2. Start Codex and look around

codex
Tell me about this project

You’ll see what Codex reads and which commands it wants to run. With the default approval settings, it asks before doing anything outside what your sandbox allows.

3. Ask for one small change

Be specific about the goal, where to look, and how to check it:

In src/utils/date.ts, make formatDate handle null by returning an empty string.
Add a unit test for it and run the test suite.

4. Review before you keep anything

git diff

Run your tests yourself. If you like the change, commit it. If you don’t:

git restore .        # throw away the change
# or
git stash            # keep it aside for later

5. Write down what you learned

Codex reads AGENTS.md before doing any work. If you had to tell it your test command or a naming rule, put it there so you don’t repeat yourself. See AGENTS.md.

Habits that pay off

  • One goal per prompt. Break bigger work into steps.
  • Mention the files, commands, and constraints that matter.
  • Keep the sandbox on. Give more access only when a task needs it. See sandbox and approvals.
  • Use codex resume to return to a recent chat instead of re-explaining context.

Questions people ask

What's a good first prompt?

Something read-only and specific to your repo, such as 'Tell me about this project' or 'Explain how requests flow from the router to the database here'. Then move to a small change you can verify quickly.

Codex seems stuck. What should I do?

OpenAI's troubleshooting steps: check whether Codex is waiting for your approval, run a basic command like git status in the terminal, and if needed start a new chat with a smaller, more focused prompt.

Sources

We link to the official source for every instruction on this page. If anything here disagrees with them, trust the official source and tell us.