PromptMake
2026-08-29·15 min read

Loop Engineering Explained: Goals, Verify Criteria & Turn Caps

Loop engineering turns vague agent tasks into bounded Claude Code loops. Learn goals, verify criteria, turn caps, and safe /goal command text.

loop engineeringclaude codeagent loopsverify criteriaturn capsprompt engineering

Generate Claude Code loop commands

Goals, verify criteria, and turn caps — copy-paste text only.

Try Loop Prompt Generator →

Loop engineering is the practice of writing agent tasks so a coding assistant can repeat work until a clear stop condition is met. In Claude Code, that often means a /goal or /loop style command with a goal statement, verify criteria the agent can check, and a turn cap so cost and scope stay bounded. You leave with definitions, a paste-ready command skeleton, mistakes to avoid, and an FAQ. PromptMake at https://promptmake.net/loop-prompt-generator generates loop command text only. It does not run loops, bill tokens, or execute tools on your machine. You copy the output into Claude Code and run it there. This article teaches loop engineering as a design skill separate from Agent Skills and separate from one-shot chat prompts.

What loop engineering is

A loop is not magic autonomy. It is a contract: do this job, check these facts, stop when checks pass or when you hit the turn limit.

Without a contract, agents wander. They refactor unrelated files, re-read the same doc, or declare victory after a partial fix. Loop engineering names the job, names what done looks like, and caps how many attempts count as one session.

Claude Code popularized loop commands for developers who want test-driven or checklist-driven iteration without hand-holding every step. The words you paste matter more than the label on the command.

Loop engineering sits beside Agent Skills. Skills are reusable SKILL.md packages with triggers. Loops are session-scoped task runners with explicit verify steps. Use Skills for standing expertise. Use loops for bounded jobs with a finish line.

Goal: the outcome in plain language

The goal states what must be true when the loop ends. Good goals are observable: all unit tests pass, migration file exists and imports resolve, README section matches template, API returns 200 for fixture X.

Weak goals invite drift: make the code better, improve performance, clean up the module. The agent picks its own definition of better.

Write the goal as one short paragraph a human reviewer could audit without reading chat history.

Verify criteria: how the agent proves progress

Verify criteria are checks the agent runs before it claims success. They bridge goal and evidence: run npm test, grep for TODO in src/, diff against spec section 3, read linter output for zero errors.

Strong verify blocks use commands and file paths. Weak verify blocks use vibes: ensure quality, double-check logic.

Order checks from cheap to expensive. Lint before full integration suite. Read one file before scanning the repo.

Turn caps: bounding cost and scope

A turn cap is the maximum number of agent iterations allowed in one loop. Each turn may read files, edit, run shell commands, and report status.

Without a cap, a stuck agent burns tokens on repeated failures. With a cap, the agent must escalate: summarize blockers, list what passed, ask for human input.

Typical starting caps for small tasks: 5 to 15 turns. Refactors spanning many files may need 20 with narrower per-turn scope. Production teams log cap hits to tune prompts.

How Claude Code loops work in practice

Claude Code accepts loop-style commands in the terminal session. You paste a block that includes the goal, verify steps, and turn limit. The runtime executes tool use across turns until verify passes or the cap triggers.

The exact slash command spelling can vary by Claude Code version. Treat /goal and /loop as patterns: structured brief plus bounded iteration. Read Anthropic release notes when field names shift.

Loops use the same model stack as your Claude Code session. As of mid-2026, Claude Opus 5 and Claude Sonnet 5 are common choices for long coding tasks. Haiku 4.5 suits narrow verify-heavy loops with small edits.

Loops do not replace git discipline. Commit before you loop on risky refactors. Revert paths stay clear when verify never passes.

Example: fix failing tests loop

Goal: make npm test pass for packages/api without changing public API signatures.

Verify: run npm test --workspace packages/api; exit code 0; no new eslint errors in packages/api/src.

Turn cap: 12.

The agent may edit implementation files, adjust fixtures, and re-run tests. It should not rename exported types without explicit permission in the goal.

Example: docs sync loop

Goal: update docs/install.md so every CLI flag in bin/cli.ts appears with one example.

Verify: diff bin/cli.ts flags against docs/install.md headings; missing flags list is empty.

Turn cap: 8.

This loop rewards grep and structured reading over broad rewrites.

Step-by-step: write your first loop command

Start from a task you already did manually twice this month. Manual repeat is the signal a loop might pay off.

Step 1: Write the goal as a falsifiable sentence. If a reviewer cannot say pass or fail, rewrite.

Step 2: List verify checks the agent can run without asking you. Prefer shell commands and file paths over judgment calls.

Step 3: Set a turn cap from task size. Add a note: if cap hit, output blocker summary and stop.

Step 4: Paste into Claude Code. Watch the first two turns. If the agent ignores verify order, tighten wording.

Step 5: Save the winning command in your team doc with project name and date.

PromptMake /loop-prompt-generator scaffolds this structure from a short plain-language brief. Output is text you paste. No execution happens on PromptMake servers.

Drafting the goal field

Include scope fences: which directories, which files are read-only, which behaviors must not change.

Name deliverables: patch, new test file, config key, doc section.

Avoid stacking three unrelated goals in one loop. Split into sequential loops with separate caps.

Drafting verify criteria

One verify line per check. Use imperative verbs: Run, Assert, List, Compare.

When tests are slow, allow a tagged subset in verify with a note to run full suite on human approval.

Include negative checks when regressions are common: do not delete file X, do not change dependency versions.

Setting turn caps responsibly

Multiply expected edits by two and add buffer for read turns. A five-file lint fix might need 10 turns, not 3.

Log cap hits. Frequent hits mean verify is too strict, goal is too vague, or cap is too low.

Never omit a cap because the task feels small. Small tasks are where runaway read loops hide.

Loop engineering vs Agent Skills

Agent Skills package reusable expertise: SKILL.md with description triggers and imperative body. Claude loads them when the task matches.

Loops are one job, one session, one finish line. They do not replace Skills for org-wide conventions.

Use a Skill when many tasks share tools and patterns: release checklist, security review, migration playbook.

Use a loop when today’s ticket has a verify bar: tests green, doc synced, type errors zero.

PromptMake generates Skills config on /skills and loop command text on /loop-prompt-generator. Pick the product that matches reuse horizon.

Common loop engineering mistakes

Mistake 1: Vague goals. The agent optimizes for chat completion, not your definition of done.

Mistake 2: Verify criteria the agent cannot run. asking it to ensure UX feels good has no command.

Mistake 3: No turn cap. Cost spikes and scope creeps on stuck tasks.

Mistake 4: Mega-loops that bundle refactor, tests, docs, and deploy. Split jobs.

Mistake 5: Confusing loop text generation with loop execution. PromptMake outputs copy-paste commands only.

Mistake 6: Skipping git checkpoint before destructive loops.

Mistake 7: Using loops for one-line edits. Human keystrokes are cheaper.

Model and tooling notes for mid-2026

Claude Code sessions commonly run Claude Opus 5 for hard refactors and Claude Sonnet 5 for balanced speed and quality. Haiku 4.5 fits verify-heavy tight loops when edits are small.

OpenAI Codex-class tools and Cursor agents use different loop metaphors. Loop engineering principles transfer: goal, verify, cap. Command syntax does not.

Gemini 3.1 Pro and GPT-5.6 Sol can draft loop command text in chat, but Claude Code execution stays on Anthropic tooling. Use https://promptmake.net/loop-prompt-generator when you want Claude-oriented wording without manual templating.

Guest users on PromptMake get about three generations per day per path. Registered free users get about five. Quotas are separate from /text and /image paths.

When to use PromptMake for loop text

Use the loop generator when you know the task but not the command shape. Paste a plain brief: fix flaky test in user.service.spec.ts, cap 10, verify jest exit 0.

Use it when onboarding juniors. They learn structure from output before they write from scratch.

Use it when verify lists grow long. The tool keeps ordering consistent: goal block, verify list, cap line.

Do not use it expecting autonomous runs. Copy output, open Claude Code, paste, supervise.

Soft next steps

Pick one recurring ticket from your backlog. Write goal, verify, and cap on paper. Open https://promptmake.net/loop-prompt-generator, paste your brief, generate once, edit paths and commands to match your repo, run in Claude Code.

After three real loops, compare cap hit rate and wall time against your manual baseline. Tune verify before you raise caps.

FAQ

What is loop engineering?

Loop engineering is designing agent tasks with a clear goal, verifiable checks, and a turn cap so coding assistants iterate safely until done or until they must escalate. It is a prompt discipline for bounded automation, not unbounded autonomy.

How is loop engineering different from Agent Skills?

Agent Skills are reusable SKILL.md packages loaded when tasks match triggers. Loops are session-scoped commands with explicit verify steps and turn limits. Skills teach standing expertise. Loops finish one ticket with a defined bar.

What are verify criteria in a Claude Code loop?

Verify criteria are commands or checks the agent must pass before claiming success: test exit codes, file diffs, linter output, grep results. They turn vague goals into evidence a human can audit.

Why do turn caps matter?

Turn caps bound token cost and prevent endless retries on impossible tasks. When the cap hits, a well-written loop forces a blocker summary instead of silent burn.

Does PromptMake run loops for me?

No. PromptMake generates loop command text at https://promptmake.net/loop-prompt-generator. You copy the output into Claude Code or another host that executes agent loops. PromptMake has no loop runtime.

What is a good starting turn cap?

For small fixes, start with 8 to 12 turns. For multi-file refactors with tests, 15 to 20 with narrow scope. Log cap hits and adjust. Omitting a cap is not recommended.

Can I use loop engineering with GPT-5.6 Sol or Gemini?

The principles transfer to any agentic coding tool. Claude Code /goal and /loop patterns are Anthropic-specific syntax. PromptMake loop output targets Claude Code wording; adapt verbs if you run another host.

How do I try the loop prompt generator free?

Open https://promptmake.net/loop-prompt-generator. Guests get about three generations per day per path without signup. Registered free accounts get about five per day. Paste your task brief, generate command text, edit repo paths, run locally in Claude Code.

Ready to generate your own prompts?

Free. No sign-up required. Works with all major AI models.

Related articles