GUIDES / CODEX WORKFLOWS

Codex /goal: run a persistent coding objective

Codex /goal keeps a defined objective attached to a thread across continuation turns. Use it when the next coding step depends on test or benchmark evidence; use a normal prompt for a small, one-off task. Start with /goal <objective> and state the passing evidence, allowed scope and blocked stop condition.

In the CLI, /goal inspects the objective; /goal pause, /goal resume and /goal clear manage it. The desktop app uses progress-row controls. Work can stop on success, pause, clear, interruption, budget limit or a blocker requiring your input.

Adapt the six-part Goal template ↓

Documented from Codex 0.128.0 in the CLI-oriented quickstart. This does not promise hours of uninterrupted execution.

1. Check your Codex surface and version

The OpenAI Cookbook still states that Goals are available starting in Codex 0.128.0. Its installation and version-check instructions use the CLI. Run codex --version in your terminal to check that installation; this number is not a documented minimum desktop-app or IDE-extension version.

Current long-running-work documentation explicitly describes Goal mode in the interactive CLI, desktop app and IDE extension. Their controls are not interchangeable:

Documented Codex Goal surfaces
SurfaceConfirmed path and limit
Interactive CLIStart with /goal <objective>; view and manage with the documented slash commands below.
Desktop appStart with /goal. Inspect progress and use pause/resume/edit/clear buttons above the composer. Availability depends on environment and access.
IDE extensionCurrent docs explicitly say /goal starts Goal mode for the open workspace. Exact lifecycle subcommands and minimum extension version: UNKNOWN.
Web / cloudThe web guide describes ChatGPT Work prompts instead of this command set. Equivalent Codex cloud /goal support: UNKNOWN from the sources checked.

2. Start, inspect, pause, resume or clear

In a supported interactive CLI session, enter /goal followed by the outcome and acceptance criteria. These are Codex composer commands, not shell commands. The Cookbook lifecycle reference documents the forms below.

For the desktop app, type /goal to start, then use the progress row above the composer to inspect progress, pause, resume, edit or clear. The IDE docs confirm starting Goal mode, but do not establish identical pause/resume/clear command syntax there. That detail is UNKNOWN in the sources checked.

Clearing the Goal removes the objective. The cited documentation does not describe it as undoing edits; inspect your diff separately. Resuming a paused Goal is also different from reopening a saved CLI session.

/goal <objective>
Set the objective and its completion criteria.
/goal
Inspect the current Goal in the documented CLI lifecycle.
/goal pause
Pause an active Goal.
/goal resume
Resume a paused Goal.
/goal clear
Remove the current Goal.

3. Use a Goal when the next step depends on evidence

A normal prompt asks for a result from the current request. A Goal keeps an outcome attached to the thread so Codex can revisit the evidence after a turn and decide whether another attempt is warranted. The benefit is a persistent objective plus repeated verification, not prompt length.

For example, a failing test may lead to reproduction, a small patch, a regression check and another hypothesis. A benchmark improvement can still miss the target. In either case, an intermediate result is not enough to declare the Goal complete.

The official continuation rules require an active Goal, available budget and an idle thread without queued input or other pending work. This is conditional continuation across turns; it does not guarantee an uninterrupted run lasting hours. The Goal belongs to this thread, not global memory or every task in the project.

4. Write a Goal with a checkable finish line

OpenAI's Goal-writing guidance identifies six useful parts. Treat them as questions to answer, not a mandatory file format:

  • Outcome: what observable result should exist?
  • Verification surface: which test, measurement or artifact can confirm it?
  • Constraints: which behavior must remain unchanged?
  • Boundaries: which files, tools, data and environments are in scope?
  • Iteration policy: what evidence should guide the next attempt?
  • Blocked stop condition: which missing input or exhausted path requires a report back?

This original AgentSkillsHub template reorganizes those ideas. Replace every placeholder before use; it is not an official required syntax. If the target is still vague, ask Codex to draft it first and review the finish line before activating the Goal.

NOT EXECUTED FOR THIS GUIDE
/goal Deliver <observable result> in <named repository or task area>.
Acceptance evidence: <exact test, benchmark or artifact and passing criteria>.
Preserve: <behavior, compatibility and existing work that must stay intact>.
Allowed scope: <files, tools, data and environments>; exclude <prohibited actions>.
After each attempt, record the result and select the next experiment supported by it.
If <specific missing input or exhausted permitted path> prevents progress, stop with the evidence, blocker and smallest input needed.

5. Four bounded coding examples

These are original, documentation-based examples—not completed runs. File names, measurements and trial counts are illustrative acceptance criteria. Substitute the actual repository paths, commands and approved target versions before starting. Combine each Goal with its verification, constraints and stop condition.

Fix a flaky test

/goal Diagnose and fix the intermittent session-expiry test in tests/session-expiry.test.ts.

Verification
Reproduce the original failure, then pass 30 consecutive runs under the same recorded seed and environment settings, plus the session regression suite. Record failures as well as passes.
Constraints
Limit edits to session handling and related tests. Keep assertions and intended timeout behavior; do not skip tests or add retries to hide failures.
Stop condition
If the failure cannot be reproduced within 10 baseline runs, or the test requires unavailable credentials, report the limitation. Passing a finite sample is evidence, not proof that all flakiness is gone.

Reach a benchmark threshold

/goal Bring p95 search latency below 150 ms on the local search-load benchmark.

Verification
Use the fixed fixture and concurrency setting documented in the repository. Save three post-warmup measurements and require all three to meet the target while the search correctness suite passes.
Constraints
Change only the search service and its tests. Keep results and public API behavior unchanged; do not reduce benchmark load or use a paid load-testing service.
Stop condition
If the fixture or stable measurement environment is unavailable, or three distinct measured changes fail to improve the baseline, report the experiments and ask for the missing input or revised scope.

Migrate a dependency with test parity

/goal Migrate packages/reporting to the already-approved target version of its CSV library.

Verification
Compare the baseline and migrated output using the same export fixtures; pass the package tests, type check and documented integration test. Record any pre-existing failure separately.
Constraints
Keep exported columns, ordering and encoding unchanged. Edit only this package, its tests and the necessary lockfile entries; do not upgrade unrelated dependencies.
Stop condition
If the target version is unspecified, an incompatible API requires a product decision, or the integration test needs unavailable infrastructure, stop and describe the exact dependency.

Produce an evidence-backed repository audit

/goal Audit the authorization checks in the repository HTTP handlers and write a reviewable findings report.

Verification
Inventory the handlers and map every finding to a file, line and reproducible local check or explicit evidence gap. Mark each handler reviewed or blocked.
Constraints
Use repository code and existing local test fixtures only. Do not patch application code, access production, export sensitive data or send findings externally.
Stop condition
If a required module or fixture is missing, stop with the covered paths, blocked claims and the specific material needed. Do not turn an untested suspicion into a confirmed vulnerability.

6. Understand completion and stopping conditions

The Cookbook describes success, pause, clear, interruption, budget limits and blockers requiring user input as stopping conditions.

  • Success: inspect the specified evidence and preserved constraints. A plausible explanation or partial improvement is insufficient.
  • Pause or clear: the user controls whether the objective should continue or remain attached.
  • Interruption: the documented dispatcher pauses the objective; check its state before expecting further work.
  • Budget limit: substantive work stops with progress and blockers summarized. Exhausting a budget is not completion.
  • Blocked: identify the missing input or decision and the evidence already collected; do not label an unresolved objective successful.

Plan-only work does not trigger automatic continuation. The Cookbook also says that a continuation without a tool call suppresses the next automatic continuation, preventing empty looping. If a Goal appears idle, check its state, pending input, permissions, budget and evidence before asking it to resume.

The sources checked here do not specify one universal budget-setting command or default budget across surfaces. Those details are UNKNOWN; use the controls actually available in your client. A natural-language experiment cap in a prompt is a task instruction, not proof of an enforced billing limit.

7. Do not use /goal for every task

Use a normal prompt for a single-file edit, a well-defined one-off bug fix, a short explanation or work that needs no iterative verification. A longer instruction alone does not make Goal mode useful.

Do not activate a vague target such as “improve this repository.” First choose a measurable result. If the evidence source is unavailable, resolve that dependency or define an honest report as the outcome.

Do not leave continuing paid API calls, production writes or external actions open-ended. Establish permitted actions, limits and approval checkpoints before starting. These selection guidelines follow the official advice on when not to use Goals, with additional editorial recommendations for spending and production boundaries.

8. Separate persistence from permission

Starting a Goal does not widen tool access or replace the existing sandbox and approval policy. The current long-running-work guide explicitly preserves those controls; approval documentation explains their separate roles.

Codex may run tests, benchmarks, tools or browser checks only within the access and authorization already available. Repeated work can consume model allowance and, where authorized tools use them, external API credits. A Goal does not supply paid-service authorization.

As an editorial setup checklist, name the allowed repository and environment, whether writes are permitted, and who approves production deployment, destructive database operations, paid API usage, external messages and account changes. For a local coding trial, explicitly exclude those actions unless they are part of the approved task.

When the work stops, review the diff, measurements, test output and unresolved claims. Our agent workflow case studies show ways to organize evidence. Use the Codex Skills guide when you need reusable task instructions alongside the Goal; a skill and a persistent objective serve different purposes.

FAQ

What version introduced Codex Goals?

The current OpenAI Cookbook says Goals are available starting in Codex 0.128.0 and gives CLI installation steps. Minimum desktop-app and IDE-extension versions are UNKNOWN in the sources checked.

Will /goal keep Codex running for hours?

There is no fixed runtime guarantee. Continuation depends on an active Goal, budget, an idle thread and no pending input or work. Success, user controls, interruption or a blocker can stop it earlier.

How do I pause, resume or clear a Goal?

The documented CLI forms are /goal pause, /goal resume and /goal clear; /goal shows the current Goal. In the desktop app, use the Goal progress-row buttons. Identical IDE lifecycle subcommands were not confirmed.

Does clearing a Goal undo its file changes?

The documentation describes clearing the current Goal, not reverting files. Inspect the working-tree diff and use your normal reviewed rollback process for any changes you want to undo.

Does Goal mode give Codex more permissions?

No. Existing sandbox and approval controls remain in effect. Define the allowed files, tools, environments and external actions before starting.

Primary sources and verification limits

Source-checked 2026-09-28. These official pages were read for the version, controls, continuation rules and surface-specific differences. Commands and examples are documentation-based. We did not set, pause, resume or clear a Goal, or run one to completion for this guide. Website QA does not establish Codex runtime behavior.