Experimental Codex CLI Feature

Follow a Goal
with Codex

Give Codex a durable objective for long-running work. Use /goal when a task needs Codex to keep working across turns toward a verifiable stopping condition.

Use /goal when you want Codex to keep working toward one durable objective instead of stopping after one normal turn. It is useful for work that has a clear target, a validation loop, and enough room for Codex to make progress without asking you to steer every step.

  • Long-running coding work with a clear success condition and validation loop
  • Code migrations, large refactors, deployment retry loops, experiments, and side projects
  • Teams that need to run long experiments with clear success criteria
  • Codex works independently for multiple hours without needing your input
# Enable /goal in config.toml
[features]
goals = true

# Start a goal
$ /goal Migrate auth service from REST to GraphQL

# Check status
$ /goal

# Control the run
$ /goal pause
$ /goal resume
$ /goal clear

A durable objective that keeps Codex working

A good goal is bigger than one prompt but smaller than an open-ended backlog. It defines what Codex should achieve, what it should not change, how it should validate progress, and when it should stop.

🎯

Name One Objective

Define exactly one durable objective and one stopping condition. Codex knows what "done" means before it starts.

Clarity
πŸ“‹

Point to Context

Point Codex at the files, docs, issue, logs, or plan it must read first before making any changes.

Context
βœ…

Define Validation

Define the commands or artifacts that prove progress. Codex works in checkpoints and keeps a short progress log.

Validation
πŸ”„

Iterate Autonomously

Codex proposes changes, runs experiments, reads results, and keeps only the ideas that improve the target metric.

Autonomy
⏸️

Pause and Resume

Pause, resume, or clear the goal when the run is done, blocked, or changing direction.

Control
πŸ“Š

Compact Reports

Ask for compact progress reports that name the current checkpoint, what was verified, what remains, and whether Codex is blocked.

Visibility

The goal loop

The loop stays small so each improvement is easy to judge. One objective, one stopping condition, and a clear validation step keep the system narrow enough to inspect and strong enough to iterate.

Step 01

Set the Objective

Name one objective and one verifiable stopping condition. Codex reads the instructions and understands the experiment target.

Step 02

Provide Context

Point Codex at the files, docs, issue, logs, or plan it must read first before making any changes.

Step 03

Define Progress

Define the commands or artifacts that prove progress. Tell Codex to work in checkpoints and keep a short progress log.

Step 04

Let Codex Run

Codex works independently for hours. It stops when it is fairly confident it has reached the stopping condition.

What /goal is best for

A good goal works well for migrations, large refactors, experiments, and prototypes where Codex can make scoped progress and validate each step.

Code Migrations

Migrate projects from one stack to another. Codex runs the migration, verifies visual parity, and keeps screens identical using automated checks.

/goal Migrate from [legacy] to [target]. Verify all screens stay the same.

Large Refactors

Refactor large codebases with automated testing after each checkpoint. Codex proposes changes, runs tests, and keeps only the improvements.

/goal Refactor [module]. Run tests after each checkpoint. Stop when all pass.

Prototype Creation

Create polished first versions of apps, games, or features from scratch. Use a PLAN.md to guide the creation precisely.

/goal Implement PLAN.md. Create tests for each milestone. Verify output.

Prompt Optimization

Optimize prompts against eval results. Codex inspects failures, updates the prompt, reruns evals, and iterates until the score improves.

/goal Optimize prompts until eval suite reaches [target score].

How to set up /goal

Enable the experimental feature, set your first goal, and let Codex work independently. The setup takes seconds.

βš™οΈ

Enable the Feature

/goal is an experimental Codex CLI feature. Enable it from /experimental, or add goals = true under [features] in config.toml.

πŸš€

Set a Goal

Run /goal <objective> to start. Check the current goal with /goal. Use /goal pause, /goal resume, or /goal clear to control the run.

πŸ”„

Let It Run

Codex works independently for multiple hours without needing your input. It stops when it is fairly confident it has reached the stopping condition.

πŸ“

Ask Codex to Help

Start by having a conversation about what you want to build, then ask it to directly set a goal and start working. Codex will handle the rest.

Turns coding objectives into something an agent can complete

Most coding tools automate execution. /goal automates the cycle of defining an objective, working toward it, validating progress, and knowing when to stop.

Clear stopping condition
Codex knows what "done" means before it starts
If the goal is a migration, "done" means the new path passes contract tests. If it is a prototype, "done" means the app builds and matches expectations.
Independent execution
Works for hours without steering
During a goal, Codex can work independently for many hours without you having to check in. Think of /goal as a background task you don't need to monitor.
Compact visibility
Progress reports you can trust
Ask for compact progress reports. A useful status names the current checkpoint, what was verified, what remains, and whether Codex is blocked.
Tighten, don't clutter
Keep the goal narrow
If the status becomes vague, tighten the goal rather than adding more ad hoc instructions. Name the checkpoint, the proving command, and the stopping condition.

Frequently asked questions

The fastest answers to the questions people ask first about Codex /goal.

What is Codex /goal?
Codex /goal is an experimental Codex CLI feature that lets you give Codex a durable objective for long-running work. Instead of stopping after one normal turn, Codex keeps working toward a verifiable stopping condition, independently, for multiple hours.
How do I enable /goal?
Enable it from /experimental in the CLI, or add goals = true under [features] in your config.toml file. Then use /goal <objective> to start.
What kind of work works well with /goal?
Code migrations (migrating from one stack to another), large refactors where Codex can run tests after each checkpoint, experiments and games where Codex can keep improving a working artifact, and prompt optimization against eval results.
How do I control a running goal?
Use /goal to inspect status while it runs. Use /goal pause, /goal resume, or /goal clear when the run is done, blocked, or changing direction.
How does Codex know when to stop?
Codex stops when it is fairly confident it has reached the stopping condition you defined. You should think of /goal as a background task you don't need to monitor.
What makes a good goal?
A good goal is bigger than one prompt but smaller than an open-ended backlog. It defines what Codex should achieve, what it should not change, how it should validate progress, and when it should stop.

Grounded in official documentation

Every claim on this page is based on the official OpenAI Codex documentation so you can verify the details yourself.