How cobusgreyling/loop-engineering works
1. What this repo is
- This is not a single application; it is a reference monorepo for “loop engineering”: a system of reusable agent workflows, starter kits, docs, and CLI tools for designing and operating AI agent loops.
- The repo’s architecture splits cleanly into reference content, starter scaffolds, runtime-specific examples, shared templates/skills, and published Node-based tools.
2. Core domain model
- The central concepts are patterns and loops.
- Patterns live in patterns/ as the canonical catalog of loop types (daily triage, PR babysitter, CI sweeper, dependency sweeper, changelog drafter, post-merge cleanup, issue triage).
- Each pattern is described in prose plus a machine-readable registry (patterns/registry.yaml, schema in patterns/registry.schema.json), which downstream tooling and starters can consume.
3. Documentation and conceptual layer
- docs/, README.md, LOOP.md, STATE.md, and resources/ form the human-facing architecture guide.
- These files explain the primitives, safety model, failure modes, operating rules, and pattern selection process.
- The docs site is also published via GitHub Pages, so the repository doubles as both source code and a static knowledge base.
4. Starter-kit layer
- starters/ contains cloneable project blueprints for different AI runtimes: Claude Code, Codex, Grok, Opencode, and minimal loop variants.
- A starter is the boundary where abstract pattern guidance becomes a concrete repo layout: it packages loop instructions, state files, skills, and sometimes verifier agents.
- There are tool-specific variants because each agent runtime expects different config and file conventions.
5. Shared instruction assets
- templates/ provides reusable file templates for loop state, skill definitions, constraints, and budgets.
- skills/ contains shared skill bundles used by the generated loops.
- scripts/issue-bodies/ holds canonical issue/PR body fragments used by the repo’s workflow automation and issue templates.
- This layer is the repository’s “instruction vocabulary” that gets copied or referenced by starters and tools.
6. Executable tooling layer
- tools/ contains the operational CLIs, each published as its own npm package:
- loop-init: scaffolds a loop into a target project.
- loop-audit: scores readiness and flags missing loop components.
- loop-cost: estimates token/cadence cost.
- loop-sync: detects drift between LOOP.md and STATE.md.
- mcp-server: exposes pattern/skill/state lookup over MCP.
- goal-audit and loop-audit are related audit tools for readiness and goal/project validation.
- These tools are the repo’s execution boundary: they transform the static reference model into actionable checks, generated files, and runtime lookups.
7. Data flow from pattern to running loop
- The usual flow is: pattern selection → starter scaffold → state/skills creation → runtime execution → state updates → audit/sync checks.
- loop-init seeds a project with the files needed to run a loop.
- The loop then writes durable state into files like STATE.md or pattern-specific state docs.
- loop-sync and loop-audit consume those files to detect drift and score readiness over time.
8. Runtime and integration boundaries
- The repo explicitly supports multiple agent runtimes rather than a single implementation.
- examples/ shows how the same loop concepts map into Claude, Codex, Grok, OpenClaw, Opencode, GitHub Actions, and MCP-based setups.
- examples/mcp/ is the connector boundary: it demonstrates read-only and write-safe integrations with external systems such as GitHub, Linear, and Slack via MCP config.
9. Automation and governance
- .github/workflows/ is a major architectural subsystem: it runs validation, auditing, releases, and contributor triage.
- The repo self-hosts its own checks on push/PR, including pattern validation and audit workflows.
- This makes the repo a dogfooded control system: the repo maintains the quality of its own loop patterns and shipped artifacts.
10. Publishing and release path
- The tools under tools/ are packaged and released independently, while the root repo serves as the reference source.
- Release notes, changelogs, and GitHub Actions workflows coordinate the publishing pipeline.
- GitHub Pages is the documentation delivery boundary; npm is the CLI delivery boundary.
11. Examples, stories, and validation artifacts
- stories/ captures real-world outcomes and failure cases, which act as architectural evidence for the patterns.
- tools/*/test and fixture directories validate the tooling against known-good loop projects.
- This is important structurally: the repo uses narrative evidence, fixture projects, and automated tests as separate proof layers for the loop system.
12. Overall architecture in one sentence
- The repo is a reference platform where pattern definitions feed starter kits and skills, which are operationalized by CLI tools and MCP services, verified by CI workflows, and documented through static docs, examples, and stories.
Main entry points: patterns/README.md Pattern catalog · registry.yaml Registry · examples/README.md Runtime examples · mcp-server MCP server
Components 25
Docs & reference
Human-facing architecture, concepts, and published guidance.
- README · Top-level orientation and repo overview.
README.md - LOOP · Operational loop instructions and repo-level loop contract.
LOOP.md - STATE · Repository-level durable state for the reference loop.
STATE.md - Docs site · Static documentation and conceptual guide published via GitHub Pages.
docs/index.html
Patterns
Canonical loop catalog and machine-readable registry.
- Pattern catalog · Canonical prose descriptions of supported loop archetypes.
patterns/README.md - Registry · Machine-readable registry of patterns and their schema.
patterns/registry.yaml - Schema · Validation schema for the pattern registry.
patterns/registry.schema.json
Starters
Cloneable runtime-specific blueprints for running loops.
- Claude starter · Claude Code starter layout for loop projects.
starters/pr-babysitter - Codex starter · Codex starter layout for loop projects.
starters/ci-sweeper - Grok starter · Grok starter layout for loop projects.
starters/issue-triage - Opencode starter · Opencode starter layout for loop projects.
starters/minimal-loop-opencode - Minimal loop · Minimal loop variant for lightweight setups.
starters/minimal-loop
Shared assets
Reusable templates, skills, and workflow fragments consumed by starters and tools.
- Templates · Reusable markdown templates for state, constraints, and skills.
templates - Shared skills · Common skills reused across generated loops and starters.
skills - Issue bodies · Canonical issue and PR body fragments used by automation.
scripts/issue-bodies
Tools & services
Executable CLIs and MCP service boundaries.
- loop-init · Seeds a target project with loop files and starter assets.
tools/loop-init - loop-audit · Scores loop readiness and flags missing components.
tools/loop-audit - loop-cost · Estimates token and cadence cost for a loop.
tools/loop-cost - loop-sync · Detects drift between loop instructions and durable state.
tools/loop-sync - MCP server · Exposes pattern, skill, and state lookup over MCP.
tools/mcp-server
Examples & evidence
Runtime mappings, integrations, stories, and validation fixtures.
- Runtime examples · Examples showing how patterns map onto different agent runtimes.
examples/README.md - MCP examples · Read-only and safe-write connector examples for external systems.
examples/mcp/README.md - Stories · Narrative evidence of successes, failures, and architectural tradeoffs.
stories/README.md
Connections 33
- README → Pattern catalog: introduces · The top-level README points to the pattern catalog as the core domain model.
- README → Docs site: documents · Repository documentation is also served as a static site.
- LOOP → STATE: pairs with · The loop contract and durable state define the operational boundary.
- Docs site → Pattern catalog: explains · Docs describe how to select and operate patterns.
- Docs site → Templates: references · Conceptual docs reference shared templates and primitives.
- Pattern catalog → Registry: indexed by · Pattern prose is mirrored in a machine-readable registry.
- Registry → Schema: validated by · The registry is checked against the schema.
- Pattern catalog → Claude starter: materialized in · Patterns are instantiated into runtime-specific starters.
- Pattern catalog → Codex starter: materialized in · Patterns are instantiated into runtime-specific starters.
- Pattern catalog → Grok starter: materialized in · Patterns are instantiated into runtime-specific starters.
- Pattern catalog → Opencode starter: materialized in · Patterns are instantiated into runtime-specific starters.
- Pattern catalog → Minimal loop: materialized in · Patterns are instantiated into a minimal starter variant.
- Templates → Claude starter: feeds · Starter repos copy shared templates into concrete layouts.
- Shared skills → Claude starter: feeds · Starter repos include shared and runtime-specific skills.
- Issue bodies → Workflows: supports · Workflow automation uses canonical issue and PR body fragments.
- loop-init → Templates: generates · Scaffolding uses templates to create loop files.
- loop-init → Shared skills: installs · Scaffolding installs the appropriate skills bundle.
- loop-audit → Registry: checks · Audit tooling consumes the registry to score readiness.
- loop-sync → STATE: reads · Sync compares live instructions against durable state.
- loop-sync → LOOP: compares · Sync detects drift between the loop contract and current state.
- MCP server → Pattern catalog: serves · The MCP service exposes pattern lookup.
- MCP server → Shared skills: serves · The MCP service exposes skill lookup.
- MCP server → STATE: serves · The MCP service exposes state lookup.
- Runtime examples → Claude starter: shows · Examples demonstrate the Claude runtime mapping.
- Runtime examples → Codex starter: shows · Examples demonstrate the Codex runtime mapping.
- Runtime examples → Grok starter: shows · Examples demonstrate the Grok runtime mapping.
- Runtime examples → Opencode starter: shows · Examples demonstrate the Opencode runtime mapping.
- MCP examples → MCP server: integrates · MCP examples demonstrate the lookup and connector boundary.
- Stories → Pattern catalog: evidence for · Stories provide real-world validation and failure cases for patterns.
- Workflows → Registry: validates · CI validates the registry and pattern definitions.
- Workflows → loop-audit: runs · Release and audit workflows execute the audit tooling.
- Scripts → Registry: checks · Repository scripts validate the registry before release.
- Scripts → Workflows: supports · Scripts provide CI and release plumbing for workflows.