Claude Code now ships three loop-engineering commands—/loop, /goal and /schedule—that let a coding agent drive its own prompt cycle without a human typing each step. The feature promises developers a way to automate repetitive coding work, keep token spend in check and avoid the “type-prompt-wait-type-prompt” rhythm that has defined AI-assisted development so far.

Why the new commands matter

Most AI-coding workflows still rely on a manual back-and-forth: a developer writes a request, the model returns code, the developer reads it, decides what to ask next, and repeats. That pattern is slow, costly and error-prone when the same small task—running a build, fixing a lint warning, iterating on a test failure—needs dozens of turns.

The three loop modes

  • /loop – A lightweight, self-paced cycle. The same Claude instance runs each turn and checks a simple condition, such as “is the build green?” It works best when the verification step is trivial and the risk of a false “done” signal is low.
  • /goal – A high-precision cycle. Each turn a secondary model evaluates the completion condition, adding an extra layer of scrutiny. Use it when a premature finish would be expensive—e.g., deploying a security-critical service.
  • /schedule – A cloud-hosted routine that lives on Anthropic’s infrastructure. The loop continues even if the developer’s laptop is shut down.

All three share a common architecture: a skill (the instructions that tell the agent what to do), a verifier (the check that proves the work is truly finished), guardrails (limits on which tools the agent may invoke) and state (a lightweight memory of prior actions). Skip any of these pieces and the loop becomes an endless self-agreement that just racks up token usage.

Building a safe, cost-controlled loop

  1. Define the skill – Write a clear, deterministic prompt that tells the agent the exact operation (e.g., “run npm test and capture the output”).
  2. Add a verifier – Couple the skill with a concrete test the agent cannot fake, such as parsing the actual test runner’s exit code or checking a generated artifact’s checksum.
  3. Set guardrails – Restrict the agent to a whitelist of commands or APIs. This stops it from opening a network socket when the task only needs file I/O.
  4. Persist state – Store a small JSON blob or database entry that records what the agent has already done. The next turn reads that state and avoids repeating work.

Three safety caps every loop needs

  • Hard stop – Impose a maximum number of turns or a hard token budget. If the loop hits the limit, it aborts and reports “max turns reached”.
  • Real stop condition – Use a verification metric the model cannot fabricate, such as a passing test suite, a non-empty build artifact, or a checksum that matches a known good value.
  • Spend cap – Hook the loop into a monitoring layer that watches token consumption in real time and halts execution once a predefined spend ceiling is breached.

Takeaway

Claude Code’s /loop, /goal and /schedule commands give developers a practical way to automate repetitive coding cycles while keeping token spend transparent. The key to a trustworthy loop is a solid verifier, strict guardrails and hard limits on runtime and cost. Build those safeguards first, then let the agent run the mundane work—so you can spend your time on the problems that still need a human mind.