Loop Engineering (cobusgreyling)
cobusgreyling/loop-engineering β a practical, tool-aware reference repo for Loop Engineering: patterns you can clone, CLI tools that score readiness, and checklists to ship against. It operationalizes the Osmani/Cherny/Steinberger idea β βstop prompting agents; design the loop that prompts themβ β for Grok, Claude Code, Codex, Cursor and other coding agents.
Where Loop Engineering (the note) is the why, this is the how: npx-runnable CLIs, seven production patterns, and starter kits. MIT-licensed.
π Links
Description
- Repo: https://github.com/cobusgreyling/loop-engineering
- Showcase + interactive pattern picker: https://cobusgreyling.github.io/loop-engineering/
- Essay (Substack): https://cobusgreyling.substack.com/p/loop-engineering
- Canonical essay (Addy Osmani): https://addyosmani.com/blog/loop-engineering/
- Companion repo: Goal Engineering β Grok Build
/goalrun-until-done objectives - License: MIT
Download or use
# 1. Scaffold a starter for a pattern + tool
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. Audit loop readiness (budget + run-log scored)
npx @cobusgreyling/loop-audit . --suggest
npx @cobusgreyling/loop-audit . --badge # Loop Ready badge for README
# 4. First report-only loop (Grok example)
/loop 1d Run loop-triage. Update STATE.md. No auto-fix in week one.No clone required β all three CLIs publish to npm from tagged releases. loop-sync (STATE.md β LOOP.md drift) and an MCP runtime-lookup server ship in-repo.
ποΈ Description
π§© The five building blocks + memory
The repoβs core model β a loop is assembled from these primitives (mapped cross-tool in primitives-matrix.md):
| Primitive | Job in the loop |
|---|---|
| Automations / Scheduling | Discovery + triage on a cadence |
| Worktrees | Safe parallel execution |
| Skills | Persistent project knowledge |
| Plugins & Connectors | Reach into real tools via MCP |
| Sub-agents | Maker / checker split |
| + Memory / State | Durable spine outside any conversation |
Anatomy: Schedule β Triage skill β read/write STATE β isolated worktree β implementer sub-agent β verifier sub-agent (tests+gates) β MCP/Git/tickets β human gate β commit/PR or escalate β repeat. This matches the external-state-in-a-DB fix argued in Loop Engineering β state lives outside any one agent session.
π§© The seven patterns
Each ships with a starter kit, a suggested cadence, and a βweek 1β maturity target:
| Pattern | Cadence | Token cost |
|---|---|---|
| Daily Triage | 1dβ2h | Low |
| PR Babysitter | 5β15m | High |
| CI Sweeper | 5β15m | Very high |
| Dependency Sweeper | 6hβ1d | Medium |
| Changelog Drafter | 1d or tag | Low |
| Post-Merge Cleanup | 1dβ6h | Low |
| Issue Triage | 2hβ1d | Low |
Phased rollout is the discipline: L1 report β L2 assisted fixes β L3 unattended. Start report-only.
π§© The three CLI tools
loop-initβ scaffolds a starter plus budget/run-log files for a chosen pattern + tool.loop-costβ token-spend estimator per cadence and maturity level; the antidote to the βone run cost a million tokensβ problem.loop-auditβ Loop Readiness Score (v1.4, with activity detection);--suggestrecommends next steps,--badgeemits a README badge.
βοΈ Reasoning for
This is the missing checklist layer between the Loop Engineering concept and actually running loops on Qamera AI / PLSoft repos. The concept noteβs conclusion is βloop engineering β Harness Engineering, mind the cost/context downsidesβ β this repo turns those warnings into scored gates: loop-cost before you commit to a cadence, loop-audit to check youβre not skipping verification, phased L1βL3 so nothing runs unattended before itβs earned trust.
Most useful to me:
loop-costup front β decide affordability before a loop bleeds tokens.- The pattern catalog β PR Babysitter / CI Sweeper / Issue Triage are exactly the recurring chores Iβd hand a loop first.
- Report-only L1 default β matches the human-in-the-loop caution I already trust from Archon.
Caveat the repo states plainly: loops amplify judgment β good and bad; verification is still on you; comprehension debt grows unless you read what the loop ships.
Alternatives considered
- Archon β a deterministic harness engine (YAML DAG + worktrees + Postgres durability). loop-engineering is patterns + audit CLIs, not a runtime; Archon is the heavier, deterministic answer to the same problem.
- Loop Engineering via raw
/loop/goal/routinesβ the Claude Code primitives alone, no readiness scoring or cost estimation. - Karpathy Skills / Awesome Claude Code β skill/prompt curation, not loop orchestration.
π Resources
- Concepts doc (intent debt, comprehension debt, harness vs loop): https://github.com/cobusgreyling/loop-engineering/blob/main/docs/concepts.md
- Failure modes & anti-patterns catalogs:
docs/failure-modes.md,docs/anti-patterns.md - Multi-loop coordination (when loops collide):
docs/multi-loop.md - Author: Cobus Greyling
π Further reading
- Loop Engineering β the concept this repo implements (Cole Medinβs skeptical take)
- Harness Engineering Β· Harness Engineering in Practice β the broader discipline loops fold into
- Context Engineering β why single-session loops poison context
- Token Optimization for Claude Code β related cost control
- Agentic Auto-Scheduling (COMPILOT) β a feedback loop inside a compiler
- 4 Claude Code Upgrades for Making Money (Nate Herk) β
/goal+ subagents in practice
Template: tool