Redthread: Portable, Git-Backed Memory for AI Coding Agents

Redthread keeps your AI coding agent's memory in a git repo and serves it over MCP, so Claude Code and other agents remember on every machine.

On this page

Coding agents such as Claude Code and Cursor take notes about your project as they work: what you decided, what broke, how you like things done. Most of them keep those notes in a local folder such as .claude/, .cursor/ or .agent/. Sit down at a different computer and the notes are gone. The agent starts from zero, and you explain your project all over again.

Redthread is a small tool I wrote to fix that. It keeps the agent’s memory in a git repo instead of a local folder, and shares it with the agent over MCP (Model Context Protocol, the standard way to plug tools into an AI agent). Every machine that clones the repo gets the same memory. This post shows how to install Redthread, connect it to an agent and use it.

Two machines share one Redthread store through a git remote. Each agent reads and writes the store over MCP.

Install

pip install redthread          # or: uv tool install redthread

You need redthread 0.15 or newer for this post. Older versions need a --store flag and a separate redthread init step for each project.

Connect your agent once

You register Redthread one time, and the same registration works in every project. There’s no store path to pass. For Claude Code, use this command:

claude mcp add --scope user redthread -- uvx redthread mcp-serve

uvx downloads Redthread from PyPI the first time it runs, so this command works even if you skipped the install step. If Redthread is already installed, drop uvx:

claude mcp add --scope user redthread -- redthread mcp-serve

To make sure that the connection is correct, do these steps:

  1. In Claude Code, type /mcp.
  2. Make sure that redthread shows as connected with 19 tools.
  3. Tell the agent to call context_bootstrap.

NOTE: Claude Code reads MCP servers only when a session starts. If you add the server during a session, restart Claude Code.

This also fixes the old problem with Cursor. Cursor keeps one global entry in ~/.cursor/mcp.json for every window you open, so a fixed store path sent every project’s memory to the same store. Without a path, each call finds its project’s store on its own. Cursor uses an install deeplink, not a CLI command. VS Code uses code --add-mcp. The per-client reference gives the procedures for Cursor, VS Code, Windsurf, Claude Desktop, Codex CLI, Gemini CLI and the Claude Agent SDK.

Your first session in a repo

A store is where the memory lives. By default it’s a separate branch inside the repo you already have. That branch shares no history with your code (git calls this an orphan branch), and Redthread checks it out as a worktree in ./redthread-store. Your working branch isn’t touched, and you don’t need a second repo.

You don’t create the store yourself. The first time the agent uses Redthread in a repo with no memory yet, it asks you first. If you say yes, it calls store_init, which does three things:

  1. It makes the orphan branch redthread-store and checks it out in ./redthread-store.
  2. It adds ./redthread-store to .gitignore.
  3. It commits a small .redthread.yaml file to your current branch. This file tells Redthread where the store is.

The store also has a phase pipeline, which is just the ordered list of stages your work goes through. The default is build,test,present, and the project id defaults to the repo’s folder name. If you want other names, for example train,eval,present, tell the agent, or create the store yourself:

redthread init my-project --phases train,eval,present --worktree-repo .

Make the agent use the memory

This is the step people miss. Registering the MCP server means the agent can use the memory. Nothing tells it that it should. When I tested this, agents often went a whole session without touching the memory tools.

Redthread handles this in two ways.

1. One tool that gives all the context. An agent starting cold would otherwise have to look up the runs, the memory folders and what is in each of them. That takes a lot of tool calls, and agents tend to give up before they find anything useful. So a single tool hands over everything at once:

redthread bootstrap

This command shows the same data that the agent gets from context_bootstrap:

  • The phase pipeline.
  • The recent runs and their status.
  • The published handoffs.
  • An index of all memory entries, with a one-line description for each.

The response also has a _next field that tells the agent what to do next: read certain entries, start a run, or write a session summary before it stops. After one call, the agent knows where things stand.

2. A note in AGENTS.md or CLAUDE.md. Most agents read this file first, and Redthread can write the note for you. Tell the agent to call agents_md_bootstrap. It adds a short usage policy to the file in your project. Calling it again changes nothing, so it is safe to run in every session.

CAUTION: Subagents do not get the instructions of the main agent, and they do not read AGENTS.md. A subagent skips the memory and does not tell you. For that reason, the usage instructions are also in the tool descriptions and the tool responses. This is the only channel that reaches all agents in all clients. If you give a subagent a task with important results, tell it to call context_bootstrap.

Make the store portable

A worktree store pushes to your code repo’s own remote, so there’s nothing extra to set up. Push your code as usual and the memory goes with it. Redthread pushes the store branch in the background after each write. To sync by hand, run this command:

redthread sync

sync commits, pulls and pushes in one go. If you don’t want to think about commits at all, run the auto-commit daemon (redthread daemon run).

On the next machine, do these steps:

  1. Clone your code repo.
  2. Register the same MCP command, if this machine does not have it yet.
  3. Start the agent in the repo.

Redthread reads the committed .redthread.yaml file and gets the store from the remote. You do not give flags, and you do not clone the store manually.

If memory must not go where your code goes, keep it local with redthread publish --disable. If you’d rather keep the store in its own repo, give redthread init a --store path without --worktree-repo, and add a remote to that repo.

Use the CLI

The store also tracks runs, where a run is one pass through your phases. You don’t need an agent for this. It is handy for any pipeline where one stage hands its results to the next. Here is a full example:

NOTE: Run these commands from the root of your repo. The CLI uses ./redthread-store by default. For a store in a different location, add --store <path>.

# a run is one attempt through your declared phases
run_id=$(redthread run start)

# append immutable context entries as a phase works
redthread log "$run_id" build note '{"msg": "kicked off build"}'

# publish the build phase's curated handoff for the next phase
echo '{"headline": "build ok", "key_results": {"warnings": 0}}' > handoff.json
redthread handoff publish "$run_id" build handoff.json

# the test phase reads only the handoff — never build's raw log
redthread handoff get "$run_id" build

# full raw history, one JSON entry per line
redthread read "$run_id"

The handoff and the raw log are separate on purpose. The log is append-only, so it only ever grows. The next phase reads the short handoff instead of the whole log. That keeps the agent’s context window (the limited amount of text it can hold in mind at once) from filling up with leftovers from the previous phase.

On the MCP side, run_id is optional for every tool that uses a run. Leave it out and the tool picks the newest active run, then reports which run id it used, so an agent can’t quietly write to the wrong run. If you have several runs going on different machines, pass the run_id yourself.

Long-term memory

Long-term memory lives apart from runs, because the things worth remembering usually outlast any single run. Each entry carries a one-line description:

redthread memory write notes toolchain.md ./note.md \
  --description "Why this project uses uv, not conda" \
  --tags toolchain

redthread memory list

The list shows the descriptions, not just filenames, so an agent can tell which entries matter before opening any of them. An entry with no description shows its first line of text instead, which keeps older stores readable.

To find a specific entry, use search. It looks through keys, descriptions, tags and the text itself, and shows the matching line:

redthread memory search uv

The same data is also exposed as MCP resources, for example redthread://bootstrap, redthread://memory and redthread://handoff/{run_id}/{phase}. Some clients can attach these directly, with no tool call.

Warning

WARNING: Do not write secrets to the store. The store is a git repo, and usually you push it to a shared remote. Git keeps all memory entries in its history. All persons with access to the repo can see them.

Redthread is MIT licensed and runs on Windows, Linux and macOS (Python 3.11+). Issues and PRs are welcome.

If you like the idea of giving agents small, sharp tools over MCP, Mullion FileMan does the same for comparing and syncing folders.

Written by Sina Fathi-Kazerooni

I write about reinforcement learning, transformers, multi-agent systems, and the tools I build along the way.