loop-engineering is an MIT-licensed TypeScript pattern library, starter collection, and CLI for developers and platform teams who want to design loops that discover work, hand it to AI coding agents, verify the results, and persist state instead of typing the next prompt themselves.
What it is
Loop engineering lives in the AI coding agent ecosystem and ships a command-line front door published as @cobusgreyling/loop, run through npx. It is a pattern library for operating agents around a codebase, inspired by Addy Osmani and Boris Cherny, and it pairs written patterns with starters and small CLI tools so that agent work runs on a defined cadence rather than on improvisation. The documented patterns each carry a cadence, a week-one rollout level, and a cost tier, so a team can reason about what it is about to automate before switching anything on.
The concrete problem it solves is the habit of manually prompting an agent turn after turn. The project replaces that habit with a loop: a system that discovers work, hands it to agents, verifies results, and persists state. The README is explicit that this is not a "rewrite the module" button — it is infrastructure for keeping a repository healthy, landing and babysitting pull requests, and shipping features or refactors as small PRs from a todos list.
Key capabilities
npx @cobusgreyling/loop init . --pattern daily-triage --tool claude scaffolds a loop; --tool defaults to claude and can be swapped for grok, codex, or opencode.
npx @cobusgreyling/loop doctor . checks whether a repository is ready for a loop.
npx @cobusgreyling/loop cost --pattern daily-triage --level L1 estimates the token cost of a chosen pattern and rollout level.
- A named pattern set with per-pattern cadence, week-one level, and cost:
daily-triage, thin-loop, pr-babysitter, ci-sweeper, dependency-sweeper, changelog-drafter, post-merge-cleanup, and issue-triage, indexed in patterns/registry.yaml.
- Three rollout levels — L1 report, L2 assisted, L3 unattended — with the documented rule that a loop advances only after the verifier has been right for a week.
STATE.md as the persisted loop state, with a thin-loop starter that requires no STATE.md at all.
- Loop Ready scoring that weights recent runs harder than files on disk, so a 30-day-old
STATE.md is not treated as L3.
Who uses it and how
- Teams keeping a repository healthy — issues, CI, dependencies — start with the Quickstart and the
daily-triage pattern, which runs at one day to two hours on a low cost tier and stays at L1 report in week one.
- Maintainers who land and babysit pull requests use the PR Babysitter pattern at a 5-to-15-minute cadence, which the project marks as high cost.
- Platform engineers sweeping CI use
ci-sweeper at 5-to-15 minutes, marked very high cost with an L2 cautious week one.
- Projects that want a loop inside GitHub Actions with almost no files use the thin-loop starter, which needs no
STATE.md and runs on event plus one-day cadence.
- Developers shipping a feature or refactor follow the refactor path, turning todos into small PRs.
Getting started
Run npx @cobusgreyling/loop init . --pattern daily-triage --tool claude, then npx @cobusgreyling/loop doctor . to check readiness. An empty repository can follow scripts/empty-to-state-demo.sh for a first STATE.md walkthrough.
How it compares
The project is deliberately tool-agnostic across the agents it targets, with worked examples for Claude Code, Grok, Codex, OpenClaw, Opencode, and GitHub Actions, plus a Claude Code plugin. Rather than competing with those agents, it sits above them as the loop design and measurement layer, so the same pattern can be reused when a team changes which agent runs the work.
When to use it — and when not to
A self-hoster must operate the loop itself: the STATE.md state file, a verifier that has to prove itself over a week, and the agent tooling behind it, with the README warning plainly that token costs can explode and that unattended loops make unattended mistakes. It is a poor fit for anyone wanting a one-shot code rewrite button, or for teams unwilling to spend week one in report-only mode. Platforms that cannot absorb bursty token spend, or cannot review what an unattended loop ships, should not enable L3.
project readme (upstream, from github) — read inline
Loop Engineering
Stop prompting. Design the loop. Get a score.
Start in 5 minutes ·
Quickstart ·
What do you want to do? ·
Refactor path ·
中文 ·
Pattern picker
npx @cobusgreyling/loop init . --pattern daily-triage --tool claude
npx @cobusgreyling/loop doctor .
--tool defaults to claude if you omit it. Swap for grok, codex, or opencode. Week one is report-only.
You design a system that discovers work, hands it to agents, verifies results, and persists state — instead of typing the next prompt yourself.
New here? Quickstart · Refactor a project · Thin GitHub Action loop (no STATE.md required)
What do you want to do?
This is a pattern library for operating agents around a codebase. It is not a “rewrite the module” button.
Full jobs table: docs/jobs.md.
Patterns
Interactive picker: showcase. Index: patterns/registry.yaml.
Getting started
npx @cobusgreyling/loop init . --pattern daily-triage --tool claude
npx @cobusgreyling/loop doctor .
npx @cobusgreyling/loop cost --pattern daily-triage --level L1
Empty repo → first STATE.md walkthrough: scripts/empty-to-state-demo.sh.
Roll out L1 report → L2 assisted → L3 unattended only after the verifier has been right for a week. See loop-design-checklist.
Loop Ready now weights recent runs harder than files on disk. A 30-day-old STATE.md is not L3.
Examples by tool
Claude Code (including the plugin) · Grok · Codex · OpenClaw · Opencode · GitHub Actions
Operating & safety
Failure modes · Anti-patterns · Safety · Operating loops · Stories (wins and failures)
Loop engineering amplifies judgment. Token costs can explode. Unattended loops make unattended mistakes. Read what the loop ships.
Help wanted
Docs and small PRs: first response within 48 hours.
See CONTRIBUTING.md.
CLI packages and companion repos (optional — not required for week one)
Unified front door: npx @cobusgreyling/loop (init · doctor · status · audit · cost). Older packages (loop-init, loop-audit, …) stay supported.
Companions exist for later: memory-engineering, harness-foundry, outerloop, fleet-engineering, goal-engineering. Do not add them until a loop has actually run.
Sources
License
MIT