ouro-loop
Ouro Loop allows artificial intelligence to write and improve code on its own, working continuously without needing constant human oversight. It addresses the challenge of AI coding tools sometimes making mistakes or unintentionally damaging important parts of a project. This framework is ideal for businesses that want to automate tasks like large-scale code refactoring or overnight builds, especially when certain files or systems require strict protection. What makes Ouro Loop unique is its focus on setting clear boundaries and rules for the AI, ensuring it stays within safe limits and can automatically correct its own errors instead of asking for help. It provides a structured and auditable way to let AI handle complex coding tasks with greater reliability.
README
# Ouro Loop

> **"To grant an entity absolute autonomy, you must first bind it with absolute constraints."**
[](https://opensource.org/licenses/MIT)
[](https://pypi.org/project/ouro-loop/)
[](https://www.python.org/downloads/)
[](https://github.com/VictorVVedtion/ouro-loop/actions/workflows/test.yml)
[]()
[]()
## What is Ouro Loop?
**Ouro Loop** is an open-source framework that gives AI coding agents (Claude Code, Cursor, Aider, Codex) a structured autonomous loop with runtime-enforced guardrails. It implements **bounded autonomy** — the developer defines absolute constraints (DANGER ZONES, NEVER DO rules, IRON LAWS) using the BOUND system, then the agent loops autonomously through Build → Verify → Self-Fix cycles. When verification fails, the agent doesn't ask for help — it consults its remediation playbook, reverts, tries a different approach, and reports what it did. Constraints are enforced at the runtime level through Claude Code Hooks (exit 2 hard-block), not by relying on the agent's "good behavior." Inspired by Karpathy's [autoresearch](https://github.com/karpathy/autoresearch), extended from ML to general software engineering. Zero dependencies, pure Python 3.10+.
| | |
|---|---|
| **What it does** | Let AI agents code overnight without breaking things |
| **How it works** | Define boundaries (BOUND) → AI loops: Build → Verify → Self-Fix |
| **What you get** | `program.md` (method) + `framework.py` (runtime) + `sentinel.py` (24/7 review) + 5 hooks (enforcement) |
| **Requirements** | Python 3.10+, Git, any AI agent. Zero dependencies. `pip install ouro-loop` |
### Is Ouro Loop for you?
**This is for you if:**
- You want to let an AI agent run autonomously for hours (overnight builds, long refactors)
- Your project has files that must never be touched without review (payments, auth, consensus)
- You've experienced AI agents hallucinating paths, breaking constraints, or getting stuck in loops
- You want auditable, structured autonomous development — not "vibe and pray"
**This is NOT for you if:**
- You're building a quick prototype or hackathon project (BOUND setup overhead isn't worth it)
- You're writing single-file scripts (the methodology overhead exceeds the benefit)
- You want real-time interactive coding (Ouro Loop is designed for "set it and let it run")
### The Problem with Unbound AI Agents
In the era of "vibe coding," unbound AI agents hallucinate file paths, break production constraints, regress architectural patterns, and get stuck in infinite fix-break loops. The current solution — pausing to ask humans — negates the promise of autonomous coding.
### The Solution: Bounded Autonomy
Ouro Loop formally introduces **The Event Horizon**: the developer establishes absolute constraints (Iron Laws, Danger Zones). The AI Agent is granted full autonomy to continuously build, verify, and self-correct within that boundary — never crossing into catastrophic failure. When something breaks inside the boundary, the agent **doesn't ask for help** — it consults its remediation playbook, reverts, tries a different approach, and reports what it did.
---
## How It Works
The repo is deliberately kept small. Only three files matter:
- **`program.md`** — the methodology instructions. Defines the six-stage loop (BOUND, MAP, PLAN, BUILD, VERIFY, LOOP) and the autonomous remediation rules. Point your agent here and let it go. **This file is iterated on by the human**.
- **`framework.py`** — lightweight runtime for state tracking, verification gates, and logging. The agent uses this CLI to check its own work. **This file can be extended by the agent**.
- **`prepare.py`** — project scanning and initialization. Creates the `.ouro/` state directory. Not modified.
```mermaid
graph TD
classDef default fill:#1e1e1e,stroke:#4a4a4a,stroke-width:1px,color:#d4d4d4;
classDef highlight fill:#2d3748,stroke:#63b3ed,stroke-width:2px,color:#fff;
classDef boundary fill:#4a1c40,stroke:#fc8181,stroke-width:2px,color:#fff;
BOUND(("Step 0<br/><b>BOUND</b><br/>(Set Constraints)")):::boundary
MAP["Step 1<br/><b>MAP</b><br/>(Understand)"]
PLAN["Step 2<br/><b>PLAN</b><br/>(Decompose)"]
BUILD["Step 3<br/><b>BUILD</b><br/>(Create)"]
VERIFY{"Step 4<br/><b>VERIFY</b><br/>(Judge)"}
REMEDIATE["<b>REMEDIATE</b><br/>(Autonomous Fix)"]:::highlight
NEXT(("Next<br/>Phase"))
BOUND --> MAP
MAP --> PLAN
PLAN --> BUILD
BUILD --> VERIFY
VERIFY -- "FAIL (inside BOUND)" --> REMEDIATE
REMEDIATE --> BUILD
VERIFY -- "PASS" --> NEXT
NEXT -.-> BUILD
```
When verification fails, the agent does *not* ask for human help. It consults `modules/remediation.md`, decides on a fix, reverts/retries, and loops — so long as it hasn't breached the outer edge of the BOUND. Read [The Manifesto](MANIFESTO.md) for the deep-dive on Precision Autonomy.
---
## Quick Start
**Requirements:** Python 3.10+, Git, any AI coding agent.
### 1. Install Ouro Loop
**Option A — pip (recommended):**
```bash
pip install ouro-loop
```
**Option B — clone:**
```bash
git clone https://github.com/VictorVVedtion/ouro-loop.git ~/.ouro-loop
```
### 2. Scan your project
```bash
cd /path/to/your/project
# If installed via pip:
python -m prepare scan .
# If cloned:
python ~/.ouro-loop/prepare.py scan .
```
This shows you what Ouro Loop sees:
```
============================================================
Ouro Loop — Project Scan
============================================================
Project: my-payment-service
Types: Python
Files: 42 Lines: 3,200
Languages:
Python 35 files ###############
SQL 7 files #######
CLAUDE.md: Not found
BOUND: Not defined
Tests: Found
CI: Found
Recommendations:
1. Define BOUND (DANGER ZONES, NEVER DO, IRON LAWS) before building
2. Create CLAUDE.md with BOUND section
============================================================
```
### 3. Initialize and draw the boundaries
```bash
# If installed via pip:
python -m prepare init . # Creates .ouro/ state directory
python -m prepare template claude . # Generates CLAUDE.md template
# If cloned:
python ~/.ouro-loop/prepare.py init .
python ~/.ouro-loop/prepare.py template claude .
```
Edit `CLAUDE.md` to define your project's actual boundaries. Here's what a real BOUND looks like:
```markdown
## BOUND
### DANGER ZONES
- `src/payments/calculator.py` — financial calculations, penny-level precision
- `migrations/` — database schema, irreversible in production
### NEVER DO
- Never use float for monetary values — always Decimal
- Never delete or rename migration files
- Never commit without running the test suite
### IRON LAWS
- All monetary values use Decimal with 2-digit precision
- All API responses include request_id field
- Test coverage for payment module never drops below 90%
```
See `examples/` for complete BOUND definitions and **real session logs** showing the methodology in action:
- [**Blockchain L1**](examples/blockchain-l1/) — BOUND for consensus/p2p, plus a [real session log](examples/blockchain-l1/session-log.md) where the agent tested 5 hypotheses, autonomously remediated 4 failures, and found a root cause that was architectural (HTTP routing), not code-level.
- [**Consumer Product**](examples/consumer-product/) — BOUND for audio/sync, plus a [real session log](examples/consumer-product/session-log.md) where
[truncated…]PUBLIC HISTORY
IDENTITY
Identity inferred from code signals. No PROVENANCE.yml found.
Is this yours? Claim it →METADATA
README BADGE
Add to your README:
