You type /goal make my website better and walk away. It either never ends or stops too early. The reason is who decides when it is done.
/goal tells Claude Code to keep working by itself until a job is finished. You describe what finished looks like, and you stop typing "keep going". After each turn, a separate small model checks whether your condition holds. Anthropic's /goal docs say that checker does not run commands or read files. It judges only what Claude has already put in the conversation. It is like a manager who only reads your status updates.
So a good goal has three parts.
01 / 06
The three parts of a good /goal
A finish line it can see. "Make my website better" never ends. "All 10 pages pass the check with zero errors" does. The docs call this one measurable end state: a test result, a build exit code, a file count, an empty queue.
Show the check in the chat after every change. Tell
Claude to print the result, like "7 of 10 pages passing". That is the status update the checker reads. The docs say to write the condition as something Claude's own output can demonstrate.
A time limit. The docs suggest a turn or time clause, such as
or stop after 20 turns. A turn is one round of work. Without a limit, a hard goal can keep running for a long time and use your plan the whole while.
A fourth line is worth adding: what must not change. The docs list constraints such as "no other test file is modified" as part of a condition that holds up. If a test file or checking script is not protected, Claude can edit it to make the check pass.
Put together:
/goal All 10 pages pass the site check with 0 errors. Check: run the site check and print its summary line after every change, like "7 of 10 pages passing". Do not change the check script or any page outside the pages folder. Stop after 20 turns and report what is blocking if not met.The condition can be up to 4,000 characters.
02 / 06
Use the goal-writer skill
The skill below asks the four questions, picks between /goal, /loop and a scheduled task, drafts the line, and lints it. Save it as SKILL.md inside a folder called goal-writer in your skills folder, which is ~/.claude/skills/goal-writer/ on Mac and Linux, or C:\Users\YOU\.claude\skills\goal-writer\ on Windows. Restart Claude Code and type
/goal-writer.
--- name: goal-writer description: Write a good /goal condition or /loop prompt for Claude Code. Interviews the user, picks the right driver (/goal, /loop, or a scheduled routine), drafts a copy-paste line, and checks it against a lint list before handing it over. Use when the user types /goal-writer, or says "make this run overnight", "keep going until it's done", "write me a goal", "write me a loop", "check this every hour". --- # goal-writer: a done-condition Claude can prove ## How /goal works (so you write for the right reader) - After every turn, a small fast model reads the conversation so far and the condition, then says: not yet, met, or impossible. - That model cannot run commands or open files. It can only judge what Claude has already printed in the chat. So a condition is only as good as the evidence Claude shows. - The condition can be up to 4,000 characters. One goal per session. - /goal does not change permissions. In manual permission mode Claude still stops to ask. Tell the user to run goals in auto mode, in a copy or branch of their work. ## Step 1: ask (one numbered list, all four at once) 1. What does "finished" look like, in one sentence? 2. How would you prove it with a command or a number you can see? (Example: "the test command ends with 0 failures", "the folder holds 20 files", "the queue count is 0".) 3. What must NOT change while Claude works? (files, tests, the checking script, anything outside the project) 4. Is it "keep going until done" (goal), "do this every so often" (loop), or "wake me when a long job ends" (scheduled task)? If the user's answer to 1 is vague ("improve", "clean up", "make it better"), do not draft. Ask for a number, a file, a count or a pass/fail result that would show it is done. ## Step 2: pick the driver | They want | Use | Stops when | |---|---|---| | Keep working turn after turn until a result is true | /goal | the condition is met, judged impossible, or they clear it | | Re-run something on a clock (check a deploy, watch a PR) | /loop | they stop it, Claude finishes, or 7 days pass | | Run while the laptop is off or after the session closes | a cloud scheduled task (a desktop scheduled task needs the computer on) | they delete it | Pick one driver per session. A goal and a loop competing for the same job waste tokens. ## Step 3: draft the /goal using this template /goal <one end state>. Check: <command or visible count> shows <exact result>; print that result line in the chat every turn. Do not change <protected things>. Stop after <N> turns or <time> and report what is blocking if not met. ## Step 4: lint the draft. Fix every miss, then show the checklist with ticks. - [ ] One end state, not a list of wishes - [ ] Names a check Claude can run (a command, a count, a file that must exist) - [ ] The check's result is printed in the chat, so the checker can read it - [ ] Names what must not change (tests, the checking script, files outside the project) - [ ] Has a turn or time limit and a "report what is blocking" clause - [ ] Under 4,000 characters (count them and say the number) - [ ] No fuzzy words: better, nicer, cleaner, improved, good, polished - [ ] No outside actions (send, post, pay, delete, publish) unless the condition says "stop and ask me before any of these" - [ ] User was told to use auto mode ## Step 5: if they want a /loop - Fixed interval (/loop 5m ...) when they need a steady check. Every fire costs a full turn, so pick the longest gap that still catches what matters. - No interval (/loop ...) when activity comes in bursts. Claude picks a wait between 1 minute and 1 hour. - Write the job in one sentence with a verb ("Check X; if Y, do Z; if nothing changed, say so in one line"). - Name what the loop may NOT do on its own (push, delete, send, spend). - Warn: a loop lives only while the session is open, and a recurring loop expires after 7 days. Past that, use a scheduled task. - Offer to save the sentence as .claude/loop.md so a bare /loop runs it. ### Loop lint (use this list for a /loop instead of Step 4) - [ ] One job, one sentence with a verb - [ ] Names a check Claude can run, and the result is printed in the chat - [ ] Says what to do when nothing changed ("say so in one line") - [ ] Names what the loop may NOT do (edit, push, delete, send, spend) - [ ] Has a brake: either an end clause ("stop the loop once X is true") or the user knows the 7-day expiry applies - [ ] Reports in the chat only. A phone alert, email or message counts as sending; add it only if the user asks, with "ask me first" - [ ] No fuzzy words; user told to use auto mode Also: if the check is a saved script or test file, add it to the "do not change" list. If the job renames or moves files, add "never overwrite an existing file; if a name is taken, stop and report". If a user's answer to question 2 is vague ("I'll know it when I see it"), treat it like question 1: do not draft, ask again. If you run several checks, list each one with its exact expected result, in the order they run. ## Step 6: hand over Give: (a) the final copy-paste line(s) in a code block, (b) how to stop: /goal clear for a goal; for a loop with no interval, Esc while it waits; for a fixed-interval loop, ask Claude to cancel it, (c) one line on cost: every turn or fire uses plan tokens, so the turn limit is the brake, (d) the lint ticks. ## Failure modes to warn about when relevant 1. Vague end state: the checker never says "met". 2. Result not printed in chat: the checker cannot see it. 3. No limit: it runs and spends until something breaks. 4. Claude edits the tests or the checker to make them pass: that is why step 3 names protected files. 5. Manual permission mode: it stalls on the first prompt. 6. Very large jobs can overflow the context, and the docs say a context overflow that auto-compaction cannot clear ends the goal. Split big jobs into goal-sized chunks. ## Never - Never write a goal that sends, posts, pays or deletes without a human stop inside the condition. - Never promise the checker "runs your tests". It reads the chat.
03 / 06
Five finished examples
Copy one and change the details.
Tests pass.
/goal Every test in the tests/ folder passes. Check: run the test command and paste its final summary line; the summary must show 0 failed. Do not change any file in tests/ or the test config. Stop after 20 turns and report what is blocking if not met.Migration done.
/goal Every file in src/ uses the new date helper and none import the old one. Check: run a search for the old helper name; it must print 0 matches, and print the count each turn. Also run the build and print its exit status; it must be 0. Do not touch files outside src/. Stop after 30 turns.Backlog empty.
/goal The folder inbox/ is empty and every file now sits in a dated subfolder of archive/. Check: list inbox/ and print the count (must be 0) and print the number of files in archive/ (must equal the starting number, which you note in turn 1). Delete nothing. Stop after 15 turns.Watch a pull request (a loop, not a goal).
/loop 10m Check the open pull request. If a check failed, read the log and fix it with the smallest change. If a review comment is new, reply with a draft in the chat and do not post it. If nothing changed, say so in one line. Never push or merge without my OK.Changelog stays current (one run from the terminal).
claude -p "/goal CHANGELOG.md has one line for every pull request merged this week. Check: print the list of merged pull requests and the matching changelog lines side by side; counts must match. Do not edit any other file. Stop after 10 turns."
04 / 06
Run it and stop it
Switch
Claude Code to auto mode. The docs say a goal does not change your permission mode, so in manual mode Claude still asks before tool calls your settings do not already allow.
Work in a copy or a branch of your files.
Paste the line. Setting a goal starts a turn right away.
Type
/goalwith nothing after it to see the condition, turns used and the checker's latest reason.To stop, type
/goal clear. For a self-paced loop, press Esc while it waits. For a fixed-interval loop like/loop 10m, askClaude to cancel it. A recurring loop ends after seven days.
05 / 06
Test it safely
Try a harmless goal first, such as "the folder test-notes/ holds 5 files named note-1.txt to note-5.txt", in a scratch folder.
Watch that
Claude prints the count each turn. If it does not, the checker cannot see it, so add that to the line.
Try a vague goal such as "make this folder nicer". The skill should refuse to draft and ask for something countable.
Where was this tested? The author gave the skill to a Claude subagent on two made-up briefs. It refused to draft the vague one, asked the four questions, and produced a line of about 490 characters with a printed count, protected files and a turn and time limit. It also wrote a loop for the second brief. That run exposed gaps in the loop rules, and the skill text was patched afterwards. The patched text was not run again. Not tested: pasting a generated line into a live session and watching the checker, and the later wording changes to the skill file.
Download the ZIP for the goal-writer skill folder.
Common mistakes
A fuzzy end state. Words like better, nicer or cleaner give the checker nothing to prove.
A check that is never printed. If the result is not in the chat, the checker cannot read it.
No limit. Add a turn or time clause.
Goals that send, post, pay or delete. Add "stop and ask me first" inside the condition.
Running in manual permission mode. It stalls on the first prompt.
Who decides the goal is met?
A small fast model that reads the conversation and your condition after each turn. It does not run commands or open files.
How is a goal different from a loop?
A goal keeps going turn after turn until a condition is true. A loop re-runs a prompt on a timer while the session stays open.
What does a goal cost?
Every turn uses your plan. The docs say the checker's own cost is typically small next to the main turns, so the turn limit in your line is the brake.
Can a goal run when my laptop is closed?
Not in a local session. For that, use a cloud scheduled task.
Finish line
What to do next
Save the skill and type
/goal-writer.Answer the four questions for one small job.
Run the line in a copy of your files, in auto mode.
Back to all the free guides. Two that pair well with this one: run Claude Code overnight safely and stop Claude saying done without proof.
You reached the end of the guide