DEV Community

edvatar
edvatar

Posted on

I Built a Tool to Sync Your Claude Code Brain Across Machines

## The Problem Nobody Talks About

If you use Claude Code, you know it gets smarter over time. It builds up memory about your preferences, your codebase
patterns, your debugging tricks. You create custom skills, agents, rules. You write a CLAUDE.md that shapes how it
works.

But all of this is trapped on one machine.

Switch to your laptop? Start from zero.
SSH into a cloud VM? Start from zero.
Got a new desktop? You guessed it.

Your AI coding assistant has amnesia every time you change machines.

## The Solution: claude-brain

I built claude-brain, a Claude Code plugin that makes your brain state portable. It syncs everything — memory,
CLAUDE.md, skills, agents, rules, settings — across all your machines via a private Git repo.

### Setup takes 30 seconds

On your first machine:
/brain-init git@github.com:you/my-brain.git

On every other machine:
/brain-join git@github.com:you/my-brain.git

That's it. Hooks auto-sync on every session start/end. Zero daily effort.

### The Interesting Part: Semantic Merge

The hard problem isn't syncing files — it's merging knowledge.

When Machine A learns "always use pnpm" and Machine B learns "prefer pnpm over npm", a file copy would keep both
(redundant) or overwrite one (data loss). Neither is great.

claude-brain uses a hybrid merge strategy:

  • Structured data (JSON settings, keybindings, MCP configs) → deterministic deep-merge
  • Unstructured data (memory, CLAUDE.md) → LLM-powered semantic merge via claude -p

The semantic merge understands that "always use pnpm" and "prefer pnpm over npm" are the same insight. It
deduplicates, resolves contradictions, and consolidates. The merge agent even maintains persistent memory to improve
over time.

### Features

  • N-way merge — laptop + desktop + cloud VM all converge
  • Encryption — optional age encryption for snapshots at rest
  • Team sharing — share skills and agents (memory stays private)
  • Auto-evolve — promotes stable patterns from memory to durable config
  • Secret scanning — strips API keys, env vars, tokens before export
  • Cheap — ~$0.50-2.00/month for semantic merge API calls

### Built Simple

Pure Bash + jq. No Node, no Python, no Docker. The only dependencies are git, jq, and the claude CLI (which you
already have if you use Claude Code).

## Try It

GitHub: https://github.com/toroleapinc/claude-brain

MIT licensed. Contributions welcome.

If you use Claude Code on multiple machines, give it a try and let me know what you think!

Top comments (0)