PTENES
TRACK 1

🧩 Fundamentals of Loop Engineering

What Loop Engineering is, where it came from, its fundamental building blocks, and how the orchestrator-workers architecture behind it all works.

3
Modules
18
Topics
~1h30
Duration
Basic
Level
Human defines the spec + loop Orchestrator /loop + /goal /routines state store iterates Worker 1 Worker 2 Worker N Result code / PR / fix

Learning path map

Detailed content

1.1 ~30 min

πŸ’‘ What Is Loop Engineering

Definition, origin of the concept, difference between manual prompting and loop-driven workflows, and the voices behind the movement.

What is:

Loop Engineering is the approach where automated systems (loops) trigger, monitor, and iterate over AI agents in a continuous cycle, replacing manual human prompting.

Why learn:

Understanding the precise definition avoids confusion with generic automation. The term has a specific meaning in the context of coding agents.

Key Concepts:

Loop-driven vs. prompt-driven. You define the system, not each prompt. Analogy with cron jobs + AI agents.

What is:

Boris Cherny, Head of Claude Code, manages tens of thousands of agents per day using loops. He doesn’t type prompts: he builds systems that do it for him.

Why learn:

The source’s credibility matters. Boris is at the center of Claude Code development and practices loop engineering at an industrial scale.

Key Concepts:

Scaling to thousands of agents per day. Prompting as a system, not an interaction. Anthropic as a practical reference.

What is:

Peter Steinberger created OpenClaw and runs loops that automatically prompt Claude, with an orchestrator, workers, and external state management.

Why learn:

It's a real implementation case outside Anthropic. It shows that the approach works for independent developers, not just the people who build the tool.

Key Concepts:

OpenClaw as harness. Orchestrator/worker separation. External state (Postgres). Agent autonomy.

What is:

With manual prompting, the human interacts directly with the agent at every step. With loop-driven work, the human defines the system once, and the loop automatically runs N iterations.

Why learn:

The distinction is essential for knowing when each approach makes sense. Loop-driven development doesn’t replace manual prompting in every case.

Key Concepts:

Synchronous vs. asynchronous interaction. Cost of human attention. Scale vs. precision. Control trade-off.

What is:

Loop Engineering combines the concept of scheduled tasks (like cron jobs on Linux) with the reasoning capabilities of LLMs. The loop triggers, and the agent decides what to do.

Why learn:

The analogy helps demystify it: it's not magic; it's automation with an intelligent layer. If you understand cron jobs, you're already halfway there.

Key Concepts:

Time-based vs. conditional trigger. Job = agent session. Exit condition = stopping criterion. Idempotency.

What is:

The term Loop Engineering gained traction after Boris Cherny publicly described how Anthropic uses loops internally. Cole Medin asks: "does it deserve its own buzzword?"

Why learn:

Separate signal from noise. Not everything with a proper name is revolutionary. Understanding the context helps you avoid adopting things blindly.

Key Concepts:

Hype cycle. Naming as marketing. Substance vs. branding. Honest critique of Cole Medin.

View Full
1.2 ~30 min

🧱 The Fundamental Building Blocks

/loop, /goal, and /routines: the three primitives that form the loop system in Claude Code.

What is:

The /loop command sets execution intervals for the agent, such as β€œevery 5 minutes.” It is the recurring mechanism that keeps the agent active.

Why learn:

Without a loop, the agent stops when it finishes a task. With a loop, it wakes up periodically to check whether there's new work.

Key Concepts:

Polling interval. Automatic wake-up. Difference between a loop and a single-shot run. Token cost per idle cycle.

What is:

/goal defines an objective completion criterion. The agent keeps iterating until it reaches the goal or runs out of attempts. It's the loop's exit condition.

Why learn:

Without a clear goal, the loop runs indefinitely, spending tokens without producing results. The goal is what makes a loop useful.

Key Concepts:

Explicit exit condition. Automatic completion check. Fallback and retry limits. Goal vs. deadline.

What is:

/routines are scheduled tasks with a defined schedule (e.g., "every hour, review the spec"). Unlike the generic /loop, routines have a specific, recurring purpose.

Why learn:

Routines are the most practical mechanism for maintenance tasks: periodic code review, docs sync, health checks.

Key Concepts:

Cron-style schedule. Routine vs. ad hoc loop. Combining multiple routines. Priority among conflicting routines.

What is:

The three primitives don't operate in isolation. A typical system combines /loop as a heartbeat, /goal as an exit criterion, and /routines as parallel maintenance tasks.

Why learn:

Understanding the composition is the step from "I know what each piece does" to "I can build a functional system."

Key Concepts:

Pipeline as a graph. Dependencies between blocks. Execution priority. Diagnostics when a block fails.

What is:

The plan.md is the Markdown document that defines the tasks for the loop to process. It works as a contract: the orchestrator reads it, executes each item one by one, and marks it as complete.

Why learn:

A poorly written plan.md leads to inefficient loops. Input quality determines output quality, even in automated systems.

Key Concepts:

Task list structure. Ideal task granularity. Acceptance criteria for each item. Plan versioning.

What is:

Loop with no exit condition (runs forever), vague goal ("do something good"), routine that conflicts with the main loop. These are traps that burn tokens without results.

Why learn:

Avoiding these errors from the start saves money and frustration. Most beginners fall into the same traps.

Key Concepts:

Infinite loop. Ambiguous goal. Conflicting routines. Max iterations as a safety net. Budget limits.

View Full
1.3 ~30 min

πŸ— Orchestrator-Workers Architecture

The design pattern behind scalable loops: an orchestrator decides, workers execute, and the state store persists.

What is:

The orchestrator is the agent session that reads the spec, decides which tasks to run, launches workers, and validates results. It doesn't execute code directly.

Why learn:

The orchestrator is the most critical point of failure. If it makes poor decisions, all the workers produce junk. Understanding its role is essential.

Key Concepts:

Separation of concerns. Decision vs. execution. The orchestrator model (which can be cheaper). Retry logic in the orchestrator.

What is:

Workers are agent sessions that receive a specific task from the orchestrator and execute it. They can run in parallel using worktrees for isolation.

Why learn:

Workers are where the real work happens. Understanding how to isolate them, monitor them, and collect their results is the practical side of loop engineering.

Key Concepts:

Worktrees as a sandbox. Real parallelism. Collecting results. Worker timeout. State isolation.

What is:

Instead of relying on the LLM's context window to maintain state, the loop saves state in an external database (Postgres, Neon). This prevents context bloat and lets you summarize sessions.

Why learn:

Context bloat is the #1 cause of degradation in long loops. External state is the architectural solution that makes loops viable at scale.

Key Concepts:

Database as the source of truth. Context window as cache, not storage. Neon branching for workers. State store schema.

What is:

Flow: spec comes in -> orchestrator plans -> spin up workers -> workers execute -> results return to state -> orchestrator validates -> next wave or completion.

Why learn:

Viewing the complete workflow helps you debug when something goes wrong. Each step is a potential failure point that needs to be handled.

Key Concepts:

Round as a unit of work. Fan-out (orchestrator -> workers). Fan-in (workers -> orchestrator). Validation between rounds.

What is:

With external state, if the agent crashes in the middle of a round, the orchestrator can resume where it left off. The state in the database survives crashes, timeouts, and disconnections.

Why learn:

Long loops inevitably fail at some point. Durability is what separates a toy from a production system.

Key Concepts:

Checkpoint in the state store. Resume from last good state. Worker idempotency. Cleanup of orphaned workers.

What is:

Observability is the ability to see what the loop is doing in real time: orchestrator decisions, worker progress, accumulated cost, errors.

Why learn:

Without observability, you're running a blind loop. "Run for a day, come back to crap" is a symptom of inadequate monitoring.

Key Concepts:

Agent Control Plane. Cost tracking per round. Orchestrator decision log. Human-in-the-loop checkpoints.

View Full