Course/Automation for Power Users

9 min · +160 XP

Let Claude work toward a goal

/goal, /loop and scheduled tasks, with a check Claude can prove and a budget you set.

By the end of this lesson

You will be able to set a goal Claude can verify, run it unattended within a budget, and choose between /goal, /loop and scheduled tasks.

Usually Claude finishes a turn and waits for your next message. With /goal you give it a finish line: after every turn, a separate small model checks whether the condition holds, and if not, Claude starts another turn. This repeats until the condition is met or the goal stops.

Set a goal
/goal all tests in test/auth pass and the lint step is clean

Setting a goal starts work at once. While it is active, ◎ /goal active shows how long it has run. /goal alone shows the condition, the turns, the token spend and the evaluator's latest reason; /goal clear removes it.

A condition Claude can prove

The evaluator does not run commands or read files. It judges only what Claude has shown in the conversation, so the condition must be something Claude's own output can demonstrate, such as a test run or an exit code.

A good condition has

  1. 1One measurable end state: tests pass, the build exits 0, a file count, an empty queue.
  2. 2A stated check: "npm test exits 0", "git status is clean".
  3. 3Constraints: "no test file is deleted or skipped", "nothing in payments/ changes".
  4. 4A limit: "or stop after 20 turns". Claude reports progress against it each turn. The whole condition can be up to 4,000 characters.
Weak and strong
you ▸ /goal make the app better (nothing to check: the evaluator cannot tell when this is done)
you ▸ /goal npm run build exits 0 and npm test exits 0, no test file is deleted or skipped, or stop after 15 turns
💬 Let Claude draft the condition

“Help me write a /goal condition for this task: make the build and all tests pass after the dependency update. The condition must be provable from command output in the conversation, forbid deleting or skipping tests, and stop after 15 turns. Show it to me and do not start it.”

Read the draft, adjust it and paste it after /goal yourself; setting a goal starts the work at once.

Unattended means auto mode

A goal does not change the permission mode. In Manual mode Claude still stops before each command that is not allowed in advance, so the goal waits for you. To let goal turns run without you, start the goal in auto mode, where a classifier reviews each action and blocks risky ones.

Run a goal from a script
claude -p "/goal CHANGELOG.md has an entry for every PR merged this week" \
  --permission-mode auto --max-budget-usd 5 \
  --output-format stream-json --verbose

The loop runs to completion in one call. With the default text output nothing appears until the end, so stream-json shows progress. --max-budget-usd stops the run at an estimated spend; Ctrl+C stops it at once.

Repeating and scheduled work

Three related tools

  1. 1/loop 5m check whether the deploy finished: repeats a prompt on an interval while the session stays open. Without an interval, Claude picks the delay itself. Recurring tasks expire after 7 days.
  2. 2Desktop scheduled tasks: run on your computer on a schedule, with access to local files. The computer must be on.
  3. 3Cloud scheduled tasks, formerly routines: a saved prompt with repositories and connectors that runs on Anthropic's cloud on a schedule, an API call or a GitHub event. Create them at claude.ai/code/routines or with /schedule, on Pro, Max, Team and Enterprise. They start in auto mode and work on a fresh clone, not on your local files.

Risks

What can go wrong

  1. 1A vague condition: Claude may work on the wrong thing for many turns, or the evaluator may accept a result you would not.
  2. 2Spend: every turn uses your plan or API budget. Put a turn limit in the condition, watch /usage, and use --max-budget-usd in scripts.
  3. 3A check that can be satisfied the wrong way: "tests pass" is also true after tests are deleted or skipped. Forbid that in the condition and read the diff afterwards.
  4. 4Actions under your name: a cloud scheduled task commits and posts through your GitHub and connector accounts. Give it only the repositories and connectors it needs.
  5. 5Auto mode reduces questions but does not guarantee safety. Commit before you start, and run long goals on a branch or in a worktree.
✦Going further

/goal is a session-scoped prompt-based Stop hook; a Stop hook in settings gives the same per-turn check across sessions and can run a script for a deterministic test. If Claude answers the evaluator for several turns without using tools, the loop stops and hands control back with the goal still set. Running subagents or background commands defer evaluation, with check-ins after 30 minutes (CLAUDE_CODE_GOAL_CHECKIN_MINUTES). Auth failures, an exhausted credit balance, a context overflow compaction cannot clear, or an unavailable model clear the goal; rate and usage limits pause it. A resumed session restores an active goal with fresh counters.

Quick check

Which condition gives /goal something it can actually check?

Quick check

You set a goal in Manual mode and go to lunch. What will you most likely find?

Facts checked against the official Claude Code docs October 24, 2026 · source

EAEvgenii Arsentev

Author

Evgenii Arsentev

PhD · Chief Executive Officer, digital health