The /goal Command That Keeps Claude Code Working Without You

Agentic loops in Claude Code let AI work autonomously end-to-end. Here's how the /goal command makes that happen.

The /goal Command That Keeps Claude Code Working Without You

What Changes When an Agent Stops Waiting for You

Most developers using Claude Code have been doing it the same way: assign a task, watch the agent work, answer its questions, verify the output, then repeat. It works, but it keeps you tethered. Every time the agent finishes a chunk, it surfaces back to you for direction, and your attention fractures across however many tasks you’re trying to run in parallel.

The loop approach breaks that pattern. Instead of an agent completing partial work and pausing, it completes work, checks that work itself, fixes what’s broken, and only returns to you when the whole task is done. That shift in mechanics is small on paper. In practice, it changes how many things you can have running at once.

Why the Interruption Problem Is Worse Than It Looks

Picture two agents running simultaneously under the standard method. You spin up Agent A, sketch out the task, and set it going. Then you start doing the same for Agent B. Before you finish briefing Agent B, Agent A is already back - it finished something and wants your sign-off. You break away, address Agent A, send it back to work, and return to Agent B. Then Agent B surfaces. You’re now managing two agents in a constant rotation, each one pulling you away from the other, and neither one actually running without your involvement.

That’s the ceiling: two agents, constant context-switching, and a workday organized around whatever the agents need next rather than what you need to accomplish.

The loop model inverts this. Agent A is given a goal and told not to return until it’s finished. Agent B gets the same. Because neither agent needs your input to move forward - they’re self-verifying and iterating on their own - you can set up Agent C, Agent D, Agent E. The practical limit on parallel work expands considerably. Agents are completing tasks end-to-end while you’re still briefing the next one.

This isn’t theoretical. It’s a direct consequence of removing the verification dependency from you and building it into the agent’s own workflow.

The /goal Command: What It Does and How to Use It

The mechanism for all of this in Claude Code is the /goal command. It works with both Claude Code and Codex, and its syntax is straightforward:

/goal <define your goal here and how to verify it>

What /goal does mechanically is implement a hook. That hook fires every time Claude Code or Codex finishes a step, feeding the goal conditions back into the agent’s decision-making before it surfaces to you. Rather than completing a unit of work and stopping, it completes a unit of work, checks against the goal, and continues if conditions haven’t been met.

The real power is in how you write the goal. A vague goal produces a weak loop. A specific, verification-rich goal produces an agent that can run almost entirely on its own.

What a Production-Grade /goal Prompt Looks Like

Here’s an actual example of the /goal command being used in production:

/goal Implement everything I asked for. Verify it end to end by clicking 
through the browser using the Playwright MCP. It's not acceptable to test 
the application only through integration tests. You need to actually click 
around the app. Continue like this until it works. Fix any issues if you 
encounter them then do an end to end test again. Run Codex exec and run 
the review skill with Codex and make him approve it and iterate until 
Codex has approved it. When Codex has approved it, come to me and tell me 
which servers I can test it on and exactly how to test it.

Several things are happening in that prompt that make it effective. First, it specifies the verification method - Playwright MCP browser clicks, not just integration tests. That distinction matters because integration tests can pass while the actual UI is broken. Requiring browser-level testing closes that gap.

Second, it builds iteration directly into the goal. “Fix any issues if you encounter them then do an end to end test again” means the agent isn’t done when it finds a problem - it’s done when it finds no problems after fixing what it found. The loop runs until a clean pass.

Third, it chains another agent into the review process. The instruction to run Codex and get its approval before surfacing to the human means two layers of automated review happen before any human time is spent. The agent only comes back with a passing grade already in hand.

Fourth, the handoff is specific. “Tell me which servers I can test it on and exactly how to test it” means the agent returns with actionable information, not just a vague “I think it’s done.”

Building Your Own Loop: The Conditions That Matter

The difference between a loop that saves you time and one that runs in circles usually comes down to how precisely you define the exit condition.

An exit condition like “finish the feature” is too loose. The agent has no clear test to run against it. An exit condition like “the login flow completes without error when tested via Playwright MCP from the homepage through to the authenticated dashboard” gives the agent something it can actually verify, fail, fix, and re-verify.

A few things worth specifying when writing a /goal prompt: what tool or method should be used to verify (Playwright, unit tests, lint checks, a second agent’s review), what counts as a failure and requires iteration, what format the final report back to you should take, and whether any external approval - like a Codex review pass - is required before the agent surfaces.

The Playwright MCP inclusion in the example above is worth noting separately. Integration tests run code against code. Browser-based testing via Playwright runs the actual application the way a user would, which catches a meaningfully different class of bugs. Requiring Playwright verification rather than accepting integration tests alone raises the bar for what “done” means.

What This Changes About How You Work

Running agents in loops doesn’t just speed things up - it changes the structure of what you’re doing moment to moment.

Without loops, your job is reactive. You respond to what agents surface. With loops, your job is compositional. You define goals with enough specificity that agents can verify their own work, then you stack tasks, knowing each one will run without your supervision until it’s actually finished.

The practical implication: the /goal command in Claude Code is less a feature and more a forcing function for writing better task definitions. Vague instructions produce interrupted agents. Specific, verification-laden goals produce agents that come back with work that’s already been tested, reviewed, and confirmed by a second automated pass.

Starting point for anyone new to this: try a single agent with a tightly scoped /goal, include a Playwright verification requirement, and require the agent to iterate until the test passes before reporting back. The prompt in the example above requires Codex approval before handoff - that’s two automated review layers for the cost of one well-written goal.