Agentic AI AcademyAgentic AI Academy

Plan Mode & Goals

Separate research from execution for multi-step work

Beginner 11 minBuilder
What you'll be able to do
  • Use `/plan` to make Codex research and draft an approach before it edits anything, and have it interview you first on complex work
  • Set, pause, resume, view, and clear a task goal with `/goal`, and write goals that double as a measurable completion criterion
  • Decide when planning pays off (multi-file, uncertain, unfamiliar code) versus when to skip it (small, clear fixes)
  • Match reasoning effort to the task — low for fast work, medium/high for complex, xhigh for lengthy reasoning-heavy runs
  • Keep one thread per coherent unit of work, not one per project, and connect planning to verification
At a glance

For multi-step work, the highest-leverage move in Codex is to separate research from execution: let the agent investigate and draft a plan before it touches a single file. This lesson teaches plan mode (`/plan`), the `/goal` command that doubles as a completion criterion, how to dial reasoning effort to the task, and the session-hygiene habits that keep a thread coherent — plus the judgment of when planning earns its keep and when it just slows you down.

  1. 1The core idea: research before you let it loose
  2. 2Plan mode: think first, edit second
  3. 3Goals: a target that doubles as a finish line
  4. 4When planning pays off — and when to skip it
  5. 5Reasoning effort: how hard should it think?
  6. 6Session hygiene: one thread per unit of work

The core idea: research before you let it loose

When a task is small and obvious — "fix this typo", "rename this variable" — you just tell Codex and it does it. But the moment a task spans several files, touches code you don't fully understand, or could go several ways, letting the agent dive straight into edits is how you get a confident-looking change that solves the wrong problem.

The fix is a discipline borrowed from how good engineers actually work: separate research from execution. First understand the terrain and agree on an approach; then make changes. Codex gives you two purpose-built controls for exactly this split:

  • /plan — switch into plan mode, where Codex investigates the codebase and drafts an approach without editing files, so you can read and correct its thinking before any code moves.
  • /goal — pin down what done looks like as an explicit, persistent target the agent works toward and checks itself against.

Think of it like briefing a capable teammate on an unfamiliar codebase. You wouldn't say "go refactor the auth layer" and walk away. You'd ask them to look around, come back with a plan, and tell you how they'll know it worked. Plan mode and goals are how you have that conversation with Codex — and the payoff is that the actual editing run, once it starts, is far more likely to land on the first try.

Key insight

Plan is cheap; a wrong refactor is expensive

A planning turn costs you a minute of reading. A 10-file refactor that went the wrong way costs you a git reset, a re-explanation, and your trust in the tool. For anything non-trivial, front-loading the thinking is almost always the cheaper path.

Plan mode: think first, edit second

/plan switches Codex into plan mode and optionally sends a prompt in the same step. In plan mode the agent does its usual context-gathering — reading files, searching the repo, exploring structure — but instead of jumping to edits it produces a proposed plan you can read, push back on, and refine. You stay in the driver's seat for the part that matters most: deciding what will happen before it happens.

text
/plan add rate limiting to the login endpoint and update the tests

For genuinely complex or ambiguous work, do one better than handing over a one-line prompt: ask Codex to interview you first. Tell it to ask clarifying questions before drafting anything — "Before you plan, ask me whatever you need about the rate-limit policy, where config lives, and how we test middleware." This turns a guess into a conversation and surfaces the assumptions that would otherwise become silent mistakes.

A good plan-mode loop looks like this:

  1. /plan with a short description of the goal (or ask it to interview you).
  2. Read the proposed plan; correct anything wrong about the approach, scope, or order.
  3. Iterate until the plan is right — it's just text, so this is fast and cheap.
  4. Hand off to execution and let Codex carry out the agreed plan.

The reason this works: a plan is text you can fully review, whereas a diff is the consequence of decisions you never saw. Catching a flawed approach in the plan costs one re-read; catching it in a finished diff costs an unwind and a restart.

Tip

Make it interview you

For unfamiliar or high-stakes work, explicitly ask Codex to ask you questions before planning. The clarifications it surfaces — about edge cases, conventions, and where things live — are exactly the assumptions that turn into bugs when left implicit.

Goals: a target that doubles as a finish line

A goal is a persistent statement of what you're trying to achieve, set with /goal. Its quiet superpower is that it does double duty: it's both direction (what to work toward) and completion criterion (how the agent knows it's done). A well-written goal is the thing that lets Codex stop when the work is actually finished — rather than when the code merely looks done.

/goal is a small state machine. You can:

ActionWhat it does
setPin a new task goal that Codex works toward
viewShow the current goal
pauseTemporarily set the goal aside (e.g. to handle an interruption)
resumePick the paused goal back up
clearRemove the goal when the unit of work is finished

The quality of a goal is mostly the quality of its done-when. Vague goals ("make auth better") give the agent nothing to check itself against. Effective goals have a specific outcome, a measurable target, or explicit test criteria:

Weak goalStrong goal
"Speed up the dashboard""Dashboard initial render under 200ms on the staging dataset; verify with the existing perf test"
"Add rate limiting""Login endpoint returns 429 after 5 attempts/min per IP; npm test auth passes"
"Fix the flaky test""test_checkout_retry passes 20 runs in a row; root cause noted in the PR description"

The pattern to internalize is the done-when clause: a goal isn't finished until something true and checkable is true. Pair that with a runnable verifier (a test, a build, a lint) and Codex can close its own loop — running the check, reading failures, and iterating — instead of leaving you to be the verification step.

Example

A goal with a built-in finish line

/goal set Add input validation to the signup form: reject empty email and passwords under 8 chars with inline errors; the new test file signup.test.ts passes; no other routes change. Notice it states the outcome, the boundary (no other routes), and the exact check (the test passes). The agent now has a finish line, not just a direction.

When planning pays off — and when to skip it

Planning is a tool, not a ritual. Forcing a plan onto a one-line fix just adds latency and ceremony; skipping a plan on a sprawling refactor invites a confident wrong turn. The judgment call is what separates fluent Codex users from frustrated ones.

Reach for /plan (and usually a /goal) when the work is:

  • Multi-file — changes that ripple across modules, where order and blast radius matter.
  • Uncertain — there are several reasonable approaches and you want to choose deliberately.
  • Unfamiliar — you (or the agent) don't yet understand the code being changed.

Skip straight to execution when the work is small and clear — a typo, a rename, a one-line bug fix, a tweak to a value. The cost of a plan exceeds its benefit; just describe the change and let it run.

SituationPlan first?Why
Rename a local variableNoOutcome is obvious; no approach to choose
Fix a clear one-line bugNoNothing to research or sequence
Refactor across 8 filesYesOrder and scope need agreement before edits
"Make the API faster" (open-ended)YesMultiple approaches; pick deliberately
Touch code you don't understandYesResearch must precede action

A reliable heuristic: if you can't predict the diff, plan first. When you already know roughly what the change looks like, planning is overhead. When you don't, the plan is the work — and getting it right on paper is far cheaper than getting it wrong in code.

Tip

When unsure, ask for a plan

If you genuinely can't tell whether a task warrants planning, that uncertainty is itself the signal. Asking Codex to propose a plan first is the safe default — you can always glance at it and immediately approve a trivial one.

Reasoning effort: how hard should it think?

Plan mode decides whether the agent thinks before acting; reasoning effort decides how hard it thinks on every turn. It's a separate dial, set with the config key model_reasoning_effort in ~/.codex/config.toml, or changed live in a thread via /model (which adjusts model and effort together).

toml
# ~/.codex/config.toml
model_reasoning_effort = "high"   # minimal | low | medium | high | xhigh

Match the dial to the task:

EffortUse it for
lowFast, mechanical tasks where deep deliberation is wasted — quick edits, simple lookups
mediumThe recommended interactive daily-driver for most work
highComplex, multi-step changes that genuinely benefit from more deliberation
xhighLengthy, reasoning-heavy work where you don't mind waiting for the agent to grind

Higher effort buys you more careful reasoning at the cost of latency and tokens, so spending it on a typo is pure waste — and starving a hard refactor of it is false economy. A practical rhythm: keep your session at medium, bump to high or xhigh when you hit a genuinely thorny step, then drop back down. Effort and plan mode work together — a hard task often deserves both a plan and elevated effort.

Two facts worth pinning, because they rot: xhigh ("Extra High") is model-dependent — not every model exposes it — and the exact per-model defaults shift release to release. Don't memorize a default; check the live model pages.

Watch out

Volatile: defaults and effort levels move

Per-model default effort (and which models even support xhigh) changes as the catalog evolves — what's true this month may not be next. Verify the current set and defaults at the live model pages (https://developers.openai.com/codex/models) rather than hard-coding a value.

Session hygiene: one thread per unit of work

Planning and goals only pay off if the thread they live in stays coherent. The single most common mistake here is treating a Codex thread like a project-long chat window — pouring weeks of unrelated tasks into one ever-growing conversation. Don't. The rule is simple:

One thread per coherent unit of work — not one thread per project.

Why it matters: every turn shares the same context window. When you mix "add rate limiting," "fix the CSS bug," and "upgrade the test runner" into one thread, the agent drags irrelevant history into every reply — costing tokens, diluting focus, and inviting confusion between unrelated tasks. A goal is meant to scope a thread; when you /goal clear and the unit of work is done, that's usually your cue to start fresh.

Keep threads clean with a few habits:

  • Start a /new conversation (or a fresh codex session) when you move to an unrelated task.
  • /fork to branch off and explore a tangent without polluting the main thread, preserving the original transcript.
  • /compact to summarize a long-but-still-relevant conversation and reclaim tokens when a single unit of work runs long.
  • /goal clear when the unit is done — a natural boundary for wrapping up the thread.

This is the connective tissue of the whole workflow: plan sets the approach, goal sets the finish line and scopes the thread, reasoning effort sets the intensity, and session hygiene keeps each thread focused enough that the first three actually work.

Watch out

The 'one big thread' trap

A thread that accumulates many unrelated tasks bloats context, blurs goals, and degrades every answer. When a unit of work ends, end the thread (/new or a fresh session). Coherence per thread beats convenience of never switching.

Try it: Plan a real change, set a checkable goal, then execute

Goal: feel the difference between planning a multi-step change and diving straight in. 1) Pick a real but bounded task in a repo you know — ideally something multi-file or in code you don't fully understand (e.g. add input validation to a form and update its tests). 2) Set a goal with a done-when clause. Run /goal set ... with a specific outcome and an explicit, runnable check — for example, "reject empty email and passwords under 8 chars with inline errors; the new signup.test.ts passes; no other routes change." Then /goal view to confirm it's pinned. 3) Plan before editing. Run /plan and, for the unfamiliar parts, explicitly ask Codex to interview you first: "Before planning, ask me whatever you need about validation rules, where the form lives, and how we test it." Answer its questions, read the proposed plan, and correct anything wrong about the approach or scope. 4) Tune effort. If the plan reveals real complexity, bump reasoning effort to high for this run (via /model, or set model_reasoning_effort in ~/.codex/config.toml); for a simple plan, leave it at the daily-driver level. 5) Execute and let it self-check. Hand off to execution and watch Codex work toward the goal, running the verifier you specified and iterating on failures. 6) Practice the pause. Midway, /goal pause to handle a quick unrelated tweak, then /goal resume. 7) Close the thread cleanly. When done, /goal clear, then reflect in three sentences: did the plan change what you would have done by diving in, did the goal's done-when clause let the agent stop at the right moment, and would you have skipped planning if the task had been a one-line fix? This builds the instinct for when to separate research from execution — the judgment at the heart of this lesson.

Key takeaways

  1. 1Separate research from execution: for multi-step work, use `/plan` to make Codex investigate and draft an approach before it edits a single file — review the plan, not the consequences.
  2. 2For complex or ambiguous tasks, ask Codex to interview you (ask clarifying questions) before it plans, turning silent assumptions into an explicit conversation.
  3. 3`/goal` sets/views/pauses/resumes/clears a persistent task goal that doubles as the completion criterion; strong goals state a specific outcome, measurable target, or test criteria.
  4. 4Plan when work is multi-file, uncertain, or unfamiliar; skip planning for small, clear fixes. Heuristic: if you can't predict the diff, plan first.
  5. 5Set `model_reasoning_effort` (or use `/model`) to match the task: low for fast work, medium as the daily driver, high for complex, xhigh for lengthy reasoning-heavy runs — defaults and `xhigh` support are volatile, so check the live model pages.
  6. 6Keep one thread per coherent unit of work, not one per project; use `/new`, `/fork`, `/compact`, and `/goal clear` to keep context focused.

Quiz

Lock in what you learned

Check your understanding

0 / 4 answered

1.Why does Codex offer a dedicated plan mode (`/plan`) instead of just letting the agent start editing on every task?

2.Which of these is the strongest task goal to set with `/goal`?

3.A teammate asks whether they should plan before having Codex rename one local variable across a single function. What's the best guidance?

4.Your Codex thread has grown for two weeks and now mixes a rate-limiting change, a CSS fix, and a test-runner upgrade. Replies feel unfocused and token-heavy. What does good session hygiene recommend?

Go deeper

Hand-picked sources to keep learning