Deterministic Iterative Agent Loop
A Rust library and CLI for autonomous AI-assisted software development. Persistent memory. Failure pattern detection. Structured task execution. Build entire projects iteratively without losing context or repeating mistakes.
Quick Start · Project Wizard · Why Specs Matter · Templates · Manual Workflow · Library · CLI Reference · AI Integration
The Problem
When you use AI coding assistants (Claude Code, Codex, Gemini, GitHub Copilot, Cursor) to build software iteratively, they hit predictable failure modes:
- Context window exhaustion - conversation history grows until the AI loses track of what it already built
- Reasoning loss between loops - decisions made 10 iterations ago are forgotten
- Duplicate implementation - the AI rewrites code that already exists
- Placeholder code - incomplete implementations with TODO comments
- Cascading failures - one error triggers increasingly desperate "fixes" that break more things
- Specification drift - the implementation diverges from requirements as the AI stops referencing them
DIAL solves these by externalizing memory to SQLite, linking tasks to specifications, detecting failure patterns automatically, building a trust-scored solution database, and enforcing one-task-at-a-time discipline.
Architecture
DIAL is structured as a Rust workspace with three crates:
dial/
├── dial-core/ # Library crate — Engine, events, providers, persistence
├── dial-cli/ # Binary crate — CLI interface
└── dial-providers/ # Provider implementations (Claude, Codex, etc.)
The core library (dial-core) is embeddable — you can build custom tools, dashboards, or CI integrations on top of it. The CLI is one consumer of the library.
The Loop
dial iterate
|
Get next task
|
Gather context from DB
(linked spec, related specs,
trusted solutions, learnings)
|
AI implements the task
|
dial validate
/ \
Pass Fail
| |
Git commit Record failure
Next task Detect pattern
Find solutions
Retry (max 3)
Quick Start
Install
Pre-built binaries (no Rust required):
# macOS (Apple Silicon)
|
# macOS (Intel)
|
# Linux (x86_64)
|
# Linux (ARM64)
|
Windows: Download dial-x86_64-pc-windows-msvc.zip from the latest release, extract, and add to your PATH.
Via Cargo (requires Rust 1.70+):
From source:
The binary is fully self-contained with no runtime dependencies.
Project Wizard
The fastest way to start a project. One command walks you from zero to autonomous iteration through 9 AI-guided phases:
The wizard can run through codex, claude, copilot, gemini, or an OpenAI-compatible API. If DIAL can detect the current agent session, it uses that backend automatically. Otherwise, pass one explicitly:
| Phase | Name | What Happens |
|---|---|---|
| 1 | Vision | AI identifies the problem, target users, success criteria |
| 2 | Functionality | AI defines MVP features, deferred features, user workflows |
| 3 | Technical | AI covers architecture, data model, integrations, constraints |
| 4 | Gap Analysis | AI reviews everything for gaps, contradictions, missing details |
| 5 | Generate | AI produces structured PRD sections, terminology, and initial tasks |
| 6 | Task Review | AI reorders tasks by implementation sequence, adds dependencies, removes redundancy |
| 7 | Build & Test | AI suggests build/test commands and validation pipeline based on tech stack |
| 8 | Iteration Mode | AI recommends how to run: autonomous, review every N tasks, or review each |
| 9 | Launch | Prints summary of everything configured, ready for dial auto-run |
After the wizard completes, start building:
Supported auto-run CLIs are claude, codex, copilot, and gemini.
Pause & Resume
Close the terminal at any phase. Pick up where you left off:
State is persisted in prd.db after every phase — nothing is lost.
Refine an Existing Document
Have an existing PRD, spec, or architecture doc? Feed it through the wizard:
The AI extracts information from your document alongside each phase's questions.
Iteration Modes
Phase 8 configures how auto-run behaves:
| Mode | Config Value | Behavior |
|---|---|---|
| Autonomous | autonomous |
Run all tasks, commit on pass, no stops |
| Review every N | review_every:N |
Pause for review after every N completed tasks |
| Review each | review_each |
Pause after every task for approval |
When paused, resume with dial approve or stop with dial reject.
Templates
Templates define the section structure the AI follows when generating your PRD. Pick the one that matches what you're building:
spec — General Product Requirements
Best for: products with clear functional requirements and acceptance criteria.
Problem Statement → Requirements (Functional, Non-Functional) → Features → Data Model → Constraints → Acceptance Criteria
architecture — System Architecture
Best for: system design documents, multi-service architectures, infrastructure planning.
Overview → Components (Interactions) → Data Model → Integrations → Deployment → Security
api — API Specification
Best for: REST/GraphQL APIs, microservices, developer-facing products.
Overview → Authentication → Endpoints (Resources, Actions) → Data Types → Error Handling
mvp — Minimum Viable Product
Best for: quick prototypes, hackathons, getting something working fast.
Problem → MVP Features → Technical Stack → Data Model
The template determines what sections the AI generates in phase 5 and what structure tasks are linked to. You can always add more sections manually after the wizard completes.
Why Specs Matter
Without a spec, DIAL assembles context from learnings, solutions, and failures — useful, but the AI has no requirements to validate against. With a spec:
- Each task carries what to build alongside how previous attempts went
- FTS search surfaces relevant requirements even for unlinked tasks
- Specification drift is prevented because the AI re-reads requirements every iteration
This is the key difference between DIAL and running an AI assistant in a loop. The spec is externalized memory — it ensures the AI re-reads requirements at every iteration instead of relying on conversation history that degrades over time.
Manual Workflow
If you prefer to control each step yourself instead of using dial new:
# 1. Initialize
# 2. Import or create a spec
# 3. Add tasks
# 4. Run
# or
dial spec wizard runs phases 1-5 only (PRD generation). Use dial new for the full 9-phase flow.
Querying the PRD
Library Usage
Add dial-core to your Cargo.toml:
[]
= "4.2"
= { = "1", = ["full"] }
Basic Example
use ;
use Arc;
;
async
See dial-core/examples/ for more: custom providers, event handlers, and validation pipelines.
Features
Task Management
Specification & PRD
Configurable Validation Pipeline
Steps run in order. Required steps abort on failure. Optional steps log and continue.
Approval Gates
Failure Pattern Detection
DIAL categorizes build/test errors into 21 patterns across 5 categories (import, syntax, runtime, test, build). When a failure recurs, DIAL surfaces previously successful solutions.
Trust-Scored Solutions
Solutions start at 0.3 confidence. Success adds +0.15; failure subtracts -0.20. Solutions at 0.6+ are "trusted" and automatically included in context.
Metrics & Trends
Project Health Score
Six weighted factors: success rate, success trend, solution confidence, blocked task ratio, learning utilization, and pattern resolution rate. Trend detection compares current score vs 7 days ago.
Dry Run / Preview Mode
Shows context items included/excluded with token sizes, prompt preview, suggested solutions, and dependency status — without creating iteration records or spawning subagents.
Cross-Iteration Failure Tracking
Tasks track total_attempts and total_failures across all iterations. Auto-run auto-blocks tasks exceeding max_total_failures (default: 10).
Per-Pattern Metrics
Checkpoint System
Automatic git stash-based checkpoints before task execution. On validation failure, the working tree is restored to pre-task state before retry. Controlled via enable_checkpoints config (default: true).
Structured Subagent Signals
Subagents write .dial/signal.json with typed signals (Complete, Blocked, Learning) instead of printing DIAL_ lines to stdout. Falls back to regex parsing for backward compatibility.
Transaction Safety
All multi-step database mutations (record_failure, task_done, iterate, prd_import) are wrapped in BEGIN IMMEDIATE transactions with automatic rollback on error.
Crash Recovery
Project Learnings
Learnings are auto-linked to failure patterns when recorded during an iteration with failures.
Project Structure
your-project/
├── .dial/
│ ├── mvp.db # Engine state (tasks, iterations, failures, solutions)
│ ├── prd.db # PRD database (sections, terminology, wizard state)
│ ├── current_phase # Active phase name
│ ├── current_context.md # Latest context (auto-generated)
│ └── subagent_prompt.md # Latest sub-agent prompt (auto-generated)
├── specs/ # Original source documents (stay intact)
│ └── PRD.md
└── ... your project files
Performance
| Metric | Value |
|---|---|
| Startup time | ~14ms |
| Binary size | ~4MB |
| Dependencies | None (static binary) |
| Database | SQLite with WAL mode + FTS5 |
License
MIT OR Apache-2.0 — see LICENSE-MIT and LICENSE-APACHE.