Skip to main content

codebaton

See your Claude Code and Codex limits live, and never lose your thread when one runs out. No proxy, no API keys: your own subscriptions, the official CLIs.

CI PyPI Python License: MIT

You're deep in a task with Claude Code and it says you've used most of your 5-hour limit. codebaton sees that coming. It shows each agent's usage against a threshold you choose, opens the agent that still has room, and passes the baton: the next agent picks up where the last one stopped, using shared notes and git checkpoints.

$ codebaton watch
agent        window usage                   used  status
claude_code  5h     ██████████████│░░░░░    71%  over threshold (threshold 70%)  resets in 1h 12m
claude_code  week   ████░░░░░░░░░░│░░░░░    22%  ok (threshold 70%)  resets in 3d 2h
codex        5h     █░░░░░░░░░│░░░░░░░░░     6%  ok (threshold 50%)  resets in 4h 40m
codex        week   ░░░░░░░░░░│░░░░░░░░░     2%  ok (threshold 50%)  resets in 5d 18h
  • No proxy, no API keys. Your traffic goes straight from the official claude and codex CLIs to their providers, on the subscriptions you already pay for. Nothing sits in between, and nothing breaks the providers' terms the way relay proxies can.
  • Native, not a wrapper. You get the real CLI, with full speed and every feature. codebaton adds a status line and hooks for that session only and never touches your own settings.
  • Real usage numbers. These are the same percentages /usage shows, not token guesses.
  • Hand-over without a lost thread. HANDOFF.md and AGENTS.md carry the goal and progress between agents. A git checkpoint is saved after every reply.
  • Local fallback. An optional free Ollama model runs on your machine, with a memory check before anything is installed or loaded.
  • Your logins stay yours. codebaton never reads, stores or sends credentials. Each CLI uses its own sign-in.
  • Ready for teams. An organisation policy file locks permissions and approved agents on every machine, and codebaton report exports usage and hand-overs as JSON or CSV.

Status: alpha (0.x). Tested on macOS with Claude Code and Codex CLI. Linux should work; Windows is untested.

How it works

codebaton component diagram: the CLI reads usage, the launcher opens Claude Code, Codex or Ollama, session hooks save checkpoints and handoff notes. Dashed boxes show the next milestones: quality gates, style contract, MCP server, light local harness.

  1. You run codebaton in a project.
  2. It reads each agent's usage and recommends the first one under its threshold.
  3. It opens that agent's real CLI in your terminal, with session-only hooks attached.
  4. After every reply, a hook saves a git checkpoint and checks usage. Near the threshold the agent is asked to update HANDOFF.md; over it, you're offered the next agent, which starts by reading that file.

More detail: docs/architecture.md. Design decisions: docs/decisions.md.

Requirements

  • Python 3.11+
  • At least one agent CLI, installed and signed in: Claude Code (claude) and/or Codex CLI (codex, then codex login)
  • git (progress is saved as commits)
  • Optional: Ollama for a free local model

Install

pipx install codebaton      # or: uv tool install codebaton
                               # or: pip install codebaton
codebaton --version

Quick start

cd your-project            # any git repository
codebaton               # first run offers to set the project up
  claude_code   27.0% used / 50% threshold  ok   [week 18%, 5h 27%]
  codex          2.0% used / 50% threshold  ok   [5h 2%, week 0%]

Which agent?
  1) claude_code   27.0% used / 50% threshold, under threshold  <- recommended
  2) codex          2.0% used / 50% threshold, under threshold
  3) ollama       local model llama3.2:1b, chat (answers in seconds, no edits)
  q) quit
Choose (Enter = recommended):

Press Enter and you're in the real Claude Code. Work as usual. When you /exit above the threshold, codebaton asks "Continue in codex?", and Codex starts by reading HANDOFF.md.

Everyday commands

Command What it does
codebaton Show usage, then open the recommended agent
codebaton use claude / codex / ollama Open a specific agent
codebaton use claude "fix the login bug" Open it with a first message
codebaton watch Live usage bars with reset countdowns for every agent (--json for scripts and menu-bar widgets)
codebaton status [--refresh] Usage vs thresholds (--refresh makes one tiny Claude call for fresh numbers)
codebaton report [--since 7d] Sessions, hours, checkpoints and hand-overs per agent (--json, --csv)
codebaton install-model Pick and install a local model: shows its size and the memory it needs, then asks first
codebaton use ollama --chat Local model as a plain chat: answers in seconds, can't edit files
codebaton run "<task>" One task, unattended (scripts, overnight), with model tiers and automatic failover
codebaton help Everyday commands with examples

Options: --model haiku|sonnet|opus starts on a tier (Codex uses its matching model); --repo DIR works on another folder. Inside a session, the agent's own /model works as usual.

What codebaton adds to a session

Claude Code Codex
Live usage status line: baton · Claude · 5h 31% · wk 18% / 50% · next: Codex Codex's own /status
After every reply git checkpoint if files changed git checkpoint if files changed
Near the threshold Claude is asked once to update HANDOFF.md desktop notification
Over the threshold "Type /exit to continue in Codex" desktop notification

Configuration

The first run creates these files in your project:

File Purpose Commit it?
router.yaml agent order, thresholds, permissions no (added to .gitignore)
model_routing.yaml which tasks go to haiku / sonnet / opus tiers yes
AGENTS.md project goal and conventions for every agent yes
HANDOFF.md current state: goal, done, next, open questions yes
decisions.log one line per decision yes
# router.yaml
providers:              # preference order: the first one under its threshold wins
  - name: claude_code
    cap_percent: 50     # above 50% used (as /usage shows it), move to the next agent
  - name: codex
    cap_percent: 50
profile: per_session    # overnight | per_session | strict
warn_margin_percent: 5  # this close to a threshold, ask the agent for a full handoff
git_checkpoint: true    # commit a checkpoint after every agent reply
allow_web: false        # let agents browse / search the web
allow_push: false       # let agents run `git push`
allow_all_commands: false
ollama:
  enabled: true
  mode: agent           # agent (edits code via Codex) | chat (fast, no edits)

The full reference is examples/router.example.yaml.

How usage is measured. Claude reports its 5-hour and weekly usage with every reply. Codex writes the same figures to its local session logs. The higher of the two windows counts. A rate-limit error marks an agent as exhausted until its window resets.

For teams and organisations

Organisation policy. IT can deploy one file to every machine (for example with MDM). Projects can't loosen it. codebaton reads $CODEBATON_POLICY if set, otherwise /etc/codebaton/policy.yaml:

# /etc/codebaton/policy.yaml
minimum_profile: per_session        # projects may be stricter, never looser
deny: [push, all_commands]          # switches no project can turn on (also: web)
allowed_agents: [claude_code, codex] # e.g. no local models
require_checkpoints: true
max_cap_percent: 80                 # keep headroom: hand over by 80% at the latest

Whenever the policy changes a project's settings, codebaton says what it enforced.

Reporting. codebaton report --since 30d --json summarises each repository's audit log (.codebaton/audit.jsonl): sessions, hours, checkpoints, hand-overs and rate limits per agent. Collect the JSON or CSV from many repositories with no server involved.

Why it suits companies: no proxy and no extra credentials, so no new vendor sees your code; the official CLIs keep their own permission prompts and sandboxes; and every routing decision is logged locally.

Local models (Ollama)

codebaton install-model     # choose from models that suit your machine's memory
codebaton use ollama --chat # instant answers, no file edits
codebaton use ollama        # coding agent via Codex's harness (can edit files)

Be realistic about speed. Agent mode sends Codex's ~47K-token instructions to the model, so on a laptop the first reply takes about a minute even with a 1B model. Replies after that take seconds. Small models also make mistakes as agents. Chat mode is the quick way to confirm local models work. Ollama is started only when you choose it and stopped when you exit.

Safety and privacy

  • Credentials: never read or stored. router.yaml refuses keys that look like secrets.
  • Commits: a checkpoint commits only the files created or changed during the agent's turn. Work you already had uncommitted, or staged, when the session opened is left alone, unless the agent edits that same file. Checkpoint commits are named chore(codebaton): ..., hooks such as pre-commit still run, and git_checkpoint: false turns them off. Unattended codebaton run owns the repo and commits everything.
  • Permissions: in interactive sessions each CLI keeps its own permission prompts. The allow_* switches mainly affect unattended codebaton run, and they're off by default.
  • Outside git: codebaton warns before setting up a folder that isn't a git repository.

Report vulnerabilities privately: see SECURITY.md.

Roadmap

  • v0.1: native Claude Code / Codex sessions with usage routing, handoff notes, git checkpoints, local models with memory checks
  • Milestone 2: quality gates (tests, lint and an LLM judge after each task; a low score moves to a stronger model) and a shared style contract
  • Milestone 3: MCP server, so any MCP client can ask for usage, handoffs and checkpoints
  • A lighter local harness, so small local models can edit code in seconds
  • Live usage monitor (watch), team report (report), organisation policy
  • More agents (e.g. Gemini CLI) through the provider plug-in interface
  • Menu-bar widget and Linux desktop notifications

Ideas and votes are welcome in Issues.

FAQ

Is this a proxy? Does it see my prompts? No. Your terminal talks directly to the agent CLI. codebaton only launches it, reads usage numbers and saves checkpoints.

Why not an MCP server? An MCP server runs inside one agent, so it can't switch you to a different agent. The CLI does the switching. An MCP server for usage and handoff tools is on the roadmap.

How is this different from claude-code-router or other model proxies? Those send your requests through a proxy to other models or API keys. codebaton never touches the traffic: it runs the official CLIs on your own subscriptions, watches the usage they report, and hands the work over with shared notes and git checkpoints.

Do I need both Claude Code and Codex? No. With one agent you still get the status line, checkpoints and handoff notes. With Ollama you also get a free local fallback.

Contributing

Contributions are welcome. Start with CONTRIBUTING.md.

git clone https://github.com/aaajjjj/codebaton.git
cd codebaton
uv sync
scripts/check.sh    # format, lint, type-check and tests, as CI runs them

Commit messages follow Conventional Commits (feat:, fix:, docs:, ...). Releases and the changelog are generated from them: see docs/releasing.md.

Disclaimer

codebaton is an independent project. It isn't affiliated with or endorsed by Anthropic, OpenAI or Ollama. Claude, Claude Code, Codex and Ollama are trademarks of their respective owners. You're responsible for following each provider's terms of use.

License

MIT

Metadata

Release files for codebaton 0.1.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 codebaton 0.1.0
File Size Uploaded Provenance Actions
codebaton-0.1.0.tar.gz 59.2 kB With provenance Details for codebaton-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 130.7 kB

Release files / codebaton-0.1.0.tar.gz

Download URL codebaton-0.1.0.tar.gz
Size 59.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5553f7db3a0dc791fafc99e9844c172dc1b483e21c56ee02bd2896ebf4df2ffe
BLAKE2b-256 checksum
How to use checksums
42105311b1db2fc6fad2cce34d537f58b2edc03b2a04a4fbbfe40f02e91a4537
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 5, 2026.

Transparency log

Release files / codebaton-0.1.0-py3-none-any.whl

Download URL codebaton-0.1.0-py3-none-any.whl
Size 71.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbc63946d1db3d53bbfdb1eeef9f2cf54fdf72d7f1e3a4392901e089146c7331
BLAKE2b-256 checksum
How to use checksums
0a293c17ca99467df16582afc3d3bd369b275fd2445c82b47375402b009cd3c2
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 5, 2026.

Transparency log

Security for codebaton 0.1.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 codebaton-0.1.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 5, 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.1.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