Claude Code /loop and /goal vs OpenAI Codex /goal
Tech
AI
Claude Code
Codex
OpenAI

Claude Code /loop and /goal vs OpenAI Codex /goal

How I use Claude Code /loop, Claude /goal and OpenAI Codex /goal to turn AI coding agents into verifiable long-running workflows.

Uygar DuzgunUUygar Duzgun
Jun 25, 2026
11 min read

I have started treating AI coding agents less like chat windows and more like workers with contracts. The difference is not the model. The difference is whether the agent knows what to keep doing, how to prove progress, and when to stop.

That is where /loop and /goal matter.

Claude Code now exposes both ideas directly: /goal for a completion condition, and /loop for repeated prompts while a session stays open. OpenAI Codex has /goal as a documented command, and OpenAI also documents eval-driven improvement loops as a workflow. The important detail: I would not describe OpenAI Codex as having the same official /loop slash command unless that appears in your installed command list. In the current docs I checked, /goal is official; “loop” is the pattern.

That distinction matters because these tools look similar from the outside, but I use them for different jobs.

Quick answer

Use /goal when the agent should pursue one durable outcome until a clear condition is true.

Use /loop when the agent should repeat a prompt on an interval or self-paced rhythm while the session remains open.

Use an eval-driven loop when the output can be scored and improved repeatedly: code quality, visual quality, performance, SEO, migrations, tests, or any task where each pass can be measured.

The practical rule is simple: a goal needs a finish line; a loop needs a cadence; both need verification.

What Claude Code /goal does

Claude’s command reference describes /goal [condition|clear] as a way to set a condition so Claude keeps working across turns until that condition is met. The hook docs add a useful implementation detail: /goal behaves like a built-in shortcut for a session-scoped stop condition.

In plain English, /goal tells Claude:

Prompt — Copy & Paste
Do not treat one assistant response as the end of the job. Keep going until this condition is actually true.

That is powerful, but only if the condition is concrete.

Weak:

text
/goal Make the app better

Useful:

text
/goal Fix the checkout bug, keep all existing payment behavior intact, and stop only when pnpm test, pnpm build, and the Playwright checkout path all pass.

The second version gives Claude a target, boundaries, and proof. It can decide the path, but not redefine success halfway through.

I use /goal for work like:

large refactors with tests after every checkpoint
migration work where old behavior must stay intact
production bug hunts where the root cause is not obvious
cleanup tasks that require many small edits
UI fixes where screenshots or browser checks define done

The moment a task has multiple unrelated outcomes, I do not use one big goal. I split it. One goal per outcome is cleaner and easier to trust.

What Claude Code /loop does

Claude’s command reference lists /loop [interval] [prompt] as a bundled skill. It runs a prompt repeatedly while the session is open. You can give it an interval, let Claude self-pace, or omit the prompt and let it use a configured maintenance prompt where available.

That makes /loop feel more operational than /goal.

Examples:

text
/loop 5m check if the Vercel preview deployment is ready, then verify /blog and /api/health
text
/loop take the next unchecked item in PRODUCTION_READINESS.md, fix it, run the relevant test, then update the checklist
text
/loop every 10m check CI, summarize failures, and stop escalating only after the latest run is green
Recommended reading

The best use case is repeated checking or repeated small work units. In my hybrid AI code review loop, the useful pattern was not “write forever.” It was: take one checklist item, implement it, ask another model to review, run the build, tick the box, repeat.

That is what makes /loop dangerous if you write a lazy prompt. If the prompt does not say what to verify, the agent can keep doing plausible work that nobody should trust.

What OpenAI Codex /goal does

OpenAI documents /goal for Codex in both the app and CLI. The Codex guide frames it as a durable objective for long-running work, especially when the task has a clear success condition and validation loop.

The Codex CLI command reference lists /goal as the command to set, pause, resume, view, or clear a task goal. The app docs say the same idea in product terms: a goal is persistent, visible, and can be paused or resumed.

A good Codex goal looks almost identical to a good Claude goal:

text
/goal Complete the Next.js 16 migration without changing public routes. Stop only when pnpm build passes, the homepage loads, /blog loads, and the changed routes return 200.

For Codex, I like goals that name:

the exact objective
the files or docs it must inspect first
what not to change
the validation commands
the stop condition
how often it should report progress

OpenAI’s own guidance for difficult problems is close to how I already work: give Codex an evaluation system, make focused improvements, re-run the score, inspect artifacts, and keep going until the score is good enough.

That is the heart of agentic work. Not autonomy for its own sake. Autonomy tied to measurement.

Does OpenAI have /loop?

This is where people can get sloppy with the wording.

Claude Code has a documented /loop command. OpenAI Codex has documented loop-style workflows: eval loops, repair loops, goal mode with validation, hooks, and automations. But in the current Codex slash command reference I checked, I found /goal, /plan, /review, /status, /mcp, and many others, not an official /loop command equivalent to Claude’s.

So my wording is:

Claude Code: /goal and /loop are commands.
OpenAI Codex: /goal is a command; loop is a workflow pattern.

That is not a weakness. It just changes how I set it up. In Codex, I usually express the loop inside the goal or prompt:

text
/goal Improve this component until the visual regression score is above 95%. Make one focused change at a time, run the screenshot comparison after each change, keep a score log, and stop when the target holds twice in a row.

That gives Codex the same operating rhythm without pretending there is a separate /loop slash command.

My practical setup

For serious work I use a five-layer pattern.

1. A written target

I start with a short plan or checklist. It can be `PLAN.md`, `PRODUCTION_READINESS.md`, a GitHub issue, or a plain prompt. The format matters less than the checkability.

A weak task says “improve the article system.”

A strong task says “prevent publish when external URLs return 404, soft 404, wrong content-type, or redirect to the wrong target; keep draft saves allowed; prove with build and a focused validation case.”

That is the kind of instruction an agent can keep acting on.

2. One owner model

Pick who is driving. Claude may be the implementer. Codex may be the implementer. Do not let both edit the same files at the same time unless you have worktrees or a strict handoff. Autonomy without ownership becomes merge conflict theater.

3. A second opinion

Recommended reading

For higher-risk work I still like model-to-model review. I have written about my AI peer-review bridge because it catches different failure modes than a single model checking itself.

The reviewer can be read-only. It does not need write access to be useful. It needs the diff, the goal, the risky files, and permission to say “this is wrong.”

4. A hard validator

Tests beat confidence. Builds beat summaries. Browser screenshots beat “it should render.” Logs beat vibes.

For web work, that usually means:

bash
pnpm build
pnpm lint
pnpm test

plus route checks, screenshots, or Playwright flows when the task is user-facing.

For content workflows, my preference is URL QA before publish: not only “did the link return 200,” but “did it reach the page the article claimed?” That is the same principle. The validator should verify the thing the reader actually experiences.

5. A stop rule

This is the part people skip.

A loop without a stop rule becomes expensive. A goal without a stop rule becomes vague. A stop rule should be boring and literal:

stop when all checklist items are checked and build passes
stop when deployment is READY and the target route returns 200
stop when the score is above 90 for two consecutive runs
stop and report if the same blocker appears three times
stop if the task requires a secret, account approval, or business decision

That last line is important. Good agents do not hide uncertainty. They surface it.

When I use each one

SituationBest toolWhy
------:---
One large task with a clear definition of done/goalThe agent can keep moving toward a durable end state
Checking deployment status every few minutesClaude /loopThe same check needs to run repeatedly
Improving a generated artifact against a scoreEval loopThe score tells the agent whether the last pass improved anything
Cleaning a checklist item by item/loop or /goalUse /loop for repeated items, /goal for the final outcome
Research with uncertain directionNormal prompt or plan modeDo not start autonomy before the target is clear
Sensitive production actionHuman approval gateAgents can prepare the action, but should not silently execute it

Copy-paste prompts

Claude Code /goal

text
/goal Finish this bug fix without changing unrelated behavior. First read AGENTS.md and the relevant route/component files. Make small commits in logic only, run pnpm build and the focused regression path, and stop only when the original bug no longer reproduces and all verification passes.

Claude Code /loop

text
/loop take the next unchecked item in TODO.md, inspect the real files first, make one focused fix, run the relevant validation command, update the checkbox only after verification, and report any blocker instead of skipping it

OpenAI Codex /goal

text
/goal Complete the migration described in PLAN.md. Preserve public behavior, keep unrelated files unchanged, run the listed validation commands after each milestone, keep a short progress log, and stop only when every milestone is complete and the final build passes.

Codex eval-driven loop prompt

text
I want this as an eval-driven improvement loop. Find or create the command that scores the output. Make one focused improvement at a time, re-run the score after each change, inspect any generated artifact directly, log score changes, and keep iterating until the target score is reached twice in a row. If the score stops improving, explain the bottleneck and stop.

Common mistakes

The first mistake is using /goal as a motivational sentence. “Make this production ready” is not a goal. It is a mood.

The second mistake is using /loop without a validator. If every iteration ends with an unchecked claim, the loop is just repetition.

The third mistake is bundling unrelated work. “Fix auth, redesign the dashboard, update pricing, and clean SEO” should be four tasks, not one heroic autonomous run.

Recommended reading

The fourth mistake is giving the agent write access before it understands the repo rules. In my own projects, I want agents to read `AGENTS.md`, respect deploy rules, avoid secrets, and verify before claiming success. The control layer around the model matters as much as the model. That is why I keep coming back to MCP developer workflows: tools, permissions, evidence, and replayable actions are what turn a clever chat into an operational system.

The real point

The interesting thing about /loop and /goal is not the slash command syntax. The interesting thing is the shift in responsibility.

A normal prompt says: answer me.

A goal says: finish this, and know what finished means.

A loop says: keep checking or improving until the condition changes.

That is how I want AI coding agents to work. Not as magic. Not as unsupervised chaos. As workers with a contract, a validator, and a clean stop rule.

If you use Claude Code, /loop is the fastest way to turn a repeated operational check into something the agent can handle while you keep working. /goal is the better tool when the work has one durable end state.

If you use OpenAI Codex, /goal gives you the durable objective, and the loop belongs in the validation design: tests, evals, artifacts, hooks, progress logs, and a stop condition the agent cannot quietly redefine.

That is the pattern I trust: not “let the AI run,” but “let the AI run inside a system that can tell it no.”

Sources checked

FAQ

Does OpenAI Codex have a /loop command?+
OpenAI documents /goal as a Codex slash command and describes eval-driven improvement loops as a workflow. I did not find an official Codex /loop slash command in the current Codex command reference.
What is Claude Code /loop best for?+
Claude Code /loop is best for repeated checks while the current session stays open, such as polling a deployment, running a maintenance prompt, or iterating through a small queue with verification after each pass.
When should I use /goal instead of /loop?+
Use /goal when there is one durable objective and a clear definition of done. Use /loop when you want the same prompt or maintenance check to run repeatedly.
Can /goal replace tests?+
No. /goal gives the agent a persistent target, but the target still needs proof. The safest pattern is to pair /goal with tests, builds, screenshots, logs, or another concrete validation command.

Recommended for you

Hybrid AI Code Review: Claude Opus 4.8 + Codex in a Loop

Hybrid AI Code Review: Claude Opus 4.8 + Codex in a Loop

Two frontier models in a loop: Claude Opus 4.8 writes each fix, Codex reviews it through my AI bridge, and a real build votes. 39 production fixes, none by hand.

7 min read
MCP Developer Workflows: The Real Control Layer

MCP Developer Workflows: The Real Control Layer

MCP developer workflows are the control layer for production agents: scoped tools, approval gates, source-backed context, and replayable actions.

8 min read
AI Peer Review: Free Skill Bridging Claude, Codex, Gemini

AI Peer Review: Free Skill Bridging Claude, Codex, Gemini

A free open-source Claude Code skill that lets Claude, Codex, and Gemini review each other's code via CLI. Install in 30 seconds.

9 min read