Agentic AI AcademyAgentic AI Academy

Your First Session

Launch, watch the loop, steer, and recover

Beginner 11 minBuilder
What you'll be able to do
  • Be able to start an interactive Codex session in a project directory, with or without an inline task prompt
  • Be able to describe the agent loop — inspect repo, propose edits/commands, pause for approval, iterate — and recognize each phase on screen
  • Be able to interrupt a run with Ctrl+C, edit your previous message with Esc Esc, and queue a follow-up with Tab while Codex works
  • Be able to attach context with `@` fuzzy file search and with images (paste or `-i screenshot.png`)
  • Be able to roll back Codex's changes using your normal git workflow, knowing there is no `/undo`
  • Be able to resume an earlier session with `codex resume` and check session config and usage with `/status`
At a glance

This is your first real Codex run: type `codex` in a project, hand it a task in plain English, and watch the agent loop inspect the repo, propose edits and commands, and pause for your approval before it touches anything. You'll learn the muscle memory that makes Codex safe and steerable on day one — interrupt with Ctrl+C, edit your last message with Esc Esc, queue a follow-up with Tab, attach context with `@` or an image — and the recovery story that lets you relax: every action is in the transcript, and git (not a `/undo` command) is your undo button.

  1. 1Starting a session: just type `codex`
  2. 2Watch the loop: inspect, propose, pause, iterate
  3. 3The safety net: transcript + git (there is no `/undo`)
  4. 4Steering mid-run: interrupt, edit, queue
  5. 5Attaching context: `@` files and images
  6. 6Coming back later: `codex resume` and `/status`

Starting a session: just type `codex`

You've installed Codex and signed in. The whole experience starts with one word. In any project directory, run:

bash
codex

That opens the full-screen terminal UI (the TUI) — a composer at the bottom where you type, and a scrolling transcript above it where Codex shows its work. You're now talking to an agent that can see and act on the project you're standing in.

You can also hand it the task up front, so it starts working the moment the UI opens:

bash
codex "fix the login bug"

Both forms do the same thing — the second just pre-fills your first message. Either way, Codex reads the project around you, so where you launch matters: start in the directory that holds the code you want it to work on. In a monorepo, open the subdirectory that contains the relevant .codex / AGENTS.md context.

The key mental model for this lesson: you are not running a command that spits out an answer and quits. You're opening a conversation with an agent that will inspect, propose, pause, and iterate with you until the task is done — and then stay open for the next instruction.

Tip

Launch where the work is

Codex grounds itself in the directory you start it in. Run codex from the project (or sub-package) you actually want to change. You can also point it elsewhere later with -C/--cd, but for your first run, just cd into the repo and type codex.

Watch the loop: inspect, propose, pause, iterate

Hand Codex a task and it runs the same loop every time. Watching it happen once is the whole point of this lesson, because the loop is what makes Codex an agent rather than a chatbot.

  1. Inspect the repo. Codex reads the relevant files, searches the code, and builds a picture of what's there. You'll see it open and skim files in the transcript.
  2. Propose edits / commands. It decides what to do — an edit to a file, a shell command to run, a test to execute — and surfaces that proposal.
  3. Pause for approval. Depending on your approval mode, Codex stops and asks before it writes a file or runs a command, showing you exactly what it intends. Nothing consequential happens behind your back.
  4. Iterate conversationally. You approve (or decline, or redirect), Codex acts, observes the result, and loops back — re-reading, re-running tests — until the task is actually finished.

The pause in step 3 is the part newcomers most need to internalize. Codex is not a runaway script; by default it works inside a sandbox and asks before going beyond it. (The full matrix of where it can act and when it asks — sandbox vs. approvals — is its own lesson; here, just notice that it pauses and waits for you.)

Throughout, Codex keeps a transcript of every action it takes — every file read, every edit, every command. That transcript is both your live view of what's happening and, as you'll see next, half of your safety net.

Key insight

The pause is a feature, not a delay

An agent that can edit files and run shell commands is only trustworthy because it stops to ask. The approval pause is the seam where you stay in control of consequential actions — review the proposed edit or command, then approve. You can loosen or tighten when it asks later; on your first run, leave it asking.

The safety net: transcript + git (there is no `/undo`)

Here is the single most important thing to understand before you let an agent edit your code: how to undo it.

Codex's answer has two parts that work together:

  • The transcript surfaces every action Codex took — which files it read, what it edited, what commands it ran. Nothing is hidden, so you can always see exactly what changed and why.
  • Git is your undo button. Codex deliberately does not ship a /undo slash command. Instead, you roll back through your normal git workflow — because the transcript tells you precisely what happened, standard git tools handle the reversal cleanly.

In practice, that means the habits you already have are your recovery story:

bash
git status                 # see what Codex changed
git diff                   # review the changes in detail
git restore <file>         # discard changes to a specific file
git checkout -- .          # discard all uncommitted changes
git stash                  # shelve changes to inspect later

Inside the TUI, /diff shows you the same Git diff (including files Git isn't tracking yet) without leaving the session, so you can review before you ever touch the shell.

The practical lesson: commit before you start a risky task. A clean git checkpoint before Codex begins means git restore or git checkout can return you to a known-good state in one command, no matter how far the agent wandered.

Watch out

Don't go looking for `/undo`

There is no /undo in Codex — typing it does nothing useful. Rollback is git. Before any task you're unsure about, run git status to confirm a clean tree (or commit your work) so you have a checkpoint to return to. The transcript shows you what changed; git is how you undo it.

Note

Sandbox limits the blast radius too

By default Codex edits only inside your workspace and can't reach the network without opting in, so the damage a wrong turn can do is bounded before git even enters the picture. Git is your undo for file changes; the sandbox is what keeps those changes contained in the first place.

Steering mid-run: interrupt, edit, queue

You will not always like where Codex is heading — and you don't have to wait it out or kill the session. Three keystrokes give you full control while it runs. Getting these into muscle memory is what turns Codex from a black box into a steerable teammate.

KeystrokeWhat it doesWhen to reach for it
Ctrl+CCancels the current turn (and, pressed again with nothing running, closes the session)Codex is doing the wrong thing — stop it now
Esc EscWith the composer empty, edits your previous user message; keep pressing Esc to walk further back through the transcriptYour last instruction was unclear or wrong — rewrite it instead of piling on a correction
TabWhile Codex is running, queues follow-up text, a slash command, or a ! shell command for the next turnYou think of the next step mid-run and don't want to forget it — line it up

A few nuances worth knowing on day one:

  • Ctrl+C is the interrupt — not Esc. If you come from other agents where Esc stops the run, retrain that reflex: in Codex a single Esc doesn't cancel; Ctrl+C does. A double-tap of Esc on an empty composer is the edit-my-last-message gesture, which is a different (and very useful) thing.
  • Esc Esc lets you fix the prompt, not patch over it. Rather than sending a second message that argues with the first, walk back and rewrite the instruction that sent Codex off course. Press Enter to fork the conversation from that point.
  • Tab queues; Enter injects. Pressing Enter while Codex is running injects an instruction into the current turn; Tab holds it for the next turn. Use Tab when you want to let the current action finish first.

Watch out

Interrupt is Ctrl+C, not Esc

This trips up everyone coming from other coding agents. In Codex: Ctrl+C cancels the current turn. Esc Esc (empty composer) edits your previous message and lets you fork from there. They are not the same key, and confusing them is the most common first-session stumble.

Attaching context: `@` files and images

Codex works far better when you point it at the right context instead of making it hunt. Two lightweight ways to do that, both usable from your very first prompt.

@ for files. Type @ in the composer to open a fuzzy file search over the workspace root. Start typing part of a filename, then press Tab or Enter to drop the highlighted path into your message. So a prompt like:

text
Why does @src/auth/login.ts throw on empty passwords?

gives Codex an exact pointer instead of a vague description. (/mention is the menu-driven equivalent if you prefer picking from a list.)

Images for visual context. Codex is multimodal — show it a screenshot of an error, a failing UI, or a design spec:

  • Paste an image directly into the interactive composer, or
  • Attach from the CLI when you launch:
bash
codex -i screenshot.png "Explain this error and fix it"

The --image / -i flag accepts comma-separated or repeated files (e.g. -i before.png,after.png), so you can hand Codex a before/after pair or several screenshots at once.

The instinct to build here: a good first prompt is a goal plus its context. Tell Codex what you want, and @-mention the files or paste the screenshot that show it the situation — that single habit eliminates a huge fraction of "Codex went the wrong way" moments.

Tip

Point, don't describe

Instead of "there's a bug somewhere in the auth code," type @ and pick the file: Fix the null check in @src/auth/login.ts. An exact @-mention or a pasted screenshot saves Codex an inspection pass and gets you a sharper first proposal.

Coming back later: `codex resume` and `/status`

A session doesn't have to end when you close your laptop. Codex stores each session locally, so you can pick a conversation back up with its full history intact.

bash
codex resume          # opens a picker of recent sessions in this project
codex resume --last   # jumps straight to your most recent session here

The plain codex resume shows a picker of recent sessions — highlight one to see its summary and press Enter to reopen it. codex resume --last skips the picker and reopens the most recent session from your current directory. Inside a session, the /resume slash command does the same, and /new starts a fresh conversation without leaving the CLI.

While you're working, one slash command is worth knowing from day one:

  • /status displays your session configuration and token usage — which model and reasoning effort are active, and how much of your usage window you've consumed. It's the quickest way to answer "what mode am I in?" and "how much have I used?" without leaving the session.

That's the full day-one toolkit: start with codex, watch the loop, steer with Ctrl+C / Esc Esc / Tab, attach context with @ and images, undo with git, and come back later with codex resume. Everything deeper — approval modes, sandboxing, config, MCP — builds on this foundation.

Tip

Sessions persist — so don't cram

Because codex resume brings a whole conversation back, you can stop mid-task and return tomorrow. Use one thread per coherent unit of work rather than one giant thread per project; resume the right one when you come back.

Note

Volatile: the slash roster and usage numbers change

What /status reports — model names, reasoning effort, your exact usage window — and the full set of slash commands evolve fast. Treat specific numbers and model IDs as live values, not memorized facts: check the slash-command reference at developers.openai.com/codex/cli/slash-commands and your usage at developers.openai.com/codex/pricing.

Try it: Run your first session: watch the loop, steer it, recover

Goal: feel the full first-session workflow end to end in one short run.

1) Start clean. In a small repo of yours (ideally one with a test command), run git status and confirm a clean tree — commit anything uncommitted. This is your safety checkpoint.

2) Launch with a task. Run codex "find and fix the most obvious bug in this project, then run the tests" — or just codex and type the prompt. Notice the full-screen TUI open.

3) Point it at context. In your prompt (or a follow-up), type @ and pick a relevant file with Tab/Enter so Codex has an exact pointer. If you have a screenshot of an error, paste it or relaunch with -i screenshot.png "...".

4) Watch the loop. Observe the four phases in the transcript: Codex inspects the repo, proposes an edit or command, pauses for approval, then iterates. Approve a step and watch it continue.

5) Steer it. Mid-run, press Ctrl+C to cancel a turn. Then, with the composer empty, press Esc Esc to edit your previous message and rewrite the instruction. Start it again and press Tab to queue a follow-up for the next turn.

6) Check your state. Run /status and note the active model, reasoning effort, and token usage. Run /diff to review what Codex changed without leaving the session.

7) Recover. Decide you don't want the change: drop to your shell and run git diff then git restore . (or git checkout -- .) to roll back — proving to yourself there's no /undo needed.

8) Resume. Quit, then run codex resume --last and confirm your conversation comes back with its full history.

Write three sentences: where did you see each phase of the loop, which steering key felt most useful, and what did the transcript-plus-git recovery story feel like compared to a tool that just edits files silently?

Key takeaways

  1. 1Start a session by running `codex` in your project directory; add an inline task like `codex "fix the login bug"` to begin working immediately. Where you launch determines what Codex can see.
  2. 2Every task runs the same agent loop: inspect the repo → propose edits/commands → pause for approval (per your mode) → iterate conversationally until done. The approval pause is what keeps you in control.
  3. 3Codex surfaces a transcript of every action and has NO `/undo` — you roll back through your normal git workflow (`git status` / `git diff` / `git restore`). Commit before risky tasks so you have a clean checkpoint.
  4. 4Steer mid-run with three keys: Ctrl+C cancels the current turn (interrupt is Ctrl+C, not Esc), Esc Esc edits your previous message and forks from there, and Tab queues a follow-up for the next turn.
  5. 5Attach context with `@` fuzzy file search (Tab/Enter to insert the path) and with images — paste into the composer or launch with `-i screenshot.png`. A good first prompt is a goal plus its context.
  6. 6Resume earlier work with `codex resume` (or `--last`); `/status` shows your active model, reasoning effort, and token usage. Slash rosters and usage numbers are volatile — verify them live.

Quiz

Lock in what you learned

Check your understanding

0 / 4 answered

1.You're in the middle of a Codex run and realize it's editing the wrong file. You want to stop it immediately. Which key do you press?

2.Codex finished a task that edited three files, and you've decided the whole change was a mistake. What is the correct way to roll it back?

3.You want Codex to look at a specific source file as part of your first prompt, without describing it vaguely. What's the fastest way to point it there?

4.Why does Codex pause partway through a task to show you a proposed edit or command before carrying it out?

Go deeper

Hand-picked sources to keep learning