Claude Code /goal vs /loop: when to use which
/goal is an inner loop that runs one task until a condition is met. /loop is an outer loop that runs a prompt on a schedule. Combine them to build loop engineering in Claude Code.
The main idea
Some people hear /loop and think that is all of loop engineering. Others see /goal and ask if it is already a loop. It is. /goal is a different kind of loop than /loop.
/loop runs a command, a prompt, or a slash command on a schedule, such as every 5 minutes, every hour, or every week. It works like a cron job. /goal takes a prompt with a condition, for example implement all tasks in tasks.md, or write unit tests for each file and keep going until code coverage is 90%. Claude keeps working until the condition is met, even if something goes wrong along the way. I call /goal the inner loop because it runs until done or blocked.
In the video I combine them. The outer loop runs every 1 minute and calls /goal to complete all tasks in tasks.md. When I add a new task, the next loop run picks it up and the inner loop does the work. You can add verifiers so the loops do the right things instead of only burning tokens.
Key points
- /loop is the outer loop. It runs a prompt on a schedule, like a cron job.
- /goal is the inner loop. It runs until the condition is met or the work is blocked.
- A goal can be a condition such as fix the failing test, or write unit tests until code coverage is 90%.
- To combine them, use /loop to run /goal on a schedule, for example every 1 minute with the prompt to complete all tasks in tasks.md.
- A goal can run for a long time. I had one running for 8 hours.
- Add verifiers to the system so the loops do the right work instead of burning tokens.
Chapters
Free live lesson · Nov 24Stop Measuring AI by Tokens. Measure What It EarnsOne hour, live, with Saurav. Bring your own bill. Free.Save my free seat →