Skip to main content
batonai logo

batonai

One AI writes the code. Another one checks it.

A local-first CLI that hands your request from model to model — Codex plans, Claude Code builds, your tests run, Codex reviews — with zero tokens spent on coordination and no commit made without you.

CI Release Python Platforms License: MIT

Quick start · Guard mode · How it works · Is it worth it? · User guide · Türkçe

A batonai run: planner on Codex, tests before, coder on Claude Code, tests after, reviewer on Codex — verdict APPROVE WITH NOTES

Why

A model reviewing its own code shares its own blind spots. A different model, reading the actual diff against the plan, catches what the first one missed — in one of this project's early real runs, Codex caught a genuine bug in the code Claude had just written (ADR-015).

batonai makes that the default, without turning your workflow into an agent framework:

  • 🧭 Deterministic. Routing is plain Python from YAML. No supervisor LLM, no agents chatting — every token goes into the work.
  • 🔀 Different models for different jobs. Planning and review on Codex, implementation on Claude Code, tests on your own runner — three quota pools instead of one.
  • 🧪 Grounded in your tests. Tests run before and after the change, so a suite that was already red is never blamed on the coder.
  • 🔒 You stay in charge of git. No stage ever commits or pushes. Every artifact — plan, prompts, diff, review, costs — stays on disk to inspect.

Quick start

uv tool install git+https://github.com/ozanorfa/baton   # or: pipx install git+https://github.com/ozanorfa/baton
cd your-project                                          # a git repo with a clean tree
batonai                                                  # scans, sets up, asks what you want

You need Claude Code (claude) and Codex CLI (codex) installed and logged in; batonai doctor checks. Python ≥ 3.12. Optional, only for stages that are off by default: agy (Designer), opencode (Publisher), repowise (--health). Then, any time:

batonai "Add Face ID unlock to the settings screen"        # the full pipeline
batonai --with-tester --fix-loop "…"                       # + your tests, + one automatic fix pass
batonai --preset tdd "add a slugify() helper"              # test-first: Codex writes failing tests, Claude makes them pass
batonai --pause-after planner "…"                          # read/edit the plan before any code is written
batonai review                                             # just a second opinion on your own uncommitted diff

Guard mode: a second opinion on every Claude Code turn

Already living in Claude Code? Keep doing that. One command makes the Reviewer a Stop hook:

batonai guard install

Every time Claude finishes a turn with uncommitted changes, Codex reviews the diff. NEEDS WORK → Claude gets the findings and keeps going (or argues back, by finding ID). Anything else → Claude stops with a one-line note. Bounded to one automatic round per request by default, never reviews the same diff twice, and never traps your session if something on baton's side fails. batonai guard uninstall removes it.

How it works

flowchart LR
    R([your request]) --> P[Planner<br/>Codex · read-only]
    P -->|plan.md| B[Baseline<br/>your tests · 0 tokens]
    B --> C[Coder<br/>Claude Code · edits files]
    C -->|diff + changes.md| T[Tester<br/>your tests · 0 tokens]
    T --> V{Reviewer<br/>Codex · read-only}
    V -->|APPROVE| D([you: review the diff, commit])
    V -.->|NEEDS WORK · fix-loop| C

Each stage hands the next one an artifact (a plan, a change summary, the real diff, a test report) — not a transcript. The Reviewer also gets a mechanical plan ↔ diff drift report and, on a re-review, its own previous findings to rule on one by one. Same-provider stages resume each other's session, so Codex reviews with the planner's understanding of your repo already loaded.

One coding agent Supervisor-LLM frameworks batonai
A different model reviews the code only if you ask depends on the setup ✓ every run
Tokens spent on coordination none the supervisor's none
Your tests before and after the change if you ask depends on the setup ✓ --with-tester
Plan, prompts, diff and review saved per run a transcript varies ✓ .ai/runs/
Resume a failed run without re-paying earlier stages — varies ✓
May commit or push with your permission depends on the tool never — only batonai publish, typed by you

Everything it can do

Pipeline batonai "<request>" · --with-tester · --with-designer · --with-publisher (drafts a commit message) · --fix-loop · --health (code-health hotspots via repowise)
Shape a run --preset quick (no planning) · --preset tdd (tests first) · your own presets · --pause-after <stage> · batonai presets
Iterate batonai revise "<correction>" (the coder resumes its own session) · batonai resume <id> (continue a failed run; remembers its preset and stages)
Review only batonai review (your diff, second model) · batonai guard install (every Claude Code turn)
Learn numbered findings the coder may dispute · batonai runs judge (which findings were real?) · batonai learn (keep a rule every stage reads)
Quota fallback: [codex] per role — a stage survives its provider's usage limit · batonai usage (spend per pool, last 5 h / 24 h / 7 d)
Measure batonai eval run "<task>" — single session vs pipeline, blind · batonai runs export · batonai runs show <id> --html
Integrate batonai mcp — call baton from Claude Code or Codex as MCP tools: claude mcp add baton -- batonai mcp
Setup batonai init · batonai setup (which AI does which job, which model) · batonai doctor · batonai config show

Full reference: the user guide (Türkçe).

Is it worth it? Measure it

The premise — two models in a pipeline beat one model in one session — is a claim until it is measured on real work, so baton ships the instrument:

batonai eval run --setup "npm ci" --review-single "add a dark-mode toggle that persists"

Your last commit is cloned twice (your working tree is never touched). One clone gets a single Claude session, the other the baton pipeline; your tests run in both; you judge the two diffs as X and Y without knowing which is which. --review-single also asks the Reviewer about the single session's diff — would a second model have caught something it shipped? The protocol and the results so far live in docs/EVALUATION.md. Honest status: no results recorded yet — if you run it, an issue with your batonai eval list output is the most useful contribution there is.

What the cost number means

The $ after a run is the provider-reported API-equivalent value. On subscription plans (Claude Pro/Max, ChatGPT) you are not charged per run — the run uses your plan's quota. A typical pipeline run is $0.50–1.50 of quota, mostly fixed per-stage overhead, so it barely grows with task size. For small changes use --preset quick, batonai ask, or a lighter model (providers: {claude: {model: haiku}}).

⚠ Trust model

The Coder stage edits your repository unattended (scoped to the project directory). The safety net: start from a clean git tree (you are warned otherwise), every change is diffable, the Reviewer reads the actual diff, and no pipeline stage ever runs git commit, git push or anything touching a remote — for any role, with any flag. The one command that runs git is batonai publish --commit/--push, which you type yourself and confirm. With providers: {claude: {allow_commands: true}} the Coder may run your tests, while git history and remote commands stay mechanically blocked. Details: ADR-007, ADR-014, ADR-034.

Status

v0.3.0 (2026-12-01; releases carry the wheel — not on PyPI yet) — see CHANGELOG.md. Verified live on macOS with the real CLIs (a real Flutter app end to end); the 440+ test suite needs no AI access and runs on macOS, Linux and Windows in CI. Every 0.3 feature was exercised live on 2026-12-01 with the real CLIs — the guard (headless and in an interactive Claude Code session), test-first runs with a paused and edited plan, the quota fallback, the findings ledger through a full open → fixed cycle, eval, and both MCP tools from Claude Code. In the first guard run, Codex caught a real input-validation bug in the function Claude had just written, and Claude fixed it before stopping. The suite also passes in a Linux container. Not yet verified: a live run with the real CLIs on Linux or Windows. Every design choice is written down in 47 ADRs.

Documentation

Doc What's in it
HOW_TO_USE.md · HOW_TO_USE.tr.md Start here — the plain-language user guide
EVALUATION.md Does the pipeline beat a single session? The protocol, and results as they come
ARCHITECTURE.md Layers, adapter contract, context system, verified CLI behaviour
DECISIONS.md Why everything is the way it is
MANUAL_TESTING.md Every feature, hands-on, with token-cost notes
CHANGELOG.md · WORKLOG.md Releases · session-by-session history
PROJECT_STRUCTURE.md · IDEAS.md Repo layout · evaluated ideas

Contributing

Pull requests against a protected main (green CI on all three platforms required) — see CONTRIBUTING.md. Third-party providers plug in through the ai_orchestrator.providers entry-point group.

git clone https://github.com/ozanorfa/baton && cd baton
uv sync
uv run pytest          # unit + contract (recorded real CLI fixtures) + integration (fake provider)
uv run ruff check .

Releasing (maintainers): bump version in pyproject.toml, move Unreleased in CHANGELOG.md to the new version, merge, then git tag v<version> && git push origin v<version>. The release workflow checks the tag against the version, runs the suite, builds, and creates the GitHub release with the wheel (PyPI publishing is switched on by the PYPI_PUBLISH repository variable).

If you move the checkout, the old .venv keeps absolute paths (uv run pytest then fails to import ai_orchestrator): rm -rf .venv && uv sync, and unset VIRTUAL_ENV if your shell still exports the old one.

Exit codes for scripts: 0 success (or paused on purpose) · 1 a stage failed · 2 config/usage error · 130 cancelled.

MIT licensed · made for people who would rather read a diff than trust one

Metadata

Release files for batonai 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for batonai 0.3.0
File Size Uploaded Provenance Actions
batonai-0.3.0.tar.gz 129.0 kB With provenance Details for batonai-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for batonai 0.3.0
File Interpreter ABI Platform Actions
batonai-0.3.0-py3-none-any.whl Python 3 none any Details for batonai-0.3.0-py3-none-any.whl

Total release size: 296.5 kB

Release files / batonai-0.3.0.tar.gz

Download URL batonai-0.3.0.tar.gz
Size 129.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2cb17ba77de667ca222af1a33b048455b72b2e806434848f7a7643ed416332ed
BLAKE2b-256 checksum
How to use checksums
51f8d82c6452b958310b9c6a9e2bc54712ce6c0fa0652bc0c20ec783166e0da8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / batonai-0.3.0-py3-none-any.whl

Download URL batonai-0.3.0-py3-none-any.whl
Size 167.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e31acc4b41cbda23096da9f75c1eb9285fc2fb9ba8cb1fbcad562508e277b94
BLAKE2b-256 checksum
How to use checksums
793c1a5c3312b5144bd0eb7e7e9773a45e25ce6244dca7ce5c42b8f25ec54856
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for batonai 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for batonai-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page