Reliable. Autonomous. Model-Agnostic. Turn any LLM into a disciplined software engineer.
Project description
โพ๏ธ Darkzloop
Reliable. Autonomous. Model-Agnostic.
Stop hand-carrying cargo. Operate the locomotive.
๐ About
Darkzloop is a terminal-based agent runner that transforms any Large Language Model into a disciplined, autonomous software engineer. Instead of building a smarter agent, Darkzloop builds a more disciplined oneโwrapping model outputs in a rigorous control system that prevents hallucinations, drift, and infinite loops.
Core Architecture:
- ๐ 7-State FSM โ Enforced transitions through Plan โ Execute โ Observe โ Critique โ Checkpoint
- ๐ง Context Grounding โ Agent receives Mermaid diagrams of its own control flow every iteration
- โก Circuit Breakers โ Hard stop after 3 consecutive failures; no spiral of bad fixes
- ๐ Auto-Detection โ Scans for Rust/Python/Node/Go and runs appropriate quality gates
- ๐ BYOA (Bring Your Own Auth) โ Uses your existing CLI tools; no API keys required
Darkzloop is a terminal-based agent runner that turns any LLM into a rigorous software engineer. Built on the Ralph Wiggum Loop methodology, it uses a Finite State Machine, Mermaid context diagrams, and Circuit Breakers to prevent hallucinations and infinite loops.
๐ฅ The Killer Feature: Bring Your Own Auth (BYOA)
Darkzloop doesn't need your API keys. It pipes context directly to the tools you're already logged into:
Claude CLI โข GitHub Copilot โข Ollama โข llm CLI โข Aider
โก Quick Start
1. Install
pip install darkzloop
2. Run
Navigate to your project and describe the task. Darkzloop auto-detects your stack.
darkzloop "Fix the retry logic in the webhook handler"
That's it. Darkzloop will:
- ๏ฟฝ Darkz Loop through Plan โ Execute โ Observe โ Critique โ Checkpoint
- ๐ Auto-detect your project type (Rust/Python/Node/Go)
- ๐ก๏ธ Create a safety backup branch
- โก Show animated spinner while working
๐ก [EXECUTING] iter=1 fails=0
โ ด ๐ Darkz Looping...
Optional: Verify Setup
darkzloop doctor
# โ Backend: claude
# โ Project: Python
# Tier 1: ['ruff check .']
# Tier 2: ['pytest -x']
โก Batch Processing (Parallel Workers)
Process multiple files concurrently with the new batch command:
# Process entire folder with 4 parallel workers
darkzloop batch ./src --workers 4 --task "Fix security vulnerabilities"
โก Batch Processing: 51 files with 4 workers
Processing... โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 100%
Results:
โ Success: 51
โ Failed: 0
Batch Options
| Option | Description |
|---|---|
--workers N |
Number of parallel Ralph workers (default: 4) |
--task "..." |
Task to apply to each file |
--backend X |
Override LLM backend |
๐ก๏ธ Why Darkzloop?
Most AI agents are just "loops in a while(true) block." They drift, hallucinate, and overwrite good code. Darkzloop is different:
| Feature | The Problem | The Darkzloop Solution |
|---|---|---|
| Ralph Loop | Agent runs aimlessly | FSM-controlled PlanโExecuteโObserveโCritiqueโCheckpoint |
| Circuit Breakers | Agent tries the same wrong fix 10ร | Task Limits: Hard stop after 3 failed attempts |
| Tiered Gates | Agent breaks the build | Quality Control: Tests must pass before loop completes |
| Stdin Delivery | Shell escaping mangles prompts | Direct stdin: Complex prompts with Mermaid diagrams work perfectly |
| Git Safety | Agent overwrites uncommitted work | Backup Branches: Auto-creates restore points |
๐ง Supported Backends
Darkzloop works with any tool that accepts text via stdin.
| Backend | Best For | Auto-Detected |
|---|---|---|
| Claude CLI | Complex refactors, high reasoning | โ |
| Ollama | Privacy, offline, free | โ |
| GitHub Copilot | Quick fixes with Enterprise license | โ |
| llm CLI | Universal adapter (50+ providers) | โ |
๐ ๏ธ Usage Examples
Quick Fix
darkzloop "Login button not responding on mobile"
With Backend Override
darkzloop "Add rate limiting" --backend ollama
Skip Safety Prompts + Quality Gates (CI/CD)
darkzloop "Fix lint errors" --unattended --no-gates
Batch Process Directory
darkzloop batch ./vulnerable-code --workers 8 --task "Fix SQL injection"
Check Environment
darkzloop doctor
Auto-detected quality gates by stack:
- Rust:
cargo checkโcargo test - Python:
ruff check .โpytest -x - Node:
npm run lintโnpm test - Go:
go build ./...โgo test ./...
๐ฆ Architecture
Darkzloop implements the Ralph Wiggum Loop methodology with industrial-grade hardening:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DARKZLOOP CONTROL PLANE โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ FSM โโโโโถโ Mermaid โโโโโถโ Gates โ โ
โ โ Engine โ โ Context โ โ (Tests) โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ โ โ โ
โ โผ โผ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Stdin Prompt Delivery โ โ
โ โ (Bypasses shell escaping entirely) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Executor Layer โ
โ (Model-Agnostic) โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโ
โ Claude โ โ Ollama โ โ API โ
โ CLI โ โ (Local) โ โ (SDK) โ
โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโ
The Ralph Loop FSM
The FSM enforces strict state transitionsโno "hallucinated" jumps:
graph LR
INIT --> PLAN
PLAN --> EXECUTE
EXECUTE --> OBSERVE
OBSERVE --> CRITIQUE
CRITIQUE --> CHECKPOINT
CRITIQUE --> TASK_FAILURE
TASK_FAILURE --> PLAN
CHECKPOINT --> COMPLETE
TASK_FAILURE --> BLOCKED
| State | Description | Exit Condition |
|---|---|---|
| PLAN | Agent receives FSM context + Mermaid diagram | Plan ready |
| EXECUTE | Agent works on task (๐ Darkz Looping...) | Changes made |
| OBSERVE | Run quality gates | Pass/Fail |
| CRITIQUE | Evaluate results | Success โ CHECKPOINT |
| CHECKPOINT | Task complete | All done โ COMPLETE |
| TASK_FAILURE | Max 3 retries, then โ BLOCKED | Fix applied โ retry |
Context Reminder (Sent Every Iteration)
Each iteration, the agent receives structured context:
# DARKZLOOP AGENT CONTEXT
FSM: EXECUTE | iter=2 | fails=1 | max_fails=3
## FSM State Diagram
graph LR; PLAN-->EXECUTE; EXECUTE-->OBSERVE...
## Current Task
Fix the SQL injection vulnerability
## Instructions
You are inside a Ralph Wiggum loop. Your changes persist between iterations.
๐ Commands
| Command | Description |
|---|---|
darkzloop "task" |
Run a fix or feature (main usage) |
darkzloop batch path/ |
Process files in parallel |
darkzloop batch path/ --workers 8 |
Control parallelism |
darkzloop "task" --backend ollama |
Override LLM backend |
darkzloop "task" --unattended |
Skip safety prompts (for CI) |
darkzloop "task" --no-gates |
Skip quality gates (for testing) |
darkzloop doctor |
Verify environment and configuration |
๐จ Safety Features
Darkzloop is designed to never lose your work:
- Git Clean Check: Warns before running with uncommitted changes
- Backup Branches: Creates
darkzloop-backup-YYYYMMDD-HHMMSSbefore execution - Circuit Breakers: Max 3 consecutive failures before stopping
- Attended Mode: Requires approval at each major step
- Stdin Delivery: Complex prompts with special characters work perfectly
๐ฏ Philosophy
"The goal is not to build a smarter agent. It's to build a more disciplined one."
Darkzloop is based on the Ralph Wiggum Loop methodology:
- Plan: Receive task + FSM context + Mermaid diagram
- Execute: Let the agent work within strict boundaries
- Observe: Run quality gates (linters, tests)
- Critique: Evaluate results, decide next action
- Checkpoint: Accept changes or retry
The agent is powerful. The system keeps it honest.
๐ง Development
git clone https://github.com/darkzOGx/darkzloop
cd darkzloop
pip install -e ".[dev]"
pytest
Stress Testing
Generate a nightmare test suite:
cd vulnerable-api
python generate_nightmare_suite.py
# Creates 50 files with various vulnerabilities
darkzloop batch nightmare_suite --workers 4
# Processes all files in parallel
๐ License
MIT ยฉ 2025
Stop debugging your debugger. Start shipping.
pip install darkzloop && darkzloop "your bug here"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file darkzloop-0.8.3.tar.gz.
File metadata
- Download URL: darkzloop-0.8.3.tar.gz
- Upload date:
- Size: 102.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba84bb65cfc37bebe6b4e07035fd958884c4ee1d0b56925ed02bdaeeef9f41dd
|
|
| MD5 |
3651c75af37ee6572573298cdf3949ba
|
|
| BLAKE2b-256 |
3fb408d8bd2a5344267296dabf4a6486c44a4ffbb7306a76d2e4b225d7938282
|
File details
Details for the file darkzloop-0.8.3-py3-none-any.whl.
File metadata
- Download URL: darkzloop-0.8.3-py3-none-any.whl
- Upload date:
- Size: 106.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
950f300dd9a5f21c1fb42b58a7d56a74caa8df6cf2e529fb8f693bc17389aa8b
|
|
| MD5 |
f5af9f7b9c6d1d7a817f908128ce55ab
|
|
| BLAKE2b-256 |
b96ca432e27c3615187de4b1685347ded8549b87a4160eec9aee1056fe854ad6
|