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

# Install globally
uv tool install ctxbaton

# Wire up the automatic Stop hook (Claude Code)
ctxbaton hooks install

Requires Python 3.11+ and 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 Skills (Claude Code, Codex, Cursor)

ctxbaton ships with a SKILL.md that auto-injects project context at session start. Copy it to your skills directory:

cp skill/SKILL.md ~/.claude/skills/ctxbaton/SKILL.md

Or run the full installer:

bash skill/scripts/install.sh

Then use /ctxbaton in any session to load context instantly.

MCP server

ctxbaton serve

Register in Claude Code:

claude mcp add ctxbaton -- ctxbaton serve

Or in any MCP-compatible client:

{
  "mcpServers": {
    "ctxbaton": {
      "command": "ctxbaton",
      "args": ["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.1.0.tar.gz (107.1 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.1.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ctxbaton-0.1.0.tar.gz
Algorithm Hash digest
SHA256 260e7877e92c97c637aaebd525af699df61619c71a241372799a71069ccce10e
MD5 ad20def390fdea6a6d73e7e71549d160
BLAKE2b-256 d61fac8d67e9a29a8c04dbd17b53ba348cc3e1ae37a493d30f0c42562b39e050

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ctxbaton-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 812ae435823aac388ebdffc2401d0ecb51aa070d81622a90f03f097086f55aab
MD5 6a4a77b90bdb48aaaf0c1a108eec8a19
BLAKE2b-256 bf3f69a8aad1b83465fc3ebbf6f1861cf45049f934b1267d69407b5a7cfa9e97

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