Claude Code /goal Command: Run It Autonomously for Hours
How to use the /goal command in Claude Code. Set one measurable finish line and a small fast model checks after every turn whether it's met, so Claude keeps working on its own until it's done.
This is one of the most slept-on commands in Claude Code. Instead of prompting through every single step, you type /goal and give it one clear finish line. Claude takes an action, then a separate small fast model checks whether your goal is actually met. If it isn't, Claude keeps going on its own. You set the target once and stop babysitting it prompt by prompt.
How /goal works
- It's a session Stop hook. After each turn, your condition plus the work so far is sent to a small fast model (Haiku by default).
- That model returns yes or no with a short reason. A no feeds the reason back as guidance and Claude keeps working. A yes clears the goal.
- The evaluator can run real commands like npm test or tsc, so it checks facts, not vibes.
Step 1: Set a measurable goal
Run /goal followed by the finish line you want. Setting it starts a turn straight away, no separate prompt needed.
/goal all tests pass and the build is cleanStep 2: Make the condition provable
Vague goals drift. A good condition has one measurable end state and a stated check. For example:
- "npm test exits 0 and tsc --noEmit reports no errors."
- "git status is clean and the app builds."
- Add a constraint that must not change, like "don't modify any other test file."
Step 3: Let it run, then clear
- Claude works turn after turn, fixing issues on its own until the check passes.
- When it's done, the goal clears automatically.
- To stop early, run /goal clear.
What you end up with
Give it something measurable rather than vague, and it'll run for hours. The command is built for long autonomous tasks: set the target, walk away, and come back to finished work instead of a prompt waiting on you.
New guides land in your inbox first
One short email a week with the tools and prompts worth your time. Free, and you can leave any time.