← Discover MCPs and Agents
l
MCPAI & MLGitHub

loop-engineering

Practical patterns, starters & CLI tools for loop engineering with AI coding agents. Design systems that prompt and orchestrate agents (inspired by Addy Osmani and Boris Cherny). Includes loop-audit, loop-init, loop-cost.

Links

README

From the repo.

Loop Engineering

Explore the Showcase

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

Loop Engineering logo

Stop prompting. Design the loop. Get a score.

Loop Engineering — design the system that prompts your agents

# Front door (recommended) — one binary for init + doctor + status
npx @cobusgreyling/loop init . --pattern daily-triage --tool grok
npx @cobusgreyling/loop doctor .

# Same as before (still fully supported — forks need not change)
npx @cobusgreyling/loop-init .
# Optional: also scaffold a versioned harness (harness-foundry)
npx @cobusgreyling/loop init . --with-foundry

loop init (or loop-init) scaffolds skills, state, and budget files, then prints your Loop Ready score and first loop command. loop doctor combines audit + sync + file checks into top-3 next actions. Swap --tool for claude, codex, or opencode. Use --with-foundry when you want the loop as a composable runtime stack. See docs/cli-front-door.md.

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

Contents

Quick Links

Start hereDescription
Quickstart (5 min)loop initloop doctor → first loop — start here if you just landed
CLI front doorUnified @cobusgreyling/loop — old packages stay open
Loop Engineering essayThe concept, primitives, and Grok mapping — read for the why
Pattern PickerWhich loop to run first — start here if unsure
Primitives MatrixCross-tool loop primitive mapping — bookmark this
Loop Design ChecklistShip readiness rubric
Patterns7 production patterns + interactive picker
StartersClone-and-run kits (Grok, Claude Code, Codex, Opencode)
Opencode examplesCLI-first loops: cron/systemd + opencode run, skills, worktrees
loop (front door)Unified CLInpx @cobusgreyling/loop init | doctor | status | audit | cost · cli-front-door
loop-auditLoop Readiness Score CLI (v1.7 — constraints + governance + Harness Runtime) — npx @cobusgreyling/loop audit . --suggest · also loop-audit
loop-initScaffold starters + budget/run-log + constraints (v1.5) — npx @cobusgreyling/loop init . --pattern daily-triage --tool grok · also loop-init
harness-foundryCompanion runtime: versioned stacks, sessions, traces — npx @cobusgreyling/harness-foundry init --from loop-engineering:daily-triage
outerloopCompanion governance: evidence → verdict → answerability
loop-costToken spend estimator — npx @cobusgreyling/loop-cost
loop-syncDrift detection between STATE.md and LOOP.mdnpx @cobusgreyling/loop-sync .
loop-contextStateful memory manager + circuit breaker for long runs — npx @cobusgreyling/loop-context --check --ledger run.json
loop-mcp-serverMCP runtime lookup for patterns, skills, state — npx @cobusgreyling/loop-mcp-server
loop-worktreeManage isolated git worktrees per fix attempt — npx @cobusgreyling/loop-worktree create --run-id <id> --pattern <p>
loop-gateMechanical enforcement of the path denylist + auto-merge allowlist from gate.yamlnpx @cobusgreyling/loop-gate check --action auto-merge --paths <f1,f2,...>
loop-sandboxEphemeral git worktree isolation + patch capture — npx @cobusgreyling/loop-sandbox run -- <cmd>
loop-actionGitHub Composite Action for running loops in CI — uses: cobusgreyling/loop-engineering/tools/loop-action@main
Goal EngineeringCompanion: loops discover, goals finish — /goal + stack cookbook (npx @cobusgreyling/goal doctor .)
Memory EngineeringCompanion: stop re-explaining the repo — tiers, budget, Memory Ready score (node tools/memory-init/cli.js .)
Fleet EngineeringCompanion: govern populations of agents — registry, inbox, Fleet Ready score (npx @cobusgreyling/fleet-init .)
StoriesReal wins and honest failures

Ecosystem stack

memory-engineering → loop-engineering → harness-foundry → outerloop → fleet-engineering
   (persist)            (patterns)         (runtime)        (verdict)     (population)
LayerYou getStart
MemoryTiers, recall budget, Memory Ready scorememory-engineering
Design (this repo)Patterns, starters, Loop Ready scorenpx @cobusgreyling/loop init . then loop doctor .
RuntimeVersioned harness, traces, evolvenpx @cobusgreyling/loop init . --with-foundry or Foundry showcase
GovernEvidence, verdict, answerabilityouterloop
FleetRegistry, inbox, budgets, kill switchnpx @cobusgreyling/fleet-init . · Fleet Ready

Scale beyond one loop: when agents forget across sessions, add memory-engineering. When you have many agents/loops on a team, add fleet-engineering.

Next after Loop Ready 80+: version the loop as a harness — loop-init prints the CTA automatically; loop-audit recommends Foundry when the score is strong but .foundry/stack.yaml is missing.

Community & announcements

DiscussionSummary
Contributor quickstartHelp wanted: open good first issues — comment I'll take this to get assigned · see Help wanted
Community updateJuly 4: 5.5k stars, traffic sources, contributor merges
Community week (Jul 8)loop-worktree npm, MCP quickstart, tool appendices
npm update (Jul 16)loop-context 1.2.0 + loop-worktree 1.1.0 — daily budget, path locks
Maintenance (Jul 10)Doc sync, branch prune, loop-audit 1.6.0 follow-up
Prior release notesv1.5.0 — loop-sync, constraints, MCP server
Add your projectPinned: Loop Ready badge + adopters list

Why This Matters

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

PrimitiveJob in the Loop
Automations / SchedulingDiscovery + triage on a cadence
WorktreesSafe parallel execution
SkillsPersistent project knowledge
Plugins & ConnectorsReach into your real tools (MCP)
Sub-agentsMaker / checker split
+ Memory / StateDurable spine outside any conversation

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

Visual Overview

The Five Building Blocks + Memory — Loop Engineering

Anatomy of a Loop

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

Deeper diagrams — the actor-level sequence within one run, the run lifecycle's states, autonomy levels L1-L3, and how tools/ maps onto the primitives — live in docs/architecture-diagrams.md.

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

Patterns

Seven production loop patterns with cadence and token cost

PatternCadenceStarterWeek 1Token cost
Daily Triage1d–2hminimal-loopL1 reportLow
PR Babysitter5–15mpr-babysitterL1 watchHigh
CI Sweeper5–15mci-sweeperL2 cautiousVery high
Dependency Sweeper6h–1ddependency-sweeperL2 patch-onlyMedium
Changelog Drafter1d or tagchangelog-drafterL1 draftLow
Post-Merge Cleanup1d–6hpost-merge-cleanupL1 off-peakLow
Issue Triage2h–1dissue-triageL1 propose-onlyLow

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 + Loop Ready score (printed automatically)
npx @cobusgreyling/loop init . --pattern daily-triage --tool grok

# 2. One health check (audit + sync + files → top 3 actions)
npx @cobusgreyling/loop doctor .

# 3. Optional: cost estimate / badge / day-2 dashboard
npx @cobusgreyling/loop cost --pattern daily-triage --level L1
npx @cobusgreyling/loop badge .
npx @cobusgreyling/loop status .

# 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.

Same as before: npx @cobusgreyling/loop-init and loop-audit still work — CLI front door.

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

Develop from source (monorepo contributors):

cd tools/loop && npm ci && npm test && node dist/cli.js doctor ../..
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.

Examples by Tool

Operating & Safety

Caveats

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

Help wanted

First PR? Pick one open issue below. Stories and adopters get same-day review when possible. See CONTRIBUTORS.md and the contributor quickstart.

11 open good first issues (refreshed 2026-07-29). Comment "I'll take this" for assignment.

TimeIssueWhat you ship
~10 min#120 — Adopters listOne row in docs/adopters.md (or Add Adopter template)
~15–20 min#118 — Daily Triage story · #173 — Issue Triage story · #119 — PR Babysitter failure · #427 — loop-sandbox storyHonest stories/ write-up + index row
~20–25 min#425 — MiniMax foundry flags · #426 — worktree lock importAdditive QUICKSTART notes for MiniMax + public loop-worktree/lock
~25–30 min#424 — loop-swarm QUICKSTART · #428 — budget-negotiator docsDiscoverability for swarm consensus + L3 budget negotiation
~40–45 min#387 — Hermes CI Sweeper · #388 — Hermes Issue TriageFill pattern-coverage gaps in examples/hermes/
AnytimeTemplatesAdd Adopter · Share a story
HubsDiscussionsShow your loop · Ask anything

Recently shipped (thanks!): Windsurf examples (#384–#386), loop-action/sandbox/gate QUICKSTART (#389–#391), CI Sweeper story (#392), loop-action hardening (#393/#395).

Maintainers re-seed the backlog with bash scripts/create-good-first-issues.sh (idempotent; skips existing titles). Prefer live open GFI filter over this table if a row looks stale.

Contributing

Share production patterns, tool mappings, and failure stories. See CONTRIBUTING.md (contribution ladder + good first issue backlog), Code of Conduct, adopters, and hubs: Show your loop · Ask anything.

Sources

License

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

Static chart (CI-updated daily). Live chart needs a GitHub token — stored in your browser only.

Collected info

  • 9,826 stars
  • 1,335 forks
  • Language: JavaScript
  • Source updated: 8/4/2026

Config for your environment

Replace {MCP_ENDPOINT_URL} with this MCP’s endpoint URL (from its repo or docs above). No API key — you connect directly.

Tool

OS

Config file: ~/.cursor/mcp.json

{
  "mcpServers": {
    "mcp-server": {
      "url": "{MCP_ENDPOINT_URL}"
    }
  }
}

Paste into mcpServers in the config file. Restart Cursor after saving.

If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.