Memory for
AI Agents

Hierarchical, file-system-based memory inspired by human neuroscience. Agents remember decisions, learn from experience, and build expertise across sessions.

Get Started
npm versionCIlicense

Features

Hierarchical Memory

The directory tree is the semantic structure. Browsable in any file explorer.

Strength & Decay

Memories fade over time. Recalled memories strengthen. Ebbinghaus forgetting curve.

Associative Network

Weighted connections between memories. Recalling one activates related ones.

Spaced Reinforcement

Longer recall intervals produce larger boosts. Diminishing returns on cramming.

Cognitive Types

Episodic, semantic, and procedural memories each decay differently.

Cross-Agent

Claude Code, Gemini CLI, and Codex CLI. One brain, all agents.

Sleep & Consolidation

9-phase maintenance cycle: replay, consolidation, pruning, reorganization.

Portable Sync

Git remote or encrypted export/import across devices.

How it works

Create
Store
Decay
Recall
Reinforce
Review
Sleep
Archive

Memories are Markdown files with YAML frontmatter. They decay following Ebbinghaus's forgetting curve, strengthen through spaced recall, and consolidate during sleep cycles. Weak memories are archived automatically.

Benchmark results

Tested across Claude Code, Gemini CLI, and Codex CLI. Full methodology

+18.3%
Average Consistency Improvement
+33.3%
Success Improvement
3 / 3
Agents Improved
ScenarioConsistencySuccess
Preference Retention
Preferences applied without re-stating
+34.7%+33.3%
Multi-Session Continuity
Decisions carry across sessions
+26.2%
Accumulated Knowledge
5 sessions of learning improve output
+7.3%
Error Pattern Learning
Past debugging helps fix similar bugs
+4.8%
Cross-Agent Consistency
All agents follow the same memorized style
inconclusive

Per-Agent Results

Scenario+Brain-BrainChangeTokens (+/-)Time (+/-)Notes
Continuity0.9440.645+46.4%223K / 211K108s / 98s
Consistency0.4000.400133K / 125K103s / 89s
Knowledge1.0000.891+12.2%511K / 312K159s / 130s
Error Learning0.5700.570248K / 141K228s / 203s100% vs 67%
Preferences0.8660.359+141.2%134K / 125K106s / 93sPASS vs FAIL

Each scenario ran 3 times with median values reported. Default cloud models used for all agents.

Neuroscience foundations

Brain MechanismImplementation
Spreading activationRecalling memory A automatically surfaces linked memories B and C
Hebbian learningMemories recalled together strengthen mutual links
Context-dependent recallMemories encoded in similar context score higher
Spacing effectLonger recall intervals produce larger strength boosts
Ebbinghaus decayExponential forgetting with per-memory decay rates
Synaptic homeostasisGlobal strength downscaling during sleep prevents inflation

Compatibility

Claude Code

Anthropic

npx brain-memory --claude --global

Gemini CLI

Google

npx brain-memory --gemini --global

OpenAI Codex CLI

OpenAI

npx brain-memory --codex --global

Quick start

npx brain-memory@beta

Interactive installer. Configures the selected runtime(s) globally or per-project.