the night shift for your backlog
lazycode is an open-source coding agent that plans with a realtime model and executes on provider batch APIs โ half the price, 24-hour SLA. Not a pair programmer: point it at the work that can wait until dawn, close your laptop, review branches over coffee.
// architecture
Chat agents burn tokens round-tripping one message at a time. lazycode treats your goal like a database treats SQL: build a logical plan, run it through an optimizer, compile a physical plan, then execute it in parallel waves on the batch API.
A realtime model reads your repo map and decomposes the goal into a DAG of typed operators โ Explore, Generate, Edit, Verify, Judge, Reduce. You approve it before a cent is spent on execution.
Rule-based rewrites, straight out of a query optimizer: push work to local tools, prune context per node, factor shared prompt prefixes for cache hits, widen independent fan-out.
Every node whose dependencies are met ships in one batch submission. One wave can carry fifty file edits. The daemon persists everything, then waits โ most batches finish in under an hour.
Results are harvested into git worktree sandboxes, diffs applied with three-way merge, your test command run per group. You get branches, a report, and an assumption ledger โ not a wall of chat.
independent nodes ride the same wave โ one batch call, fifty files
// economics
Batch APIs are 50% off list price. Most tools would stop there. We don't โ because realtime agents get prompt-cache discounts on input that batch mostly gives up. Here is where the savings actually come from.
Every token the model writes overnight costs half. No caveats. For generation-heavy work โ new tests, migrations, mass refactors โ this is the bulk of the bill.
A chat agent re-reads the conversation every turn; caching makes that cheap (0.1ร on cache hits). lazycode wins on input differently โ it collapses thirty chatty turns into a few wide waves, so the context is simply read far fewer times. Fewer rounds beats cheaper re-reads.
Batch providers don't care if a wave carries one request or a thousand. The optimizer widens fan-out aggressively because breadth is free โ only depth costs wall-clock time.
// durability
An agent that runs while you sleep has one non-negotiable job: never lose work, never pay twice. Every guarantee below is enforced by the test suite, including a kill -9 โ resume end-to-end test.
Every state change is an event in SQLite; job state is a replayable projection. Crash at any instant โ plan approved, wave in flight, results half-processed โ and lazycode resume reconstructs exactly where it was.
Submissions carry content-derived idempotency keys, stamped into the provider's batch metadata. If the process dies between paying and recording, reconciliation finds the orphaned batch and adopts it instead of re-submitting.
A daemon holds a heartbeated per-job lease as the sole database writer; CLI and UI are read-only clients over HTTP. No second process can double-submit your job โ not even you, accidentally, from another terminal.
The daemon keeps your machine from sleeping (it asks first). Results land in git worktree sandboxes, diffs apply with three-way merge and an applied-diff ledger โ your working tree is never touched.
// quickstart
Python 3.12+, a git repo with at least one commit, and an Anthropic API key. Or try the built-in mock provider first โ zero network, zero spend.
# install git clone https://github.com/rajagurunath/lazycode && cd lazycode uv sync # hand over the backlog cd /path/to/your-repo export ANTHROPIC_API_KEY=sk-ant-... uv run lazycode run "add type hints to services/" --verify "pytest -q" # approve the plan, close the laptop. in the morning: uv run lazycode review jb_7f3a
| lazycode run | Plan with a realtime model, approve, execute in batch waves |
| lazycode status | Per-node progress: what's queued, in flight, landed, failed |
| lazycode explain | Logical and physical plan trees โ Spark-style, for your code |
| lazycode review | Branches, verification results, and the assumption ledger |
| lazycode resume | Pick an interrupted job back up after a crash or reboot |
| lazycode daemon | Single-writer orchestrator that owns jobs and stays awake |
Plan โ waves โ verified branches. Crash-safe resume, idempotent submits, daemon, benchmark harness.
Repair loop: failed verify feeds back into a fix wave instead of stopping. Typed contracts, merge/cancel.
Cost estimates in the plan preview, explain analyze, hedging and deadline-aware realtime fallback.
Web UI for plan DAGs, rolling wave flush, OpenAI & Gemini batch adapters, webhook-first completion.