Skip to main content

Pass context between AI agents like a relay baton — persistent memory, snapshots, and semantic search across sessions

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctxbaton-0.2.4.tar.gz (62.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctxbaton-0.2.4-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file ctxbaton-0.2.4.tar.gz.

File metadata

  • Download URL: ctxbaton-0.2.4.tar.gz
  • Upload date:
  • Size: 62.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for ctxbaton-0.2.4.tar.gz
Algorithm Hash digest
SHA256 94f452fb79ed10ecdad52e85e8265c783b6b8081bc0645ebd28aa52bd0910f15
MD5 54e9ba8b21cf05dd64271fbddf5c0085
BLAKE2b-256 f74d30f864d11a4a6d1667d3e0fec71391889e3dcebe3e36b24c20b93df19a8c

See more details on using hashes here.

File details

Details for the file ctxbaton-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: ctxbaton-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for ctxbaton-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0289548139aa359142e6458a345ebabffb98491bb54d3b12bde7fac3da7f1b3e
MD5 61f06be56e197a00936f0a77f7074929
BLAKE2b-256 2104df657158ba7279c84a361411440bb2eabcb85dd493dbf0af86f8ccaa9a95

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page