Loop Engineering
Loop Engineering provides reusable prompt patterns, scaffolds, and CLI tools for running budgeted, human-gated repository loops such as daily triage, PR babysitting, and CI cleanup with Codex, Claude Code, Grok, and OpenCode.
Project overview
Loop Engineering is a pattern library and toolset for operating coding agents around a repository. Instead of supplying a single large prompt, it organizes recurring work into observable loops with state, budgets, gates, escalation rules, and stop conditions. Its starters cover daily triage, pull-request follow-up, CI cleanup, dependency sweeps, and related maintenance. The unified CLI can scaffold Codex, Claude Code, Grok, or OpenCode, but the repository recommends starting with report-only automation before allowing edits.
Core capabilities
Pattern and starter library
Reusable prompt workflows define triggers, state, outputs, escalation, and stopping behavior for common repository maintenance tasks.
Multi-host scaffolding
The loop init command generates host-specific configuration for Codex, Claude Code, Grok, or OpenCode instead of requiring a manual copy from the examples directory.
Readiness, gates, and budgets
doctor, audit, gate, and cost-related commands help inspect configuration completeness, policy checks, loop levels, and likely spend before scheduling a run.
Stateful recurring operation
STATE.md, LOOP.md, run logs, and budget files make the next run aware of prior work and give people artifacts to review.
Optional MCP and advanced execution
The repository includes an MCP server plus worktree, sandbox, and swarm-oriented materials for teams that need a broader execution surface.
Access and usage
Run the unified CLI in a disposable or low-risk repository, choose Codex explicitly, inspect generated files, and keep the first week in L1 report-only mode. Add a schedule only after doctor and audit output are understood.
Let an AI Agent install it
Send this prompt to Codex, Claude Code, or another AI agent that can work with your local environment.
Help me configure Loop Engineering for Codex in a low-risk test repository. Use https://github.com/cobusgreyling/loop-engineering at commit c78d70f30dcef8d39686499287b41c867f5c17fb. First read README.md, docs/QUICKSTART.md, docs/SAFETY.md, SECURITY.md, LICENSE, and tools/loop/package.json. Confirm Node.js 18+ and show the files that `npx @cobusgreyling/loop init . --pattern daily-triage --tool codex` will create before running it. Keep the loop at L1 report-only for the first week. Deny secrets, credentials, infrastructure, migrations, authentication, payments, and billing paths. Do not place API keys in prompts, STATE.md, logs, or scheduler configuration. Run doctor and cost checks after initialization. Do not schedule the loop, enable L2/L3, raise token budgets, edit source files, comment on GitHub, or merge anything without my explicit approval.- Node.js 18 or newer with npx
- Git and a version-controlled test repository
- Codex installed and authenticated for the intended repository
- A small, reviewable first pattern such as daily-triage
- Defined budget, denied paths, stop conditions, and approval owner
npx @cobusgreyling/loop init . --pattern daily-triage --tool codex- 1Read the pattern and safety guidance
Review README, Quickstart, Safety, Security, and the daily-triage starter. Decide which repository data the loop may read and which paths and external actions are denied.
- 2Scaffold a Codex loop
From a low-risk repository, run `npx @cobusgreyling/loop init . --pattern daily-triage --tool codex`. Inspect every generated file before committing anything.
- 3Run doctor and cost checks
Use `npx @cobusgreyling/loop doctor .` and `npx @cobusgreyling/loop cost --pattern daily-triage --level L1`. Resolve missing gates and set a conservative token budget.
- 4Test one report-only run
Run the daily-triage prompt manually. Confirm it writes only the expected report and state artifacts, respects denied paths, and stops when a human decision is required.
- 5Schedule and promote deliberately
Schedule L1 only after the manual result is clean. Review reports for a week before considering narrow L2 edits. Treat L3 as a separate governance decision.
Run `npx @cobusgreyling/loop doctor .`, inspect the generated LOOP.md, STATE.md, budget, and log configuration, then estimate the L1 run with `npx @cobusgreyling/loop cost --pattern daily-triage --level L1`. The first scheduled run should create a report only and should not edit source files or merge changes.
- Use an explicit package version in long-lived automation after choosing the release line you intend to track.
- The GitHub Release version and the unified CLI package version are currently different; record both in change management.
- Keep connector permissions read-only during L1 wherever the host allows it.
- Review generated state and log files for sensitive code or issue content before committing them.

Use cases
Daily repository triage
Summarize failing checks, stale pull requests, new issues, and maintenance signals into a report without changing source code.
Pull-request babysitting
Watch a pull request, report review or CI changes, and prepare narrowly scoped follow-up work behind explicit comment and push permissions.
CI and dependency sweeps
Collect repeat failures or outdated dependencies, apply budget and file-count limits, and escalate sensitive or broad changes to a maintainer.
Loop readiness audits
Use readiness and gate checks to evaluate whether an existing agent workflow has state, budgets, stop rules, evidence, and ownership.
Assessment
Loop Engineering is strongest as an operational design reference: it connects prompts to state, budgets, gates, and evidence instead of treating automation as a single instruction. The Codex scaffold and report-only starting point make it practical to evaluate without immediately granting write access. The main caution is release interpretation and execution trust. The repository's v1.6.0 release and 0.2.0 unified CLI are different version surfaces, recent activity includes automation, and the behavior of a generated loop still depends on the selected model, host, connectors, and repository. This review did not run the CLI.
Why it may be useful
- Patterns describe operational artifacts, escalation, and stop conditions, not only prompts
- Codex, Claude Code, Grok, and OpenCode have direct scaffold paths
- L1, L2, and L3 make permission growth explicit
- MIT licensing, security reporting, and safety guidance are clearly published
What to know first
- GitHub Release and unified CLI versions use different numbers
- Unattended results still vary with the model, host, connectors, and repository
- Recent commit activity includes automated maintenance output
- Installation, cost estimates, and loop behavior were not independently tested
README
Loop Engineering
Overview
Loop Engineering provides reusable prompt patterns, scaffolds, and CLI tools for running budgeted, human-gated repository loops such as daily triage, PR babysitting, and CI cleanup with Codex, Claude Code, Grok, and OpenCode. Practical prompt patterns, starters, and CLI tools for designing and operating AI coding-agent loops.
Getting started
- Run the unified CLI in a disposable or low-risk repository, choose Codex explicitly, inspect generated files, and keep the first week in L1 report-only mode. Add a schedule only after doctor and audit output are understood.
- The repository frames loop engineering as the discipline of building systems around agents: prompts, context, state, tools, permissions, feedback, budgets, and stop conditions are treated as one operational design.
- Starters cover daily triage, thin implementation loops, PR babysitting, CI sweeps, dependency sweeps, changelog drafting, post-merge cleanup, and issue triage. Each pattern describes triggers, artifacts, risk, and escalation points.
- Run `npx @cobusgreyling/loop doctor .`, inspect the generated LOOP.md, STATE.md, budget, and log configuration, then estimate the L1 run with `npx @cobusgreyling/loop cost --pattern daily-triage --level L1`. The first scheduled run should create a report only and should not edit source files or merge changes.
Configuration
npx @cobusgreyling/loop init . --pattern daily-triage --tool codexRead the complete README on GitHub →