Open source Apache-2.0

Git-tracked memory for Claude Code and Cursor.

Extract quoted notes from the chats already on your laptop. Review and share them through git. When an anchored file changes, Midbar withholds its note.

Local. No account. No model calls.

Try the demo InstallGitHub

api/auth/login.py
def login(request):
    user = authenticate(request)
    target = request.args.get("next", "/")
    if not target.startswith("http"):
        return redirect(target)
    response = redirect(target)
    response.set_cookie("session", user.session_id)
    return response
.midbar/memory.jsonlcurrent
The login handler returns before the session cookie is set when the redirect target is relative.
Kind
file
Learned from
Dana’s chat in Claude Code
Given to agents
Yes
File now7e5c46ad=Learned with7e5c46adHanded to the agent
Apply the fix to see the check. An example file and note. Both hashes are the real git hashes of its two versions.
History import and hooks
  • Claude Code
  • Cursor
MCP tools
  • Codex CLI
  • Cline
  • Windsurf

In Cursor, notes reach the agent at its next tool call, not when the prompt is sent.

The problem

Your agents keep relearning what your team already found out.

Earlier chats in this repo found how the deploy script really works and were told “never push to main without asking”. None of that reaches the next chat, or a teammate’s. Memory tools that do carry it over hand last month’s note to the agent as fact, after the code has moved on.

How it works

Three steps, and two of them are git.

  1. 01

    Learn

    Reads the Claude Code and Cursor chats on your laptop for this repo and keeps what they found, quoted. No model, no account.

    midbar learn
  2. 02

    Review and commit

    The memory is one file in the repo. Read it like a pull request, drop what is wrong with midbar forget, then commit.

    git diff .midbar
  3. 03

    Every agent gets it

    Teammates in Cursor or Claude Code get the same memory, checked against their checkout before their agent sees it.

    git pull

The check

What “checked against your code” means, and what it does not.

A note about a file carries that file’s git hash from when it was learned. Before an agent gets the note, Midbar hashes the file in your checkout again, and checks that every function, path or script the note names is still in the code. Deterministic for the same memory records and checkout.

Unchanged is not correct

A matching hash says the file is what the note was learned against. It does not say the note was right. That is why you read git diff .midbar before you commit, like code.

Whole file, on purpose

Any change to the file withholds the note, even one that does not touch what it says. Some notes that still hold get dropped. We chose that over handing over ones that do not.

Already said stays said

If an agent edits a file after it got the note, the note stays in that chat. Midbar cannot take it back. No later chat gets it, and midbar stale lists it to check or forget.

Where the hash comes from for an old chat

Midbar does not rebuild old versions of a file. It keeps a note only when it can show the file is still what the chat saw: the file is line for line what a Claude Code chat last read, or it has not been modified since the chat’s last message. Then it hashes the file as it is now. If neither holds, it cannot know what the chat read, so the note is left out.

This errs toward dropping. Cursor does not store what a read returned, so after a fresh clone or a branch switch, which rewrite modified times, notes from earlier Cursor chats are left out.

  1. kept

    The chat ended on Tuesday. api/auth/login.py was last modified on Monday. The note is recorded with the hash of the file as it is today.

  2. left out

    The chat ended on Tuesday. jobs/queue.py was modified on Thursday and no longer matches what the chat read. No hash is recorded, and midbar learn counts the note as already out of date.

What a memory is

One line of JSON, in your repo, reviewed like code.

The memory is a single file, .midbar/memory.jsonl, sorted, one memory per line. Line-oriented records produce reviewable diffs and merge through git. Nothing is a vector or a graph you cannot read.

kind
A note about a file, a decision, a rule the team set, or how an error was fixed.
text
Quoted from the chat, with keys, tokens and passwords replaced by [redacted].
anchors
The files it is about, each with its git hash when the note was recorded.
source
Who learned it and the exact message it came from, so you can always check.
.midbar/memory.jsonl
{
  "anchors": {
    "api/auth/login.py": "7e5c46ad..."
  },
  "id": "4b7e21c0a913",
  "kind": "file",
  "source": {
    "by": "Dana",
    "chat": "3f2a91c0",
    "item": "a15",
    "tool": "claude"
  },
  "text": "The login handler returns before the session cookie is set when the redirect target is relative."
}
Illustration, not a real memory. Spread out here; in the file it is one line.

Where agents get it

At the moment it matters, without being asked.

You do not have to tell the agent to search. Midbar hooks into Cursor and Claude Code and adds a few lines at four moments.

  1. A new chat starts

    The rules the team set and the latest decisions that still hold, in a few lines.

    midbarTeam memory: Never push to main without asking. The job queue runs on Postgres, not Redis.
  2. The agent reads a file

    The team's note about that file, once per chat, only while the file is unchanged.

    midbarNote on api/auth/login.py: The login handler returns before the session cookie is set when the redirect target is relative.
  3. Before a risky command

    Push, deploy, publish and delete are checked against the team's rules. A match stops and asks you.

    midbarMidbar: the team memory says "Never push to main without asking." This command would push.
  4. A command fails

    What fixed the same error before, from the team memory and from your own chats.

    midbarFixed before: the test database was not migrated. Running make migrate-test first made the suite pass.

Sample text is an illustration of the format. Codex CLI, Cline and Windsurf get the same memory through MCP tools.

Compared

Next to what you already use.

Midbar does not replace your rule files, and git alone keeps the code’s history, not what the chats found about it. What Midbar adds: each note links to the chat it came from, lives in a file you review, and is withheld once its file changes.

QuestionCLAUDE.md, AGENTS.md, rulesClaude Code auto memoryMem0 (hosted or self-hosted)Midbar
Who writes itMaintained by you or your agentClaude, as it worksA model, from conversationsRules over the chats you already had
Where it livesYour repoYour machine, outside the repoTheir cloud or your serverYour repo, one file
Where each item came fromGit blame of the linePlain notes, no link to the source messageMetadata you attachThe chat and message it quotes
When the code changesNo automatic file-hash checkNo automatic file-hash checkNo file-hash checkWithheld once its file changes
Shared with the teamThrough gitNot shared, local to one machineThrough the serviceThrough git, reviewed as a diff

Privacy

Your chats stay on your laptop.

  • Raw chats never leave the laptop that had them.
  • Only the short quotes midbar learn picked go into the repo, secrets redacted, and only when you commit them.
  • No server, no account, no telemetry, no model calls. Read every line in git diff .midbar first.

Known limits

What it does not do yet.

  • Learning is rules over text, not a model. It misses some things and keeps some noise, so review the diff before you commit.
  • A rule that names no file or code, like "never push to main without asking", is current until replaced. One that names retry_send or jobs/queue.py goes stale once that is gone.
  • It learns from chats on the laptop that had them. Each teammate runs midbar learn for their own chats.
  • Cursor cannot add context when a prompt is submitted, so notes reach the agent at its next tool call.
  • Built and used on macOS. Tests run on Linux too; Windows is untested.

Questions

Common questions.

What is Midbar?

A free, open-source memory for coding agents. midbar learn reads the Claude Code and Cursor chats you already had in a repo and keeps what they found (notes about files, decisions, rules the team set, how errors were fixed) as short quotes in .midbar/memory.jsonl. Each memory about a file carries that file's git hash, so Midbar can tell when the code has changed under it.

How do I install it?

Run uv tool install git+https://github.com/midbar-ai/midbar && midbar setup, or the same with pipx install. Both keep the midbar command installed. Setup finds Cursor and Claude Code, shows what it will change and asks once. Then run midbar learn in your repo, review git diff .midbar and commit it.

How does my team get it?

Through git. The memory is one file in the repo, one line per memory, sorted, with a union merge set in .gitattributes. Line-oriented records produce reviewable diffs and merge through git. Teammates get it with git pull, whether they use Cursor or Claude Code.

What happens when the code changes?

Before an agent gets a memory about a file, Midbar hashes the file again. If it no longer matches the hash the memory was learned with, the memory is held back and listed by midbar stale. A rule that names a function, an env var, a script or a path is held back once that name is gone from the code. It is a content hash and a git grep: deterministic for the same memory records and checkout, with no server and no clock. A matching hash means the file is unchanged, not that the note was right, so review notes before you commit them. A note an agent already got stays in that chat; later chats do not get it.

How does a note from an old chat get its file hash?

Midbar does not rebuild old versions of a file. midbar learn keeps a note only when it can show the file is still what the chat saw. For a Claude Code chat, the transcript holds what each file read returned, so if the file is line for line what the chat last read, the note is kept with the file's hash as it is now. Otherwise Midbar compares the file's modified time with the chat's last message: not modified since, the note is kept. If neither holds, Midbar cannot know what the chat read, so the note is left out and counted as already out of date. Cursor does not store what a read returned, so after a fresh clone or a branch switch, which rewrite modified times, notes from earlier Cursor chats are left out.

Does my chat history leave my machine?

No. Raw chats stay on the laptop that had them. Only the short quotes midbar learn picked, with API keys, tokens and passwords replaced by [redacted], go into .midbar/memory.jsonl, and nothing leaves your machine until you commit and push it. No server, no account, no telemetry.

How is it different from CLAUDE.md or Cursor rules?

Rule files hold what someone chose to write down, and nothing tells you when they stop being true. Midbar starts from what the chats actually found, quotes them with a link to the message, and withholds a note once the file it describes has changed. It does not replace your rule files; agents get both.

What if a memory is wrong?

Review the diff before you commit, like code. midbar forget ID drops a memory, and a later decision or rule replaces an earlier one. Learning is rules over text, not a model, so it misses some things and keeps some noise.

What does it cost?

Nothing. It is open source under Apache-2.0, needs no account and calls no model.

Install

Try it on the repo you are in.

Setup finds Cursor and Claude Code, shows what it will change, and asks once. --dry-run changes nothing.

uv tool install git+https://github.com/midbar-ai/midbar && midbar setup

No uv? pipx install git+https://github.com/midbar-ai/midbar && midbar setup. Either way the midbar command stays installed. Needs Python 3.10 or later and git.

Then, in your repo: midbar learn, review git diff .midbar, commit.

Or paste this into Claude Code or Cursor:

Install Midbar (https://github.com/midbar-ai/midbar) in this project. Follow https://midbar.ai/llms.txt: show me what setup will change with --dry-run, then run it, fix anything midbar doctor reports, and run midbar learn in this repo.