What is a Loop?

A loop is a runnable agentic harness—a reusable pattern that powers AI coding agents like Claude Code, Cursor, Codex, and the Anthropic Agent SDK. It's the engine that drives autonomous coding workflows.

At its core, a loop implements a plan → act → observe → repeat cycle. The agent evaluates the current state, plans its next move, executes code or commands, observes the results, and loops until the goal is reached.

In 2026 this shift got a name, loop engineering, and went viral on X.

"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."

Boris Cherny, Head of Claude Code at Anthropic

"Here's your monthly reminder that you shouldn't be prompting coding agents anymore. You should be designing loops that prompt your agents."

Peter Steinberger, creator of OpenClaw

How Loops Work

1. Plan

The agent reads your request and breaks it into actionable steps, thinking through dependencies and edge cases.

2. Act

The agent executes code, runs tests, makes API calls, or performs other actions within your environment.

3. Observe

The agent captures output, errors, test results, and feedback to understand what happened and why.

4. Repeat

Based on observations, the agent adjusts its strategy and loops until the task succeeds or a stopping condition is met.

Types of Loops

Harness

A complete, standalone framework that wraps an AI agent. Examples: a CLI harness, a web service wrapper, or a deployment template. ~30 to several hundred lines.

Plugin

A focused loop that runs inside an agent tool or within an existing platform (Claude Code, VS Code, terminal). Examples: the TDD loop (red-green-refactor cycle), a debug loop, or a code-review loop.

Config

A configuration or prompt template that describes a specific loop pattern. Useful for documenting best practices, prompts, or decision trees without implementation.

Why Loops Matter

Loops turn AI agents into reliable tools for coding and automation. A well-designed loop ensures the agent doesn't get stuck, recovers from errors gracefully, and delivers consistent results.

By sharing loops, developers can:

  • Reuse proven patterns instead of reinventing the wheel
  • Teach agents better habits through structured workflows
  • Build faster by standing on others' work
  • Compose complex tasks from simpler, proven loops

Loop Engineering Glossary

agent loop
A runnable pattern that plans, acts, observes the result, and repeats until a goal is met. The unit this directory catalogs — also called an AI loop or agentic loop.
loop engineering
Designing the system that prompts your agent instead of prompting it yourself. The term took off in 2026 via Addy Osmani and Peter Steinberger.
context rot
Quality decay as an agent's context window fills with stale history. Ralph-style loops avoid it by starting every iteration with fresh context.
backpressure
Anything that slows or stops a loop when quality drops: failing tests, lint gates, verification subagents, or a human reviewing the diff.
completion promise
A token the agent must output (like DONE) to prove the goal is met. The loop exits only when the promise appears — otherwise it keeps iterating.
stop hook
A Claude Code hook that intercepts session exit and re-feeds the prompt. The mechanism behind the official Ralph Loop plugin.
harness
A standalone framework that wraps an agent and runs the loop from the outside — a bash script, a CLI, or a fleet of Docker sandboxes.
plugin
A loop that runs inside an agent tool like Claude Code, installed with /plugin or a skills manager rather than cloned and run.
config
A prompt template or playbook that documents a loop pattern without shipping code. You adapt it to your own agent.
AGENTS.md
A memory file coding agents read automatically. Good loops append learnings to it each iteration, so future runs inherit conventions and gotchas.

Get Started

Browse the directory to discover loops created by the community. Each loop includes documentation, code examples, and links to its source.

Have a loop to share? Submit it to the directory and help other developers build better agents.