lex-code

A coding assistant that proves its work.

lex-code writes Lex and ends every task with a verdict from the type checker and from examples written before the code — not a transcript claiming success. Give it one task, or a brief for a whole package; run it on your own machine with a local model, or overnight, unattended.

curl -fsSL https://raw.githubusercontent.com/alpibrusl/lex-code/main/install.sh | bash

A real, unedited run: the request is plain English, not Lex.

What it does

Verifies, doesn’t narrate

A typed issue is a contract: exact signatures plus the examples that decide whether it holds. The run ends with one machine-readable verdict, whatever the model claims.

Builds whole packages

From a brief: a checked plan, units built in dependency order, generated invariants, the real program started and attacked with the brief’s own requirements, and repair when it fails.

Runs while you sleep

lex-code-overnight resumes across rounds, waits out a provider that goes away, restores the source file after a kill, and writes a report.

Sandboxed by the language

Every session runs under a capability grant enforced by the Lex VM. An effect it was not granted, it cannot perform. --lex-os adds an outer, host-level perimeter.

Local-first, any provider

--ollama runs entirely on your machine, no key. Cloud and OpenAI-compatible servers use the same flags.

Leaves a trail

Each session is a database of events, each issue is in a content-addressed store, and a running build has a read-only live dashboard.

How a package gets built and checked

  1. PlanAn agent drafts a graph of typed issues from your brief. Nothing is filed yet.
  2. Check the planUnbuildable examples, cycles, name collisions and invariants that can never fail are rejected before any code is written.
  3. BuildUnits are built in dependency order. Each is verified against its own examples; a later unit that breaks an earlier one is caught.
  4. HardenInvariants declared in the plan are checked on generated inputs; violations are fixed.
  5. AcceptThe real program is started and the brief’s requirements are replayed against it as requests.
  6. RepairFailures that only exist once the units share a file go back to a model as one task.
  7. ReportVerdict, per-unit attempts and tokens, and what is still wrong.
  8. Stop anywhereEvery stage is a command and a file you can read, edit and resume.

“Verified” is necessary, not sufficient: a unit’s examples are a finite list. That is why a build ends by running the program — and why you should attack the result yourself before exposing it.

Quick start

lex-code --ollama                        # interactive, local, no key
lex-code --ollama "implement list.zip"   # one task, then exit
lex-code --plan --ollama                 # plan only, nothing written

Pick a provider with its flag; --ollama needs no key. See Providers.

lex-code --issue=<id> --ollama   # implement a typed issue
                                 # ends with [ISSUE_VERDICT]

A typed issue is exact signatures plus the examples that decide whether it holds.

Implementing a typed issue: iterate against the type checker and the declared acceptance, then one verdict line.

Whole packages, in stages you can stop at

lex-code --package "a small invoice REST API ..." --name=invoices --ollama   # 1. plan; files nothing
lex-code --package-check=invoices                                             # 2. re-validate after you edit it
lex-code --package-apply=invoices                                             # 3. file the reviewed plan as issues
lex-code --project=invoices --ollama > invoices.log 2>&1 &                    # 4. build, harden, accept, repair
lex-code --dashboard=invoices                                                 #    watch it live (127.0.0.1:7800)

Or all of it, unattended, with a report at the end:

lex-code-overnight --name=invoices --brief-file=brief.txt --ollama
cat .lex/overnight/REPORT.md

If a unit gets stuck you can resume with --hint or write it yourself with --patch: verified units are kept, and a patch goes through the same verification as a model’s work. Read the packages guide →

Providers

Ollama

Fully local, no key. Default model qwen3.8:27b-mlx.

lex-code --ollama "..."

OpenCode Go

Cloud access to several open-weight coding models behind one key.

export OPENCODE_API_KEY=... lex-code --opencode "..."

OpenAI-compatible server

Any vLLM-style endpoint, including a local inference engine.

export VLLM_BASE_URL=.../v1/chat/completions export VLLM_MODEL=... lex-code --vllm "..."

Others

LiteLLM, lex-gpu, OpenAI, Mistral, Google, Vertex and Anthropic are implemented with less mileage. Only the three at left have been run end to end in this repository.

Provider guide →

Safety model

Security model →

Documentation

Status and limits