Start
Brevi documentation
Brevi is a compiler built for AI coding agents. The agent writes ordinary Python, and Brevi builds it through Rust into a native program that prints exactly what CPython prints, typically 2 to 40 times faster. When Brevi cannot build something, it says so in one short JSON line the agent can act on.
Brevi is written in Rust and released under the Apache-2.0 license.
$ brevi run top.py < text.txt # build natively, then run
the: 3
and: 2
cat: 1
Who it is for#
- Coding agents that write Python to solve a task: Brevi takes the place of
python3in the loop. The agent needs no guide, and gets faster programs and shorter errors. Start with For AI agents. - People who run agent-written code: one native binary to ship, the same output as CPython, and a sandbox the program declares. Start with Install and Using Brevi.
- Anyone curious how a Python-to-Rust compiler can stay exact: Architecture and What works, and limits.
What makes it different#
- AI-first. Every design choice is measured by what it costs a model to get a working program: tokens written, errors read, retries. The release test has Claude models solve 24 tasks in Python, run once by CPython and once by Brevi, and Brevi must cost no more.
- Fast. Most Python builds into plain Rust with fixed types. Programs whose types change at run time build over dynamic values, still native.
- Safe. Rust's memory safety underneath, integers that never silently overflow, and a declared sandbox for file access and native code.
- Exact. A program Brevi builds gives CPython's output, or Brevi refuses at build time. It does not guess. On 591 saved agent programs, every build matched CPython byte for byte.
Where to go next#
Install
Release binaries, the install script, Docker, or from source.
Using Brevi
Commands, flags, errors, the CPython fallback, sandbox and GUI tests.
For AI agents
MCP server, Agent Skill, Claude Code plugin, llms.txt and prompting advice.
Architecture
The pipeline from source to native binary, with diagrams.
What works, and limits
Python coverage, libraries, big integers and known gaps.
Benchmarks
Release test, model cost, and Brevi against Codon and Nuitka.
Status#
Brevi is a preview, at version 0.24. It builds most real-world agent-written Python natively today, and the roadmap lists what is still missing. Package-manager installs (pip, npm, Homebrew) and the hosted service at brevi.run are coming; for now, install from the GitHub release.