█

AI/TLDR

Buy me a coffee
Buy me a coffee

Loop Engineering

A CLI and starter kits that scaffold scheduled coding-agent loops (triage, PR babysitting, CI and dependency sweeps) into a repo and score how ready they are to run

AI SDLC AutomationOpen source
Latest
v1.6.0
Updated
20 Jul 2026
Language
TypeScript
License
MIT

What's new

v1.6.020 Jul 2026

Added `loop-init --with-foundry` to scaffold a harness-foundry stack alongside the loop, and shipped the `loop-gate` path denylist and auto-merge allowlist. `loop-context` gained stagnation detection and `loop-worktree` a `--wait` queue.

IN SHORT

What is Loop Engineering?

Loop Engineering is an open-source pattern library and command-line toolkit by Cobus Greyling for running AI coding agents in loops around a codebase. It sits in the AI SDLC Automation category of the AI Coding tools and is open-source, written in TypeScript and licensed MIT. To get started: scaffold a pattern.

Updated Markdown version ↗

Overview

Loop Engineering is an open-source pattern library and command-line toolkit by Cobus Greyling for running AI coding agents in loops around a codebase. Instead of typing the next prompt yourself, you set up a system that discovers work on a schedule, hands it to an agent, verifies the result and keeps state in files in the repo. The README is explicit about scope: it is for operating agents around a codebase (keeping issues, CI and dependencies healthy, landing pull requests), not a button that rewrites a module.

Diagram of the anatomy of a loop: schedule, triage skill, STATE memory, isolated worktree, implement sub-agent, verify gates, MCP and PR tools, human gate, then loop back
Anatomy of a loop: schedule, triage, state, worktree, implement, verify, tools, human gate, repeat.Loop Engineering showcase ↗

The installable part is the unified CLI, `npx @cobusgreyling/loop`. `loop init` copies a starter for a chosen pattern and coding tool into your repository and creates `STATE.md`, `LOOP.md`, `loop-budget.md` and `loop-run-log.md`; `loop doctor` runs a readiness audit plus a drift check between `STATE.md` and `LOOP.md` and prints the top three actions. Scaffolding supports Claude Code (the default), Grok, Codex and opencode, and the docs give manual setups for Cursor, Windsurf, OpenClaw, Hermes and GitHub Actions.

Each pattern comes with a cadence and a staged rollout: week one is report-only (L1), then assisted fixes (L2), then unattended runs (L3) only after the verifier has been right for a week. The patterns are Daily Triage, Thin loop, PR Babysitter, CI Sweeper, Dependency Sweeper, Changelog Drafter, Post-Merge Cleanup and Issue Triage. Around them sit smaller tools for the risky parts: a token cost estimator, a circuit breaker that escalates repeated failures to a human, a path denylist and auto-merge allowlist gate, per-attempt git worktrees, a patch-capturing sandbox and an MCP server. The project is MIT-licensed and written in TypeScript; release v1.6.0 shipped on 2026-07-20.

What it does

  • One front door, `npx @cobusgreyling/loop`, with `init`, `doctor`, `status`, `audit`, `cost`, `sync`, `badge`, `context`, `worktree`, `gate`, `mcp` and `sandbox` subcommands
  • Starters for eight loop patterns, from Daily Triage and Issue Triage to PR Babysitter, CI Sweeper and Dependency Sweeper, each with a recommended cadence and week-one level
Grid of the Loop Engineering production patterns with cadence, week-one level and cost: Daily Triage, PR Babysitter, CI Sweeper, Dependency Sweeper, Changelog Drafter, Post-Merge Cleanup and Issue Triage
The production patterns, each with its cadence, week-one level and relative cost.Loop Engineering showcase ↗
  • Loop Ready score from 0 to 100 with suggested next steps; recent runs weigh more than files on disk
  • Token cost estimates per pattern, level and cadence before you schedule anything
  • Safety tooling: a circuit breaker (exit 2 = escalate), a `gate.yaml` denylist and auto-merge allowlist, isolated worktrees per fix attempt and a sandbox that captures changes as a `.patch`
  • Scaffolds for Claude Code, Grok, Codex and opencode, plus a GitHub Actions composite action and an MCP server for on-demand pattern and state lookup

Getting started

Everything runs through npx in the root of an existing git repository; no clone is needed. Week one is report-only: let the loop write to `STATE.md` and read what it says before you allow fixes.

Scaffold a pattern

Pick a pattern and the coding tool you use. `--tool` defaults to `claude`; `grok`, `codex` and `opencode` are also scaffolded. This copies the starter kit, creates the state files and prints your Loop Ready score.

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

Run the health check

`doctor` combines the readiness audit, the STATE/LOOP drift check and a file check. It exits 0 when healthy, 1 on warnings and 2 when blocked (score under 40, critical drift, or not scaffolded). Add `--json` for machine-readable output.

bashbash
npx @cobusgreyling/loop doctor .
Animated terminal-style demo of loop-init followed by loop-audit, with the Loop Ready score climbing from 10 to 70 to 100
The Loop Ready score climbing from 10 to 70 to 100 as a repo is scaffolded and audited.Loop Engineering README ↗

Estimate the token cost

Check what a pattern will spend at a given level and cadence before you schedule it. High-frequency loops such as CI Sweeper at 5 minutes can burn tokens fast.

bashbash
npx @cobusgreyling/loop cost --pattern daily-triage --level L1 --cadence 1d

Start the loop, report-only

In Claude Code, schedule the triage skill with `/loop`. The quickstart's first command reads state, updates priorities and does not touch code.

texttext
/loop 1d Run $loop-triage. Read STATE.md. Merge findings into High Priority and Watch List. Update Last run. Do not edit code.

Set the merge gate before any auto-merge

Copy the `gate.yaml` template to the repo root, then check paths against it. Exit 0 means allowed, 2 means escalate to a human.

yamlyaml
# gate.yaml
version: 1
denylist:
  - "src/auth/**"
  - "**/*.env"
autoMergeAllowlist:
  - "docs/**"
  - "**/*.md"

npx @cobusgreyling/loop gate check --action auto-merge --paths <f1,f2,...>

Check progress

`status` shows a run-log dashboard; re-run `audit --suggest` after each improvement and only move from L1 to L2 to L3 once the verifier has proved itself.

bashbash
npx @cobusgreyling/loop status .
npx @cobusgreyling/loop audit . --suggest

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Setting up a daily, report-only triage loop with Claude Code, Codex, Grok or opencode that keeps a repository's issues, CI and dependencies in a single `STATE.md`
  • Babysitting open pull requests or sweeping failing CI with isolated worktrees and a circuit breaker that hands repeated failures back to a human
  • Putting a mechanical denylist and auto-merge allowlist in front of any agent that is allowed to merge
  • Estimating what a scheduled agent loop will cost in tokens, and scoring whether a repo is ready to run it unattended

How Loop Engineering compares

Loop Engineering alongside other open-source ai sdlc automation tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Multica★ 58.5kSelf-hostable workspace where coding agents are assigned issues like teammates: 26 agent CLIs, runtimes you own, a replayable execution log per run, and review gates before anything ships.
oh-my-codex (OMX)★ 33.9kA workflow layer for the OpenAI Codex CLI that adds agent teams, git-worktree isolation, hooks and HUDs behind a set of canonical plan, code-review and QA commands.
GPT-Pilot★ 33.6kAutonomous AI developer that breaks down an app description into tasks, writes and runs code incrementally, and asks clarifying questions to produce a working production application.
Beads★ 29.3kA Dolt-backed dependency-graph issue tracker for coding agents: hash IDs avoid multi-agent collisions, `bd ready` surfaces unblocked work, and `bd remember` keeps durable project memory.
Vibe Kanban★ 28.9kVibe Kanban lets you plan tasks on a kanban board, run coding agents like Claude Code and Codex in isolated workspaces, then review their diffs and ship pull requests.
Archon★ 24kA workflow engine for AI coding agents: describe plan, implement, validate, review and PR phases as YAML, and every run repeats them in its own git worktree.
Keploy★ 20kAn API testing tool that records real traffic with eBPF — including database and queue calls — and replays it as deterministic tests and data mocks, with no SDK to import and no code changes.
Loop Engineering★ 11.9kA CLI and starter kits that scaffold scheduled coding-agent loops (triage, PR babysitting, CI and dependency sweeps) into a repo and score how ready they are to run