SuperAPI AI Directory

loop-three-elements

Agents & models

View repository

Updated 10-15 23:44

About this skill

Source Metadata

Original cangjie-skill frontmatter from the distillation run:

name: loop-three-elements
description: |
  设计或审计任何循环系统的起点: 将循环拆解为 Trigger(触发器)、Action(动作)、Stop Condition(停止条件) 三要素。
  当用户需要设计一个新循环、诊断一个失效循环、或向他人解释"什么是 Loop"时使用。
  不适用于: 单次任务执行、非循环的自动化脚本、或已经稳定运行无需重新设计的系统。
  关键 trigger: "设计一个 loop"、"这个循环为什么不停止"、"什么是 loop 的最小结构"。
source_book: "Loop Engineering 视频合集 (Gillock/Cherny/Steinberger/Idoos Money/小木头)"
source_chapter: 视频1/3/4
tags: [loop-design, core-concept, trigger, action, stop-condition]
related_skills: [loop-worthiness-test, goal-verification, loop-build-path]
The Three Elements of a Loop — the minimal working structure of any loop

R — Reading (Original Text)

"A loop is three things: a trigger, an action, and a stop condition." — Adam Gillock (Video 1)

"The first block is the heartbeat, which is used to automatically trigger... the second block is the work tree... the third block is skill... the fourth block is connector... the fifth block is sub-agent... and finally there is that spine — memory." — 小木头 (Video 3)

I — Interpretation (Self-Explanation)

Any loop system, no matter how complex, can be broken down into three basic elements:

  1. Trigger: Under what conditions does the loop start? It can be timed (cron), event-based (a new email arrives), or a state change (CI failure).
  2. Action: What operation is performed after the loop starts? This is the main logic of the loop.
  3. Stop Condition: When is the task judged complete and the loop exited? It can be goal achieved (collected 5 items), a maximum count (at most 8 rounds), or a state judgment (no new tasks).

None of the three elements can be missing: a loop without a trigger does not know when to start; a loop without an action is an empty shell; a loop without a stop condition will run indefinitely until resources are exhausted.

A1 — Past Application (Cases in the Book)

Case 1: Boris Cherny's Support Loop (Video 2)

  • Trigger: Start on a timer every 30 minutes
  • Action: Read new support tickets → AI classifies + replies → Record friction/ideas to the signals folder
  • Stop Condition: No new tickets or the maximum processing count is reached

Case 2: 小木头's Topic Selection Loop (Video 3)

  • Trigger: Every morning at 8 (cron)
  • Action: Pull AI news from the past 24h → Rate with the topic-score sub-agent → Append to inbox.md
  • Stop Condition: No new news or the inbox reaches its limit

A2 — Future Trigger

Users will need this skill in the following situations:

  1. When designing a new loop: "I want AI to automatically do X every day" → First ask: What is the trigger? What is the action? When does it stop?
  2. When diagnosing a failing loop: "My loop has been running for 3 days and still hasn't stopped" → Check whether the stop condition is missing or too subjective
  3. When explaining a Loop to the team: Use the three elements as a teaching framework to help non-technical people understand the structure of a loop system
  4. When comparing different Loop implementations: Use the three elements as an analytical framework to compare the triggering strategies and stopping logic of different approaches

Language Signals: "Design a loop", "How does this loop stop", "What is the minimal structure of a loop", "Help me see what this loop is missing"

Differences from Adjacent Skills:

  • loop-worthiness-test: Judges "whether to make a loop" (this skill assumes the decision to do it has already been made and focuses on "how to do it")
  • goal-verification: Focuses on the design of the stop condition (this skill is the overall framework of the three elements)
  • loop-build-path: Focus on the construction steps (this skill is static structural analysis)

E — Execution (executable steps)

Step 1: Identify the three elements

For any loop requirement, first answer three questions:

  1. Trigger: What event/time will start this loop? (If you can't answer, the requirement is unclear)
  2. Action: What operations are specifically executed within the loop? (Write them as a series of verbs: read → analyze → generate → write)
  3. Stop Condition: When is it determined that it is "done"? (As objective and verifiable as possible)

Step 2: Verify the completeness of the three elements

  • Is the Trigger clear? (Not "when needed", but "when X happens")
  • Is the Action executable? (Does the agent have the corresponding tools and permissions?)
  • Is the Stop Condition objective? (Not "until satisfied", but "until metric X is reached or at most N rounds")

Step 3: Design a Hard Stop

Even if the stop condition is subjective, a hard maximum number of iterations must be set:

  • Example: "until the average score ≥ 9 or at most 8 rounds"
  • This is a safety net to prevent runaway loops

B — Boundary

Scenarios where this skill should not be used:

  1. One-off task: "Help me write an email" does not need a loop — there is no repeated trigger
  2. Pure automation script: "Back up the database every day" is a cron job, not a loop — there is no verify-iterate cycle
  3. A system that is already running stably: If the loop is running well, there is no need to re-analyze it with the three elements

The author's blind spots and limitations:

  • The three elements are a static analysis framework and do not address "how the loop system evolves over time" (see three-stage-evolution)
  • The three elements assume the designer has already chosen the task and do not address "whether a loop should be done" (see loop-worthiness-test)
  • All cases in the video are based on the Claude Code ecosystem; other tools may have different ways of implementing the three elements

Adjacent but easily confused methodologies:

  • RAO loop (Reason-Act-Observe): Focuses on the thinking process within a single iteration; the three elements focus on the overall structure of the loop
  • 5+1 architecture: Focuses on the components of the complete system; the three elements are the analysis framework for the minimum usable unit