Stop Prompting Agents: Design Loops That Orchestrate AI Coding Agents

Move from manual prompting to designing loop systems that orchestrate AI coding agents. Explore patterns, CLI tools, and a 5-minute quickstart.

Why Loop Engineering Matters

Peter Steinberger captured the shift perfectly: "You shouldn't be prompting coding agents anymore. You should be designing loops that prompt your agents." Boris Cherny, Head of Claude Code at Anthropic, echoes this: "I don't prompt Claude anymore. I have loops running that prompt Claude and figuring out what to do. My job is to write loops."

The leverage point has moved from crafting individual prompts to designing the control systems that orchestrate agents over time. This is the core idea behind loop engineering — a practical methodology for building automated, agent-driven workflows.

What Is Loop Engineering?

Loop engineering replaces you as the person who manually prompts an agent. Instead, you design a system — a loop — that does it for you. This system schedules tasks, manages state, executes in isolated environments, and gates risky actions behind human approval.

The reference repository, cobusgreyling/loop-engineering, provides practical patterns, CLI tools, and starters for implementing this approach with AI coding agents like Grok, Claude Code, Codex, Cursor, and OpenClaw.

The Five Building Blocks + Memory

Every loop is composed of five primitives plus a memory/state layer:

Primitive Job in the Loop
Automations / Scheduling Discovery + triage on a cadence
Worktrees Safe parallel execution
Skills Persistent project knowledge
Plugins & Connectors Reach into your real tools (MCP)
Sub-agents Maker / checker split
+ Memory / State Durable spine outside any conversation

These primitives form the anatomy of a loop:

flowchart LR
A[Schedule / Automation] --> B[Triage Skill]
B --> C[Read + Write STATE / Memory]
C --> D[Isolated Worktree]
D --> E[Implementer Sub-agent]
E --> F[Verifier Sub-agent<br/>tests + gates]
F --> G[MCP / Git / Tickets]
G --> H{Human Gate?}
H -->|safe / allowlisted| I[Commit / PR / Action]
H -->|risky / ambiguous| J[Escalate to human<br/>with full context]
I --> A
J --> A

Production Patterns

The repository includes seven production-ready loop patterns, each with a defined cadence, starter template, and estimated token cost:

Pattern Cadence Token Cost
Daily Triage 1d–2h Low
PR Babysitter 5–15m High
CI Sweeper 5–15m Very high
Dependency Sweeper 6h–1d Medium
Changelog Drafter 1d or tag Low
Post-Merge Cleanup 1d–6h Low
Issue Triage 2h–1d Low

Not sure which to pick? Use the interactive pattern picker or consult patterns/registry.yaml.

CLI Tools: Get Started in 5 Minutes

The repository ships with several npm-published CLI tools:

  • loop-init: Scaffold starters + budget/run-log + constraints
  • loop-audit: Loop Readiness Score CLI (v1.5 + constraints scoring)
  • loop-cost: Token spend estimator
  • loop-sync: Drift detection between STATE.md and LOOP.md
  • loop-context: Stateful memory manager + circuit breaker for long runs
  • loop-mcp-server: MCP runtime lookup for patterns, skills, state

Quickstart

# 1. Scaffold + get your Loop Ready score (printed automatically)
npx @cobusgreyling/loop-init . --pattern daily-triage --tool grok

# 2. Estimate token spend for your cadence
npx @cobusgreyling/loop-cost --pattern daily-triage --level L1

# 3. Re-audit after improvements
npx @cobusgreyling/loop-audit . --suggest

# Optional: paste Loop Ready badge into your README
npx @cobusgreyling/loop-audit . --badge

# 4. See scores climb: empty → L1 → L2
bash scripts/before-after-demo.sh

# 5. Start report-only (Grok example)
/loop 1d Run loop-triage. Update STATE.md. No auto-fix in week one.

All CLIs publish to npm from tagged releases — no clone required.

Operating & Safety

Loop engineering amplifies judgment — both good and bad. Key caveats:

  • Token costs can explode with sub-agents and long-running loops.
  • Verification is still on you. Unattended loops make unattended mistakes.
  • Comprehension debt grows faster unless you read what the loop ships.
  • Two people can run the same loop and get opposite results. The loop doesn't know. You do.

As Addy Osmani puts it: "Build the loop. But build it like someone who intends to stay the engineer, not just the person who presses go."

The repository includes detailed documentation on failure modes, anti-patterns, multi-loop coordination, and safety (denylist, auto-merge, MCP scopes).

Contributing

The project welcomes contributions, especially failure stories and production patterns. See CONTRIBUTING.md for the contribution ladder and good first issue backlog.

Conclusion

Loop engineering is a paradigm shift for developers working with AI coding agents. Instead of manually prompting, you design systems that orchestrate agents over time — with scheduling, state management, safety gates, and cost awareness. The tools and patterns in this repository give you a practical starting point for implementing this approach today.

Source

cobusgreyling/loop-engineering: Practical patterns, starters & CLI tools for loop engineering with AI coding agents. Design systems that prompt and orchestrate agents (inspired by Addy Osmani and Boris Cherny). Includes loop-audit, loop-init, loop-cost.