Skip to main content

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.

PyPI License: MIT Python 3.10+

Darkzloop is a terminal-based agent runner that turns any LLM into a rigorous software engineer. Unlike flaky chat agents, Darkzloop uses a Finite State Machine, Circuit Breakers, and Manifest Protocols 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:

  • ๐Ÿ” Detect your project type (Rust/Python/Node/Go)
  • ๐Ÿ›ก๏ธ Create a safety backup branch
  • ๐Ÿ”„ Plan, Execute, and Test the fix using your project's own test suite

Optional: Verify Setup

darkzloop doctor
# โœ“ Backend: claude
# โœ“ Project: Python
#   Tier 1: ['ruff check .']
#   Tier 2: ['pytest -x']

๐Ÿ›ก๏ธ 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
Manifest Protocol Agent edits files blindly Read-Before-Write: Writes blocked unless file is in context
Circuit Breakers Agent tries the same wrong fix 10ร— Task Limits: Hard stop after 3 failed attempts per task
Tiered Gates Agent breaks the build Quality Control: Tests must pass before loop completes
Semantic Expansion "Fix billing" misses src/invoice.rs Synonyms: Auto-expands intent to find relevant files
Git Safety Agent overwrites uncommitted work Backup Branches: Auto-creates restore points before execution

๐Ÿง  Supported Backends

Darkzloop works with any tool that accepts text via stdin.

Backend Best For Setup
Claude CLI Complex refactors, high reasoning darkzloop config native claude
Ollama Privacy, offline, free darkzloop config native ollama
GitHub Copilot Quick fixes with Enterprise license darkzloop config native gh-copilot
llm CLI Universal adapter (50+ providers) darkzloop config native llm
Direct API Full control, streaming darkzloop config api anthropic

๐Ÿ› ๏ธ Usage Examples

Quick Fix

darkzloop "Login button not responding on mobile"

With Backend Override

darkzloop "Add rate limiting" --backend ollama

Skip Safety Prompts (CI/CD)

darkzloop "Fix lint errors" --unattended

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 Loop methodology with industrial-grade hardening:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    DARKZLOOP CONTROL PLANE                   โ”‚
โ”‚                                                              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”               โ”‚
โ”‚  โ”‚   FSM    โ”‚โ”€โ”€โ”€โ–ถโ”‚ Manifest โ”‚โ”€โ”€โ”€โ–ถโ”‚  Gates   โ”‚               โ”‚
โ”‚  โ”‚  Engine  โ”‚    โ”‚ Protocol โ”‚    โ”‚ (Tests)  โ”‚               โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜               โ”‚
โ”‚        โ”‚              โ”‚               โ”‚                      โ”‚
โ”‚        โ–ผ              โ–ผ               โ–ผ                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                โ”‚
โ”‚  โ”‚         Semantic Expansion Layer         โ”‚                โ”‚
โ”‚  โ”‚   (Synonyms, Learning Glossary, Search)  โ”‚                โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
                         โ–ผ
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚   Executor Layer    โ”‚
              โ”‚  (Model-Agnostic)   โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ                โ–ผ                โ–ผ
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚ Claude  โ”‚     โ”‚  Ollama  โ”‚     โ”‚   API   โ”‚
   โ”‚  CLI    โ”‚     โ”‚ (Local)  โ”‚     โ”‚ (SDK)   โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Finite State Machine

The FSM enforces strict state transitionsโ€”no "hallucinated" jumps:

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚                                     โ”‚
                    โ–ผ                                     โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚
โ”‚ IDLE โ”‚โ”€โ”€โ”€โ–ถโ”‚ PLANNING  โ”‚โ”€โ”€โ”€โ–ถโ”‚ EXECUTING โ”‚โ”€โ”€โ”€โ–ถโ”‚ TESTING โ”‚โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜โ”‚
                                                   โ”‚     โ”‚
                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚     โ”‚
                              โ”‚             โ”‚      โ”‚     โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค REMEDIATING โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚
                    โ”‚         โ”‚             โ”‚ (tests     โ”‚
                    โ”‚         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  failed)   โ”‚
                    โ”‚               โ”‚                    โ”‚
                    โ”‚               โ”‚ (fix applied)      โ”‚
                    โ”‚               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚
                    โ”‚ (max retries exceeded)
                    โ–ผ
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚ BLOCKED โ”‚         โ”‚ DONE โ”‚โ—€โ”€โ”€ (tests passed)
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
State Description Exit Condition
IDLE Waiting for task Plan approved
PLANNING Agent generates plan Plan validated
EXECUTING Agent works on current task Task complete
TESTING Running tiered gates Pass โ†’ DONE, Fail โ†’ REMEDIATING
REMEDIATING Self-healing after test failure (max 3 retries per task) Fix applied โ†’ TESTING
BLOCKED Circuit breaker tripped Human intervention required
DONE All tasks complete, all gates passed โ€”

Key Components

  • FSM Engine: 7-state machine with strict transitionsโ€”no skipping states
  • Manifest Protocol: Tracks every file read/write, enforces read-before-write, user must approve sensitive file additions
  • Circuit Breakers: Max iterations (100), consecutive failures (3), per-task retries (3)
  • Semantic Layer: Expands search terms using local synonym matching + learning glossary (no external API calls, no data leaves your machine)
  • Executor Interface: Pluggable backends via stdin/stdout protocol

The Manifest Protocol (Read-Before-Write)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      MANIFEST RULES                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โœ“ Agent wants to READ src/api/users.rs                     โ”‚
โ”‚    โ†’ Allowed (adds to manifest automatically)               โ”‚
โ”‚                                                              โ”‚
โ”‚  โœ— Agent wants to WRITE src/api/users.rs (not in manifest)  โ”‚
โ”‚    โ†’ BLOCKED: "Must read file before modifying"             โ”‚
โ”‚                                                              โ”‚
โ”‚  โš  Agent wants to READ config/secrets.json                  โ”‚
โ”‚    โ†’ PROMPT: "Add sensitive file to manifest? [y/N]"        โ”‚
โ”‚                                                              โ”‚
โ”‚  โœ“ Agent wants to WRITE src/api/users.rs (in manifest)      โ”‚
โ”‚    โ†’ Allowed (file was previously read)                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

This prevents the #1 agent failure mode: blindly overwriting files it hasn't seen.

Semantic Expansion

When you say darkzloop fix "billing issue", the semantic layer expands your intent:

Input:  "billing"
        โ†“
Synonyms: ["invoice", "payment", "charge", "subscription", "price"]
        โ†“
Learned: ["stripe", "checkout"] (from project glossary)
        โ†“
Search:  Finds src/billing.rs, src/invoice.rs, src/stripe/webhook.rs

Implementation: Local dictionary + project-specific learning glossary stored in .darkzloop/glossary.json. No embeddings, no external callsโ€”fast and private.


๐Ÿ”ง Configuration

Zero config by default. Darkzloop auto-detects everything.

Optional overrides via environment:

DARKZLOOP_BACKEND=ollama     # Use Ollama instead of Claude
DARKZLOOP_MAX_ITER=5         # Limit iterations

๐Ÿ“Š Commands

Command Description
darkzloop "task" Run a fix or feature (main usage)
darkzloop "task" --backend ollama Override LLM backend
darkzloop "task" --unattended Skip safety prompts (for CI)
darkzloop doctor Verify environment and configuration

๐Ÿšจ Safety Features

Darkzloop is designed to never lose your work:

  1. Git Clean Check: Warns before running with uncommitted changes
  2. Backup Branches: Creates darkzloop-backup-YYYYMMDD-HHMMSS before execution
  3. Dry Run Mode: --dry-run shows what would happen without executing
  4. Attended Mode: Requires approval at each major step
  5. Read-Before-Write: Cannot modify files not explicitly loaded into context
  6. Sensitive File Prompts: Asks permission before reading config/secrets

๐ŸŽฏ Philosophy

"The goal is not to build a smarter agent. It's to build a more disciplined one."

Darkzloop is based on the Ralph Loop methodology:

  1. Spec: Define what you want (the "Pin")
  2. Plan: Break it into tasks with dependencies (DAG)
  3. Execute: Let the agent work within strict boundaries
  4. Verify: Run tests before accepting any change
  5. Learn: Build project-specific vocabulary over time

The agent is powerful. The system keeps it honest.


๐Ÿค Contributing

See CONTRIBUTING.md for guidelines.

git clone https://github.com/yourusername/darkzloop
cd darkzloop
pip install -e ".[dev]"
pytest

๐Ÿ“„ 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

darkzloop-0.7.2.tar.gz (99.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

darkzloop-0.7.2-py3-none-any.whl (102.8 kB view details)

Uploaded Python 3

File details

Details for the file darkzloop-0.7.2.tar.gz.

File metadata

  • Download URL: darkzloop-0.7.2.tar.gz
  • Upload date:
  • Size: 99.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for darkzloop-0.7.2.tar.gz
Algorithm Hash digest
SHA256 5b92a2445effae3d50334f8e02faa36c52b6d49af0cc146fa62a29f787149612
MD5 5ea7e3c5dcdd24898b9a8bc64a1d83d4
BLAKE2b-256 a03a7f1749e5aeadb6d35211f24ecbe99e34937b525cabbe84c3e5e94ff0a347

See more details on using hashes here.

File details

Details for the file darkzloop-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: darkzloop-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 102.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for darkzloop-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bff572a8936075e48f2ec5e15e2e15017921208a7cba69e66246b6c821630ee4
MD5 57af9ab6ef41bfe6e5a155a90982718b
BLAKE2b-256 3285dec2529fa9f3d6201a02a0d8d2237bd9161f9830a09d8f327be9d1291431

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page