Skip to the article

I'm Fernando,
a full-stack developer!

When Claude Code’s /goal command is useful

I was unable to find good examples of Claude Code’s /goal command, only the reference documentation. Then I had a task where it worked great, so this is a short field report of what that use case looks like.

I had a usability test: a cheap model (Claude Haiku 5.5 on low effort) plays a non-technical employee of a government office, and works through 15 scenarios in a browser. After every scenario it writes a log block into a markdown file.

With a normal prompt, I noticed the agent tries to do everything in order, with no back tracking to earlier tasks. The way the goal command works changes this. It tells the agent to pickup any task and then do it, rather than the agent doing everything in a strict order. When you have a lot of tasks that you need to do, this is a benefit as theagent picks up the easiest task, then uses the knowledge when learned for the next task.

/goal You are the test participant described in run.md in your current directory. Read run.md completely and follow it exactly: you play a non-technical employee of a regional government office, you work only in the browser at http://localhost:5174, you do not look for source code, documentation or the API, and the only file you change yourself is run.md (files that the browser tool writes on its own do not count). Work through the 15 scenarios one iteration at a time, easiest first, and write each iteration into run.md (log block and scoreboard row) before you start the next one. Use your iterations for more than a first pass: go back to scenarios you doubt, or that you now know a better way to do, as run.md describes. You are finished only when your final message contains the scoreboard table, copied from a fresh Read of run.md, in which every scenario is Done, or is Partial / Gave up with "Iterations used" of at least 2, and the Final report section of run.md is filled in. Do not stop before that; if it is not reached, stop only after 120 goal checks (the number of times your turn ended and you were sent back to work; your own actions and tool calls are not turns) and say where you stopped.

Setting the goal in a claude code sessionThe goal set in a Claude Code session, with the acknowledgement and the /goal active indicator

This is the part I would have liked to know in advance. The judge only sees the conversation, and it reads the words you wrote, not what you meant.

  • It can pass too easily. In one of my example runs the condition said every scenario had two iterations, “or all 20 iteration blocks are filled in”. Three scenarios broke my rule, and the judge noticed, and still passed it because the last clause was true. Every or is an escape hatch.
  • It can refuse too long. In one of my example runs 14 of 15 scenarios, and the judge still said no, because my condition says the only file the agent may change is run.md, and the screenshot tool had written a PNG into the folder. The agent could not delete it, and told me so again and again.
  • A cap is not an exit. The agent believed it hit “120 turns” after about 10 turns, stopped, and the judge refused that too: the cap only allows stopping with a report, it does not make the condition true.

The agent asks for the stray file to be deleted, the judge keeps saying not met, and Claude Code stops blocking

Note that it does not loop forever either. After reaching the limit set by CLAUDE_CODE_STOP_HOOK_BLOCK_CAP blocked stops in a row Claude Code printed “Goal paused” and waited for a message. This limit is by default set to 8, so it stops on the 9th turn. Note that this stop condition doesn’t clear the goal, it will continue wif you did not ran /goal clear on the next message!

  • Put the whole task in the goal, it is the first prompt anyway.
  • Make the finish line visible in the conversation. Ask for evidence in the final message (“paste the table from a fresh Read”) instead of pointing at the state of a file.
  • Avoid or between acceptance clauses.
  • Keep rules the agent cannot control out of the condition, they will be checked too.
  • Keep behaviour rules (try harder, no giving up too early) in the task file. The goal decides when it may stop, not how hard it tries.

Comments