loop-three-elements

A simple model for any repeating automated process: something starts it, an action happens, and a rule decides when it stops. The start may be a schedule, a new message, or a failed build.

In plain words
What is it for?
Use it to design a new repeating workflow, explain what a loop is, or diagnose one that will not start or stop correctly.
Why use it?
It makes it easier to design a loop that starts at the right time, does useful work, and does not run forever.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/kangarooking/loop-engineering-skill/loop-three-elements
Any agent
npx skills add kangarooking/loop-engineering-skill --skill loop-three-elements
Clone the repo
git clone --depth 1 https://github.com/kangarooking/loop-engineering-skill

Made for: Claude Code, Codex.

Per session 122 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,633 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00122 $0.01633
Opus 5 $0.00061 $0.00816
Sonnet 5 $0.00024 $0.00327
Haiku 4.5 $0.00012 $0.00163

Measured 2d ago against content hash 8fcd65e1387b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

loop-three-elements scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

loop-three-elements/SKILL.md · 109 lines

How it starts

The opening of the file, as written. The whole thing — 109 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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]

Loop 三要素 — 任何循环的最小可工作结构

R — Reading (原文)

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

"第一块心跳,它用来自动触发... 第二块工作树... 第三块skill... 第四块连接器... 第五块子智能体... 最后就是那根脊柱——记忆。" — 小木头 (视频3)

I — Interpretation (自述)

任何循环系统,无论多复杂,都可以拆解为三个基本要素:

  1. Trigger (触发器): 什么条件下启动循环? 可以是定时 (cron)、事件 (新邮件到达)、或状态变化 (CI 失败)。
  2. Action (动作): 循环启动后执行什么操作? 这是循环的主体逻辑。
  3. Stop Condition (停止条件): 何时判定任务完成并退出循环? 可以是目标达成 (凑够 5 条)、次数上限 (最多 8 轮)、或状态判断 (无新任务)。

三要素缺一不可: 没有 trigger 的循环不知道何时开始; 没有 action 的循环是空壳; 没有 stop condition 的循环会无限运行直到资源耗尽。

A1 — Past Application (书中案例)

案例1: Boris Cherny 的 Support Loop (视频2)

  • Trigger: 每 30 分钟定时启动
  • Action: 读取新 support ticket → AI 分类+回复 → 记录摩擦/想法到 signals 文件夹
  • Stop Condition: 无新 ticket 或达到最大处理数

案例2: 小木头的选题 Loop (视频3)

  • Trigger: 每天早上 8 点 (cron)
  • Action: 拉取过去 24h AI 资讯 → 用 topic-score 子智能体评级 → 追加到 inbox.md
  • Stop Condition: 无新资讯或 inbox 达到上限

A2 — Future Trigger (未来触发)

用户会在以下情境下需要这个 skill:

  1. 设计新循环时: "我想让 AI 每天自动做 X" → 先问: trigger 是什么? action 是什么? 何时停止?
  2. 诊断失效循环时: "我的 loop 跑了 3 天还没停" → 检查 stop condition 是否缺失或过主观
  3. 向团队解释 Loop 时: 用三要素作为教学框架,让非技术人员理解循环系统的结构
  4. 比较不同 Loop 实现时: 用三要素作为分析框架,对比不同方案的触发策略和停止逻辑

语言信号: "设计一个 loop"、"这个循环怎么停"、"什么是 loop 的最小结构"、"帮我看看这个 loop 缺什么"

与相邻 skill 的区别:

  • loop-worthiness-test: 判断"要不要做 loop" (本 skill 假设已决定要做,关注"怎么做")
  • goal-verification: 关注 stop condition 的设计 (本 skill 是三要素的整体框架)
  • loop-build-path: 关注构建步骤 (本 skill 是静态结构分析)

Read the full file on GitHub · 109 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 109 lines · 122 tokens per session scan A 8fcd65e1387b

Subscribe to this mod's changes

loop-three-elements is a skill published in the GitHub repository kangarooking/loop-engineering-skill (23 stars, last pushed 2mo ago), licensed MIT. It adds 122 tokens to every session and 1,633 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens