Fork any AI coding-agent session back to any step — the files and the memory. The forked agent genuinely forgets the future.
Record Claude Code and Kimi CLI sessions, rewind them to the exact step where things went wrong, and branch from there. Replay recorded runs for $0. Turn failures into permanent CI tests. Python 3.9+ stdlib, zero dependencies, local-first, MIT.
Your agent goes off the rails at step 20 of 47. Your options today:
- Start over — and re-pay the full token cost of steps 1–19.
claude --resume/kimi -S— but the agent still remembers the broken steps, and steers itself back into the same ditch.- Scroll the transcript and guess what the files looked like back then.
beyond fixes all three at once.
An agent is taught a codeword in turn 1, a second codeword in turn 2:
- Turn 1 — "remember GOLDENHAWK" (+ it writes
notes.txt= phase one). - Turn 2 — "remember SILVERWOLF" (+
notes.txt= phase two). bnd record --git --followhas been watching: the session and a git checkpoint of the working tree after every tool call.- Fork from step 5 — one click in
bnd web:
The files are restored to phase one in a new worktree. A new session is written — truncated at step 5 — and resumed. You ask the forked agent:
What codewords did I teach you?
It answers: "GOLDENHAWK. You never mentioned SILVERWOLF."
Not prompt engineering. Not "please disregard." The memory is gone — verified live against claude 2.1.218 and kimi 0.28.1. The timeline is a first-class conversation view, not a log:
| Command | Outcome |
|---|---|
bnd record |
Records the session from the CLI's own local transcripts. Works with Claude Pro/Max and Kimi subscriptions — no API key, nothing on the wire. |
bnd record --git |
Also checkpoints the working tree at every tool call (temp-index git plumbing only — your index, HEAD, and files are never touched). |
bnd fork <run> --at N |
Restores files to step N in a new worktree + truncates the conversation at N (surgical) or starts fresh with a handoff (synthesis). Version-gated: unverified formats fall back safely, never best-guess. |
bnd wrap / bnd replay |
Proxy mode for API-key users and CI: record raw HTTP, replay it byte-exact for $0, or replay a prefix and continue live (--until N --then-live). |
bnd test |
Turns any recorded run into a deterministic, structural CI test (tool sequence, token budgets, file states). No LLM judges. Cases commit to your repo. |
bnd diff |
First divergence point, unique tool calls, token totals per side. |
bnd web |
Every Claude/Kimi conversation on the machine, grouped by project, in a localhost-only UI. Fork from any message bubble. |
A run against its own fork:
| What it does at a checkpoint | |
|---|---|
| LangSmith / Langfuse / Helicone | Traces. No replay, no environment, no forking. |
| LangGraph time travel | Re-executes the graph live — every LLM call is re-billed and can diverge (their own docs say so). Conversation state only, no environment. |
claude --resume / kimi -S |
Continues the full conversation — the agent remembers everything, and your files stay where they are. |
| beyond | Byte-exact replay for $0; fork restores the git working tree and truncates the conversation at the same step. |
pipx install beyond-ai # or: pip install beyond-ai
cd your-project
bnd record --git --follow # record the agent session + env checkpoints
bnd web # browse every conversation, fork from any step
bnd fork <run-id> --at 20 # same thing, from the terminalForking writes into the CLIs' own session stores, so bnd hard-gates on verified versions — anything unknown falls back to the synthesis path rather than writing a best-guess session.
| CLI | Verified version | Format verified | Surgical fork |
|---|---|---|---|
| Claude Code | 2.1.218 | JSONL transcript | yes (live-verified) |
| Kimi CLI | 0.28.1, 0.29.0 | wire protocol 1.4 | yes (live-verified) |
Recording, replay, diff, tests, and the web UI work with any version of either CLI — the gate applies only to session surgery.
- Record (transcript + proxy), zero-token replay, env checkpoints
- Surgical fork (env + conversation), synthesis fallback
-
bnd testdeterministic CI regression suite -
bnd diff, run normalization (one canonical event model) -
bnd webconversation-first local UI - Native Mac app (the web API was designed as its backend — contributors welcome!)
-
bnd mcp— let agents inspect and rewind their own runs - More CLIs: Codex, Cursor, Aider (adapters wanted — see Contributing)
- Go single-binary port
- Hosted team dashboards
Good first issues: new CLI adapters (Codex, Cursor, Aider — each
needs a transcript parser and a session-store probe), format
re-verification as Claude/Kimi ship new versions (the surgical gates
are intentionally strict), and Mac-app work on top of the existing JSON
API. Stdlib-only Python, no build step, python3 test_bnd.py must stay
green (78 tests).
MIT. Everything runs locally; recordings and sessions never leave your machine.
Reference: recording modes, run format, checkpoint safety, test spec, web API
- Membership mode (default):
bnd recordingests the CLI's own local session transcripts (~/.claude/projects/<dir>/<session>.jsonl,~/.kimi-code/sessions/.../wire.jsonl). No interception, works with any auth.--followtails live; in a git repo, checkpoints are auto-enabled (--no-gitto disable). - Proxy mode:
bnd wrap --upstream <url> -- <cmd>sits between the CLI and the model API, forwarding every header untouched (Claude subscription OAuth verified working; Kimi's host-pinned OAuth refuses non-default base URLs — hence membership mode).bnd replay <run>serves recorded responses byte-exact;--until N --then-livereplays a prefix then forwards to the real upstream, recording the continuation as a linked run.
~/.bnd/runs/<id>/ holds meta.json plus events.jsonl (one JSON
object per line: seq, ts, kind [user_msg, assistant_msg, thinking,
tool_call, tool_result, usage, meta, error], agent, content, tool,
tool_id, model, usage, is_error). Proxy runs keep
interchanges.jsonl as the byte-exact replay source of truth and derive
events.jsonl deterministically (bnd normalize, or automatic on
wrap/show/diff/test).
Snapshots use a throwaway index (GIT_INDEX_FILE) + git add -A +
write-tree + commit-tree under refs/bnd/<run>/<seq> — plumbing
only. The user's index, HEAD, branches, and working tree are never
modified (the tests assert this byte-for-byte). Fork materializes with
git worktree add --detach into ~/.bnd/worktrees/. Checkpoints are
step-aligned only when recording live (--follow); post-hoc recording
stores one honestly-labeled snapshot.
- Kimi: the wire log is append-only; truncation = cut at the mapped
line and complete any dangling tool call. Sessions are registered in
~/.kimi-code/session_index.jsonl; workDir pinning is rewritten to the fork worktree. No integrity mechanisms found. - Claude: truncated copy written as
<new-uuid>.jsonlwithsessionIdfields rewritten; resume reads only the project-dir file — no workdir pinning beyond that. - Both: original sessions are never modified.
context.undoprefixes and subagent wires refuse surgery and fall back.
case.json holds {"assert": [...]} — tools_contain (ordered
subsequence), tools_exclude, tool_args (regex), no_errors,
tool_calls/events/interchanges bounds, tokens budgets,
final_message (regex), file (exists/match at the run's last git
checkpoint). Modes: golden validation (free), --on <run> candidate
gate (free), --live [--at N] re-execution (costs tokens; with --at
the prefix is replayed free and the spec targets the live tail).
bnd test update <name> --from <run> re-baselines. Exit 0/1, --json
report for CI artifacts.
GET /api/conversations sessions grouped by project, duplicate-collapsed
GET /api/conversations/events?path= parse an (unrecorded) session into events
POST /api/conversations/record {path} -> record, returns the new run id
GET /api/runs GET /api/runs/<id> GET /api/runs/<id>/events?after=N
GET /api/diff?a=<id>&b=<id> GET /api/tests GET /api/recording
POST /api/fork {run_id, at, method, env} -> new run + resume command
POST /api/tests/run {name?, on?} -> the bnd test JSON report
python3 test_bnd.py # 78 integration tests, stdlib only
./demo_fork.sh # live demo: real kimi session, checkpoints, fork, proof
./demo_test.sh # live demo: bnd test suite, caught regression, live tail


