开源项目 GitHub Topic ai-coding 2026-07-06T12:02 正文 ok 903 words

📦 cobusgreyling/loop-engineering:AI 编码代理的循环工程实用模式、起步模板与 CLI 工具

英文标题:📦 cobusgreyling/loop-engineering

本项目为使用 AI 编码代理(如 Claude Code、Codex、Cursor 等)的开发者提供循环工程(Loop Engineering)参考实现与配套 CLI 工具链。核心理念是“停止手工提示,设计驱动代理的循环”,提供了 loop-init、loop-audit、loop-cost 等工具,能够自动生成项目骨架、计算成本、评估循环准备度并输出评分。项目包含 7 种生产级循环模式、多个可克隆的起步套件以及五类基础原语(自动化、工作树、技能、插件、子代理),帮助开发者从手动提示转向系统化的代理编排,对提升 AI 编码流程的可靠性与可维护性具有重要实践意义。
打开原文相关 6.3 · 机会 8
media748 B media2.6 KB media1.3 KB media1.3 KB media1.3 KB media1.3 KB media1.3 KB media1.3 KB media1.2 KB media1.3 KB media1.2 KB media115.9 KB media70.5 KB media989 B media104.8 KB media5.6 KB media4.9 KB media142.3 KB media142.3 KB media115.9 KB

中文

Explore the Showcase

GitHub stars loop-audit dogfood loop-audit npm loop-init npm loop-cost npm loop-sync npm loop-context npm MIT Pages

Loop Engineering 徽标

停止手工提示。设计循环。获得评分。

Loop Engineering — 设计驱动代理的系统

npx @cobusgreyling/loop-init .

loop-init 会搭建技能、状态和预算文件,然后打印您的 Loop Ready 评分以及第一条循环命令。通过 --tool 可切换为 claude、codex 或 opencode。

Loop Ready 评分在 15 秒内从 10 升至 100

循环工程取代了您亲自向代理发送提示的角色 — 您转而设计执行这一工作的系统。

新来的? 快速入门 (5 分钟) · 交互式选择器

适用于使用 Grok、Claude Code、Codex、Cursor 以及其他 AI 编码代理的开发者。

→ 交互式展示 + 模式选择器 · 文章 · Addy Osmani

从这里开始 说明
快速入门 (5 分钟) 搭建 → 成本检查 → 审计 → 第一个循环 — 刚进入项目时从这里开始
Loop Engineering 文章 概念、原语以及 Grok 映射 — 了解缘由时阅读
模式选择器 先运行哪个循环 — 不确定时从这里开始
原语矩阵 跨工具循环原语映射 — 将此页面加入书签
循环设计检查清单 发布就绪评估表
模式 7 种生产环境模式 + 交互式选择器
起步模板 克隆即用套件(Grok、Claude Code、Codex、Opencode)
Opencode 示例 命令行优先的循环:cron/systemd + opencode run、技能、工作树
loop-audit Loop Readiness Score CLI(v1.5 含约束评分) — npx @cobusgreyling/loop-audit . --suggest · --badge 用于 README
loop-init 搭建起步模板 + 预算/运行日志 + 约束(v1.2) — npx @cobusgreyling/loop-init . --pattern daily-triage --tool grok
loop-cost 令牌消耗估算器 — npx @cobusgreyling/loop-cost
loop-sync 检测 STATE.md 与 LOOP.md 之间的漂移 — npx @cobusgreyling/loop-sync .
loop-context 有状态的内存管理器及长时间运行的熔断器 — npx @cobusgreyling/loop-context --check --ledger run.json
loop-mcp-server 用于模式、技能、状态的 MCP 运行时查找 — node tools/mcp-server/dist/index.js(仓库版本 v1;npm 待发布)
Goal Engineering 配套项目: 循环负责发现,目标负责完成 — /goal + 技术栈手册(npx @cobusgreyling/goal doctor .)
故事 真实的成功经验与诚实的失败教训
贡献者快速入门 求助: 12 个限定了范围的 good first issues — 留言 I'll take this 即可被分配
社区更新 7 月 4 日: 5.5k star、流量来源、贡献者合并
先前发布说明 v1.5.0 — loop-sync、约束、MCP 服务器
添加您的项目 置顶: Loop Ready 徽章 + 采用者列表

Peter Steinberger:

“您不应该再手动提示编码代理了。您应该设计能提示代理的循环。”

Boris Cherny(Anthropic Claude Code 负责人):

“我不再直接提示 Claude。我有正在运行的循环来提示 Claude 并决定该做什么。我的工作就是编写循环。”

杠杆点已经从编写零散的提示转向设计能够持续编排代理的控制系统。

五大构建模块 + 记忆

原语 在循环中的职责
自动化/调度 按节奏执行发现与分类
工作树 安全的并行执行
技能 持久化的项目知识
插件与连接器 连接到您的真实工具(MCP)
子代理 制造者/检查者分离
+ 记忆/状态 在对话之外的持久化主干

完整细节:docs/primitives.md · 跨工具矩阵:docs/primitives-matrix.md

五大构建模块 + 记忆 — Loop Engineering

动画循环流程 — 调度、分类、状态、工作树、实现、验证、MCP、人工关卡

Mermaid 图(可直接复制)

flowchart LR A[调度/自动化] --> B[分类技能] B --> C[读写状态/记忆] C --> D[隔离的工作树] D --> E[实现者子代理] E --> F[验证者子代理测试 + 关卡] F --> G[MCP / Git / 工单] G --> H{人工关卡?} H -->|安全 / 白名单| I[提交 / PR / 操作] H -->|风险 / 不确定| J[升级给人工并附上完整上下文] I --> A J --> A

加载中

该参考仓库现在在每次推送和 PR 时运行自己的 validate-patterns + audit 工作流(参见 .github/workflows/)。我们还添加了描述将维护自身的循环的 LOOP.md。

七种生产循环模式及其节奏与 token 成本

不确定选哪个?试试交互式选择器或模式选择器。

机器可读索引:patterns/registry.yaml(7 种模式)

开始使用(5 分钟)

bash

1. 搭建并自动获取您的 Loop Ready 评分

npx @cobusgreyling/loop-init . --pattern daily-triage --tool grok

2. 估算您设定节奏下的 token 消耗

npx @cobusgreyling/loop-cost --pattern daily-triage --level L1

3. 改进后重新审计

npx @cobusgreyling/loop-audit . --suggest

可选:将 Loop Ready 徽章粘贴到您的 README 中

npx @cobusgreyling/loop-audit . --badge

4. 观察评分提升:空 → L1 → L2

bash scripts/before-after-demo.sh

5. 以仅报告模式启动(Grok 示例)

/loop 1d 运行 loop-triage。更新 STATE.md。第一周不自动修复。

所有三个 CLI 工具均通过带标签的发布版发布到 npm — 参见 docs/RELEASE.md。无需克隆仓库。

从源码开发(monorepo 贡献者):

bash cd tools/loop-init && npm ci && npm test && node dist/cli.js /path/to/project --pattern daily-triage --tool grok cd tools/loop-audit && npm ci && npm test && node dist/cli.js /path/to/project --suggest cd tools/loop-cost && npm ci && npm test && node dist/cli.js --pattern ci-sweeper --cadence 15m

分阶段推出:L1 报告 → L2 辅助修复 → L3 无人值守 — 参见 循环设计检查清单。

循环工程会放大判断力 — 无论是好的还是坏的。

  • token 成本 可能随着子代理和长时间运行的循环而爆炸性增长。
  • 验证仍然是您的责任。 无人值守的循环会造成无人察觉的错误。
  • 理解债务 增长得更快,除非您阅读循环所交付的内容。
  • 两个人运行相同的循环可能会得到完全相反的结果。循环自己并不知道,但您知道。

Addy Osmani:

“构建循环。但要像一个打算继续当工程师的人那样去构建,而不仅仅是按下启动按钮的人。”

第一次提交 PR? 从贡献者快速入门开始 — 大约 10 分钟到 1 小时的任务,关于故事和采用者的内容会在当天内得到审核。

在任何一个 good first issue 下留言 “I'll take this” 以获取分配。

欢迎分享生产模式、工具映射以及失败故事。参见 CONTRIBUTING.md(贡献阶梯 + good first issue 积压事项)、采用者以及 GitHub Discussions。

MIT


面向循环工程的实用、工具感知的参考,可供复制的模式,等等。

English / 原文

Explore the Showcase

GitHub stars loop-audit dogfood loop-audit npm loop-init npm loop-cost npm loop-sync npm loop-context npm MIT Pages

Loop Engineering logo

Stop prompting. Design the loop. Get a score.

Loop Engineering — design the system that prompts your agents

npx @cobusgreyling/loop-init .

loop-init scaffolds skills, state, and budget files, then prints your Loop Ready score and first loop command. Swap --tool for claude, codex, or opencode.

Loop Ready score climbs from 10 to 100 in 15 seconds

Loop engineering replaces you as the person who prompts the agent — you design the system that does it instead.

New here? Quickstart (5 min) · Interactive picker

For developers using Grok, Claude Code, Codex, Cursor, and other AI coding agents.

→ Interactive showcase + pattern picker · Essay · Addy Osmani

Start here Description
Quickstart (5 min) Scaffold → cost check → audit → first loop — start here if you just landed
Loop Engineering essay The concept, primitives, and Grok mapping — read for the why
Pattern Picker Which loop to run first — start here if unsure
Primitives Matrix Cross-tool loop primitive mapping — bookmark this
Loop Design Checklist Ship readiness rubric
Patterns 7 production patterns + interactive picker
Starters Clone-and-run kits (Grok, Claude Code, Codex, Opencode)
Opencode examples CLI-first loops: cron/systemd + opencode run, skills, worktrees
loop-audit Loop Readiness Score CLI (v1.5 + constraints scoring) — npx @cobusgreyling/loop-audit . --suggest · --badge for README
loop-init Scaffold starters + budget/run-log + constraints (v1.2) — npx @cobusgreyling/loop-init . --pattern daily-triage --tool grok
loop-cost Token spend estimator — npx @cobusgreyling/loop-cost
loop-sync Drift detection between STATE.md and LOOP.md — npx @cobusgreyling/loop-sync .
loop-context Stateful memory manager + circuit breaker for long runs — npx @cobusgreyling/loop-context --check --ledger run.json
loop-mcp-server MCP runtime lookup for patterns, skills, state — node tools/mcp-server/dist/index.js (repo v1; npm pending)
Goal Engineering Companion: loops discover, goals finish — /goal + stack cookbook (npx @cobusgreyling/goal doctor .)
Stories Real wins and honest failures
Contributor quickstart Help wanted: 12 scoped good first issues — comment I'll take this to get assigned
Community update July 4: 5.5k stars, traffic sources, contributor merges
Prior release notes v1.5.0 — loop-sync, constraints, MCP server
Add your project Pinned: Loop Ready badge + adopters list

Peter Steinberger:

“You shouldn’t be prompting coding agents anymore. You should be designing loops that prompt your agents.”

Boris Cherny (Head of Claude Code at Anthropic):

“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.”

The leverage point has moved from crafting individual prompts to designing the control systems that orchestrate agents over time.

The Five Building Blocks + Memory

Primitive Job in the Loop
Automations / Scheduling Discovery + triage on a cadence
Worktrees Safe parallel execution
Skills Persistent project knowledge
Plugins & Connectors Reach into your real tools (MCP)
Sub-agents Maker / checker split
+ Memory / State Durable spine outside any conversation

Full detail: docs/primitives.md · Cross-tool matrix: docs/primitives-matrix.md

The Five Building Blocks + Memory — Loop Engineering

Animated loop flow — schedule, triage, state, worktree, implement, verify, MCP, human gate

Mermaid diagram (copy-friendly)

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

Loading

This reference repo now runs its ownvalidate-patterns + audit workflows on every push/PR (see .github/workflows/). We also added LOOP.md describing the loops that will maintain it.

Seven production loop patterns with cadence and token cost

Not sure which to pick? Try the interactive picker or pattern-picker.

Machine-readable index: patterns/registry.yaml (7 patterns)

Getting Started (5 minutes)

# 1. Scaffold + get your Loop Ready score (printed automatically)
npx @cobusgreyling/loop-init . --pattern daily-triage --tool grok

# 2. Estimate token spend for your cadence
npx @cobusgreyling/loop-cost --pattern daily-triage --level L1

# 3. Re-audit after improvements
npx @cobusgreyling/loop-audit . --suggest

# Optional: paste Loop Ready badge into your README
npx @cobusgreyling/loop-audit . --badge

# 4. See scores climb: empty → L1 → L2
bash scripts/before-after-demo.sh

# 5. Start report-only (Grok example)
/loop 1d Run loop-triage. Update STATE.md. No auto-fix in week one.

All three CLIs publish to npm from tagged releases — see docs/RELEASE.md. No clone required.

Develop from source (monorepo contributors):

cd tools/loop-init && npm ci && npm test && node dist/cli.js /path/to/project --pattern daily-triage --tool grok
cd tools/loop-audit && npm ci && npm test && node dist/cli.js /path/to/project --suggest
cd tools/loop-cost && npm ci && npm test && node dist/cli.js --pattern ci-sweeper --cadence 15m

Phased rollout: L1 report → L2 assisted fixes → L3 unattended — see loop-design-checklist.

Loop engineering amplifies judgment — both good and bad.

  • Token costs can explode with sub-agents and long-running loops.
  • Verification is still on you. Unattended loops make unattended mistakes.
  • Comprehension debt grows faster unless you read what the loop ships.
  • Two people can run the same loop and get opposite results. The loop doesn't know. You do.

Addy Osmani:

“Build the loop. But build it like someone who intends to stay the engineer, not just the person who presses go.”

First PR? Start with the contributor quickstart — ~10 min to ~1 hr tasks with same-day review on stories and adopters.

Comment "I'll take this" on any good first issue for assignment.

Share production patterns, tool mappings, and failure stories. See CONTRIBUTING.md (contribution ladder + good first issue backlog), adopters, and GitHub Discussions.

MIT


Practical, tool-aware reference for loop engineering, patterns you can clone, checklists you can ship against, and stories that include what broke.

Essay · Showcase · Cobus Greyling

Star History Chart