Skip to main content

ctxbaton

Pass context between AI agents like a relay baton.

When you switch agents mid-project — because you ran out of tokens, changed tools, or just opened a new session — ctxbaton makes sure nothing is lost. Every agent picks up exactly where the last one stopped.

How it works

A lightweight hook fires after every agent turn and saves a snapshot: the current git hash, todo state diff, and transcript path. No tokens spent. No agent cooperation required. It just happens.

When you resume — in the same agent or a different one — run:

ctxbaton context    # what are we building, what's open, what was decided
ctxbaton replay     # what changed since I was last here

Install

uvx ctxbaton hooks install   # wire up the Claude Code Stop hook
uvx ctxbaton init            # write AGENTS.md into your project

Requires uv.

Commands

ctxbaton context              # full project context — spec, todos, handoff, decisions
ctxbaton replay               # what changed since last snapshot (git diff + todo changes)
ctxbaton replay --since 2h    # what changed in the last 2 hours
ctxbaton search "auth"        # semantic search across all memories

ctxbaton todo list            # open tasks
ctxbaton todo done <id>       # mark a task done
ctxbaton todo start <id>      # mark a task in progress

ctxbaton memory save --type decision "use JWT over sessions because..."
ctxbaton memory save --type handoff  "stopped mid-auth, next: refresh tokens"
ctxbaton memory save --type spec     "build a REST API with FastAPI"
ctxbaton memory save --type todo     "add rate limiting"

ctxbaton snapshot list        # full snapshot history with git hashes
ctxbaton hooks install        # install Claude Code Stop hook
ctxbaton serve                # start as MCP server

Memory types

Type Purpose
spec The current goal or plan
todo A task with status (pending / in_progress / done)
decision An architecture or design choice with rationale
handoff State snapshot when switching agents or sessions
progress What has been completed
general Anything else

Cross-agent continuity

ctxbaton is agent-agnostic. Claude Code, OpenCode, Codex, Cursor — they all call the same CLI and write to the same store.

Each project gets its own isolated DB at:

~/.ctxbaton/projects/-Users-you-dev-myproject/memories.db

The path mirrors the project directory (same convention as Claude Code's own memory files), so there's no config needed — open a project, run ctxbaton context, done.

Automatic snapshots

Install the Stop hook once:

ctxbaton hooks install

After that, every time an agent finishes a turn, ctxbaton saves:

  • The current git hash and branch
  • A diff of what todos changed
  • A reference to the session transcript

No tokens. No agent cooperation. Just a shell script that runs in milliseconds.

Agent instructions

Run once in your project directory:

ctxbaton init

This writes AGENTS.md into the project root. Claude Code, Codex, and OpenCode all read it automatically — every agent will run ctxbaton resume at session start and ctxbaton handoff before switching.

MCP server

ctxbaton serve

Register in Claude Code:

claude mcp add ctxbaton --env MEMORY_PROJECT=$(pwd) -- uvx ctxbaton serve

Or in any MCP-compatible client:

{
  "mcpServers": {
    "ctxbaton": {
      "command": "uvx",
      "args": ["ctxbaton", "serve"],
      "env": { "MEMORY_PROJECT": "/path/to/your/project" }
    }
  }
}

Storage

Memories are stored in SQLite with local embeddings (BAAI/bge-small-en-v1.5, ~40MB, downloaded once). No API keys. Works offline.

License

MIT — melonkernel/ctxbaton

Metadata

Release files for ctxbaton 0.2.4

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

Source distribution (sdist)

Source distribution for ctxbaton 0.2.4
File Size Uploaded Provenance
ctxbaton-0.2.4.tar.gz 62.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 84.9 kB

Release files / ctxbaton-0.2.4.tar.gz

Download URL ctxbaton-0.2.4.tar.gz
Size 62.3 kB
Tags Source
SHA-256 checksum
How to use checksums
94f452fb79ed10ecdad52e85e8265c783b6b8081bc0645ebd28aa52bd0910f15
BLAKE2b-256 checksum
How to use checksums
f74d30f864d11a4a6d1667d3e0fec71391889e3dcebe3e36b24c20b93df19a8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release files / ctxbaton-0.2.4-py3-none-any.whl

Download URL ctxbaton-0.2.4-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0289548139aa359142e6458a345ebabffb98491bb54d3b12bde7fac3da7f1b3e
BLAKE2b-256 checksum
How to use checksums
2104df657158ba7279c84a361411440bb2eabcb85dd493dbf0af86f8ccaa9a95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Security for ctxbaton 0.2.4

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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