Skip to content

Chapter 26 · Loop Engineering: From Prompts to Loops ​

Chapter goals: Understand the core philosophy of "stop prompting, design loops," master the five-building-blocks + Memory architecture, and评估 your own loops for production-readiness using Loop Ready Score.

26.1 Core Philosophy: From Prompts to Loops ​

Peter Steinberger once said a widelyquoted line:

"You shouldn't be prompting coding agents anymore. You should be designing loops that prompt your agents."

Boris Cherny (head of Claude Code) expressed a similar view:

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

This points to the shift in leverage point: from "crafting a single prompt" to "designing the control loop."

Single Prompt vs. Loop ​

DimensionSingle PromptLoop
What you提供"What to do next""What the final state should look like"
What the agent doesExecute onceLoop until the goal is达成
Whojudges completionYouVerifiable stop条件
Can you walk away?NoYes — input /goal and leave

26.2 Five Building Blocks + Memory ​

Loop Engineering拆解 all loops into five basic blocks, plus a Memory layer贯穿始终:

BlockResponsibilityTypical Implementation
Automations / Scheduling定时 discovery + triagecron, GitHub Actions, /loop command
WorktreesSafe parallel executiongit worktree add, loop-worktree tool
SkillsPersistent project knowledgeSKILL.md, skills directory
Plugins & ConnectorsConnect to real toolsMCP server, GitHub API, Slack bot
Sub-agentsmaker/checker separationIndependent sub-agent execution + verification
+ Memory / StateCross-session persistenceSTATE.md, PROGRESS.md, git commits

Loop Anatomy Diagram ​

mermaid
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

26.3 Four Loop Types ​

TypeTriggerStop ConditionTypical Scenario
Turn-basedManually input each promptAgent认为完成 or you打断Small tasks, exploratory work
Goal-basedGiven a goalIndependent evaluator confirms完成 or reaches上限/goal complex tasks
Time-basedScheduled timingManually stop or the task自然 exits/loop monitoring, periodic checks
Event-drivenExternal events (PR opened, CI failed)Exit after处理 or reach retry上限CI/CD integration, responsive workflows

Distinguish /goal vs. /loop

Both带 "loop" but solve不同 problems:

  • /goal: one大 task; loops until完成 (a marathon)
  • /loop: one小动作;周期 repeated execution (an alarm clock)

26.4 Loop Ready Score ​

The official CLI provides a loop audit command that scans the repo and gives a 0–100 Loop Ready Score, measuring whether the loop具备 production-readiness. Audit dimensions include:

DimensionCheck Content
SkillsWhether a compact-format triage skill exists; whether the skill description is "boring but specific"
StateWhether the state file schema is明确; whether each round读旧写新
Maker/Checker SeparationWhether the implementer and verifier are独立
BudgetWhether there is a budget定义 and over-limit actions
ConstraintsWhether path denylists, attempt上限, and other constraints are成文
Governance / Run logWhether there is a run log and LOOP.md self-description

Chapter Summary ​

  • The core of Loop Engineering is "design loops, not写 prompts";
  • Five blocks (Automations/Worktrees/Skills/Plugins&Connectors/Sub-agents) + Memory form the完整架构;
  • Four loop types correspond to different trigger and stop scenarios;
  • Loop Ready Score provides a quantitative评估 of production-readiness.

🧪 随堂测验

点击你认为正确的选项。答错时会展示正确答案与原因解析。

1. Which phrase best概括izes the core philosophy of Loop Engineering?

2. Which of the following is NOT one of Loop Engineering's five building blocks?

3. What is the core difference between /goal and /loop?

4. When Loop Ready Score is below 60, what does the official建议?

🛠️ Hands-on Practice ​

  1. Use npx @cobusgreyling/loop init . --pattern daily-triage --tool claude to initialize a Daily Triage loop; run loop doctor to查看 the health status.
  2. Design a /goal loop for a simple task;明确 the goal, verification method, and stop condition.
  3. Read the output of loop-audit;理解 each audit dimension; and改进 your loop针对 the lowest-scoring dimension.

After completing the exercises, proceed to Next chapter: Seven Production Loop Patterns.