Skip to content

The /goal Command: Goal-Directed Autonomous Runs

You’re three hours into a migration. The agent finishes a turn, you read the diff, you type “good, keep going,” it finishes another turn, you type “keep going” again. You’re not directing anymore — you’re a clock that says tick. The work is clear, the stopping condition is obvious (“all tests green, all call sites migrated”), and yet every step waits on you pressing return.

The /goal command removes you from that loop. You give the agent one objective and one verifiable finish line, and it keeps working — planning, acting, testing, reviewing — until a checker confirms the goal is met or a budget runs out. Your job shifts from typing every step to designing the finish line.

  • What /goal actually does and how the plan → act → test → review loop terminates
  • Exactly how to enable and drive it in Claude Code and in Codex
  • What to reach for in Cursor, which has no native /goal
  • How to write an objective and stopping condition the agent can actually verify
  • When /goal is the right tool versus /loop

A normal agent turn ends when the model decides it has said enough. /goal replaces that with an explicit, checkable condition. Under the hood it runs a loop:

  1. Plan — decide the next concrete step toward the objective.
  2. Act — make the change.
  3. Test — run the validation commands you defined.
  4. Review — a checker asks “is the stopping condition met?” If no, loop back to plan. If yes, stop.

The pattern has an older nickname — the “Ralph loop” — after the idea of re-feeding an agent the same goal until it converges. The difference with /goal is that the loop, the checker, and the budget are built into the tool instead of being something you script by hand.

The whole thing lives or dies on the stopping condition. “Make the app better” never terminates. “Every test in tests/ passes and npm run typecheck exits 0” terminates the moment it’s true.

/goal is built in. Set an objective with /goal <objective> and the session keeps working turn after turn until the goal is met, rather than stopping after one response. A fast checker model evaluates the stopping condition after each round and ends the run when it’s satisfied.

Use it when the work spans many turns toward a condition you can state precisely — a migration with parity checks, a refactor gated by a test suite, a bug you can reproduce with a command. To run on an interval instead of toward a condition, use /loop; to run unattended on Anthropic infrastructure, use Routines.

The quality of an autonomous run is decided before it starts, in how you frame the objective. Five rules carry most of the weight:

  1. One objective, one stopping condition. Bundling “migrate the API and improve test coverage” gives the checker two finish lines and it will thrash between them. Split them into two runs.
  2. Make the condition a command. “Looks good” isn’t checkable; npm test exiting 0 is. Hand the agent the exact validation commands that prove progress — they become the gate every iteration must pass.
  3. Point it at what to read first. Name the files, the plan, or the docs that define “correct.” An agent that has to guess the target wanders.
  4. Ask for checkpoints. Request a short progress log each round. It gives you a place to interrupt and makes a long run auditable after the fact.
  5. Bound the blast radius. State what’s out of scope and what it must never touch. A loop with no boundaries will happily refactor your auth layer to make a test pass.

They sound similar and solve different problems:

  • /goal runs until a condition is true. The schedule is “as fast as possible until done.” Reach for it for convergent work with a clear finish line.
  • /loop runs on a cadence. The schedule is “every N minutes” (or a self-chosen interval). Reach for it for open-ended monitoring — polling a deploy, babysitting a PR — where there may be no single finish line.

A common combination: a /goal run drives a feature to “tests green,” then a /loop watches the resulting PR for CI failures and review comments.