
Free guide · by Cooper Simson
Let Claude Work 8 Hours While You Sleep
The exact condition-builder prompt I use, 5 ready-to-paste long-running goal templates, the drift checkpoint pattern that stops 90% of long-run failures, and the Codex parity context most coverage skips.
No email required. Use it today.
Anthropic shipped /goal in Claude Code 2.1.139. You type one command, write a completion condition, and Claude keeps working across turns until the condition is met. This is the operator pack: the condition builder prompt, the drift checkpoint pattern, and 5 ready to paste goal templates so you can run your first autonomous /goal tonight.
What You'll Learn
- The exact condition builder prompt that makes /goal runs actually finish
- 5 ready to paste long running goal templates (test migration, issue backlog, file splits, doc backfill, dep upgrades)
- The drift checkpoint pattern that stops 90% of long run failures
- How Claude /goal compares to Codex's /goal
What /goal Actually Does
You type one command, write a completion condition, and Claude keeps working across turns until the condition is met. A small fast model evaluates after every turn whether the condition holds. If not, Claude starts another turn. The goal clears automatically once met. One goal can be active per session. The condition can be up to 4,000 characters.
What this unlocks: substantial autonomous work with a verifiable end state. Migrate a module to a new API until every call site compiles. Implement a design doc until acceptance criteria hold. Split a large file into focused modules under a size budget. Work through a labeled issue backlog until the queue is empty. Any task where you can name the finish line, /goal can drive to it.
The one thing to internalize: the evaluator only reads what Claude has surfaced in the conversation. It does not run commands independently. So your condition must be something Claude's own output can demonstrate. "All tests pass" works because Claude runs the tests and the result lands in the transcript. "The code is cleaner" fails because there is nothing to read.
How Claude /goal Compares To Codex's /goal
OpenAI shipped /goal in Codex on May 3, 2026, about ten days before Anthropic shipped it in Claude Code. For a stretch of weeks, /goal was the one capability tipping serious autonomous coding workflows toward Codex. Anthropic just closed that gap.
What Codex shipped first:
- OpenAI's own engineering blog documents a 25 hour autonomous Codex run that used 13M tokens and generated 30k lines of code (developers.openai.com/blog/run-long-horizon-tasks-with-codex)
- Cursor's team called Codex's agent loop "much better at extended autonomous work: following instructions, keeping focus, avoiding drift" (cursor.com/blog/scaling-agents)
- CloudYeti called Codex /goal "the most consequential feature OpenAI has ever shipped in Codex"
- Paul J Lipsky's walkthrough was titled "Claude Cowork Killer" specifically because of /goal
- The r/codex thread "/goal feature is one of the most useful things I have ever seen" pinned the developer community sentiment in May
Where each pulls ahead in practice: Codex /goal gives more verbose progress reporting between turns; some users prefer the live visibility, others find it chatty. Claude /goal has tighter integration with the rest of Claude Code's plugin and skill system. On well scoped engineering work (test migrations, doc backfills, dependency bumps, file splits), both platforms finish at parity. The dimension that matters most is condition writing quality, which is the same skill regardless of platform. The condition builder prompt below works identically for both.
The practical takeaway:
- If you have been using Codex specifically for /goal, you do not have to anymore. Claude has parity
- If you have been waiting for Anthropic to ship something like this before going autonomous, your wait is over
- If you run both stacks, the condition builder prompt and drift checkpoint pattern apply to both
The /goal Condition Builder Prompt
Most people write conditions Claude cannot verify, and the run bails early or drifts. Instead of hand writing conditions, have Claude write them using Anthropic's own 3 part framework. Paste this prompt into any Claude Code session inside the project you want to automate:
Look at the project I'm currently in. Write me a /goal condition with:
1. One measurable end state (a test result, build exit code, file count, empty
queue)
2. A stated check Claude can run to prove it (e.g., 'npm test exits 0', 'git
status is clean')
3. Constraints that must not change on the way there (e.g., 'no other test file is
modified', 'no new dependencies added')
Add a turn or time bound (e.g., 'or stop after 30 turns') so it can't run forever.
Then show me the final /goal command formatted for copy-paste, and tell me what
success will look like in the conversation transcript so I can verify the evaluator
will fire correctly.
Why this works: the prompt forces Claude to commit to the verification mechanism BEFORE the run starts. If the condition cannot be proven from Claude's own output, the prompt forces a rewrite. Hand written conditions skip this step and usually fail because of it.
The Drift Checkpoint Pattern
The number one failure mode for long /goals is the agent solving a different problem than the one you set. Two hours in, Claude is refactoring an unrelated module because some test imported it. Three hours in, the original goal has not moved. Add the paragraph below to EVERY /goal condition you set. It forces a re anchor every 10 turns and stops 90% of drift in testing:
Every 10 turns, restate the original goal in your own words, list what's been
completed, list what's blocking, and confirm you're still solving the original
problem. If you've drifted, stop and ask before continuing.
Why the forced re anchor works: it catches "wait, why am I refactoring the auth module when the goal was to migrate tests" before it eats 5 hours of credits. The cost is tiny (one extra turn every 10) and the value is huge (no hour long dead ends).
5 Ready To Paste Goal Templates
Each template is a complete /goal condition you can adapt by swapping the bracketed values. They cover the 5 use cases that index highest on real autonomous Claude Code work.
Template 1: test suite migration. Use when migrating a folder of tests to a new framework or fixtures pattern. Expected run time: 2 to 6 hours depending on test count.
/goal every test in test/auth uses the new fixtures pattern from
test/auth/fixtures.ts, npm test exits 0, and no test file outside test/auth is
modified. Every 10 turns, restate the original goal, list what's done, list what's
blocking, and confirm you're still on the original problem. Stop after 30 turns.
Template 2: issue backlog drain. Use when you have a labeled backlog of small bugs to close. Expected run time: 4 to 12 hours depending on backlog size.
/goal every open GitHub issue labeled P2-cleanup in this repo has a corresponding PR
with passing CI. Don't modify issues outside that label. Don't change any code
unrelated to the labeled issue. Every 10 turns, restate the original goal and
confirm you're on track. Stop after 50 turns.
Template 3: module split. Use when refactoring an oversized file into focused modules. Expected run time: 1 to 4 hours.
/goal no file in src/ exceeds 400 lines, npm run typecheck exits 0, all existing
tests still pass, and the public API exported from src/index.ts is unchanged. Every
10 turns, restate the goal and confirm. Stop after 25 turns.
Template 4: doc backfill. Use when adding docstrings and type signatures to every public function. Expected run time: 2 to 5 hours.
/goal every exported function in src/ has a JSDoc block with @param and @returns,
npm run typecheck exits 0, and no implementation code is modified (signatures only).
Every 10 turns, restate the goal. Stop after 40 turns.
Template 5: dependency upgrade. Use when bumping the dependency tree to latest minor. Expected run time: 1 to 3 hours.
/goal every dependency in package.json is at the latest minor version per npm
outdated, npm test exits 0, and no major version bumps occur. Every 10 turns,
restate the goal. Stop after 20 turns.
Scoping For 6 To 12 Hour Finishes
Two questions to ask before setting a goal. If you cannot answer both clearly, you are setting up a credit burn with nothing to show.
- Can Claude prove it's done? If the success criterion is "the code is cleaner" or "the UX is better," the evaluator has nothing to read. Rewrite to a verifiable check: tests passing, file count, build exit code, empty queue.
- What would make it run forever? If there is a way for Claude to keep finding new work indefinitely (e.g., "improve all the tests"), bound it. Add a turn cap ("stop after 30 turns"), a time cap ("or stop after 6 hours"), or a count cap ("process at most 20 files").
The 4 Most Common Condition Mistakes
- Vague success: "the code is cleaner." Rewrite to "npm run lint exits 0 and no file exceeds 400 lines"
- Missing constraints: "all tests pass." Add "and no implementation file outside src/auth is modified"
- No turn or time bound: the condition can technically be satisfied forever. Add "or stop after N turns"
- Unverifiable from transcript: "the UX is better." If Claude cannot prove it via its own output, the evaluator cannot fire. Pick something measurable
Real Receipts From The 8 Hour Run
A real /goal run finished a test migration that had been sitting in the backlog. Here is what the artifacts looked like the next morning:
- Run duration: 8 hours 14 minutes
- Commits: 47 (one per migrated test file)
- Tests: all 47 passing on the new framework
- Production code touched: 0 lines (the constraint held)
- Pull request: clean diff, ready to merge
- Cost: roughly $40 in API credits
Time saved vs doing it by hand: 3 to 5 hours of focused engineering work. The /goal handled the mechanical migration. The result was a finished feature and a clean diff to review.
Your First /goal Tonight (30 Minute Plan)
- Update Claude Code to 2.1.139 or later. Run
claude -vto check your version. Earlier versions do not have /goal. - Pick a project with a verifiable end state. Test migration, doc backfill, dependency upgrade, file split. Any template above will work.
- Paste the condition builder prompt. Let Claude write the condition for you using Anthropic's framework.
- Add the drift checkpoint. Append the drift checkpoint paragraph to whatever Claude writes.
- Type /goal followed by the condition. Watch the "/goal active HH:MM:SS" indicator appear in your terminal. Walk away.
- Check back at the indicator clearing. If the goal completes, you will see the auto clear message. If it stalls or drifts, run /goal clear and tighten the condition.
Further Reading
- Anthropic /goal docs: code.claude.com/docs/en/goal
- OpenAI Codex 25 hour run blog: developers.openai.com/blog/run-long-horizon-tasks-with-codex
- Cursor on scaling agents: cursor.com/blog/scaling-agents
- Anthropic long running Claude (scientific computing): anthropic.com/research/long-running-Claude
Go Deeper
Prefer a printable version? Grab the PDF: https://drive.google.com/file/d/1aYEo1C_a87VK0PWK6OR_sYAMy1Tmw7vt/view?usp=drivesdk
Want the whole system installed live, with Cooper on the call? Build Your Own AI, the two week sprint runs the first two weeks of August.
Or get a new working tool every Monday inside The AI Operator community on Whop.
The honest part
The guides are free. The working agents are $97.
Cooper has published 125+ guides like this one, free, no email gate. The step after reading is running the actual systems: five working agents, including the content engine behind his 10M+ views, plus your first month inside The AI Operator community, a new working tool every Monday.
Want it built with you, live? Build Your Own AI · $1,997 · live Aug 3