Stop Losing Context! Engram Gives AI Agents a Real Brain
You just spent three hours architecting a complex microservices migration with Claude Code. Deep decisions about database sharding, API versioning strategies, failure mode handling—you hashed it all out. The agent nodded along, generated beautiful code, and you called it a day.
Tomorrow morning? Gone. Poof. Tabula rasa. Your AI coding agent stares back with the digital equivalent of a blank expression, asking "What project are we working on?" like an amnesiac goldfish.
Sound familiar? You're not alone. This is the dirty secret of the AI coding revolution: these agents are brilliant in the moment and tragically forgetful the moment your terminal session ends. Every standup, every architecture decision, every "we tried X and it failed because Y"—lost to the void.
But what if your agent could actually remember? Not some hacky prompt injection workaround. Not a bloated cloud service that phones home your proprietary code. A real, persistent, queryable memory system that works with any agent you throw at it.
Enter Engram—the open-source memory layer that transforms your forgetful AI assistant into a coding partner with genuine continuity. One Go binary. One SQLite file. Zero dependencies. Infinite context retention.
This isn't another toy project. This is the infrastructure missing from the entire AI coding ecosystem. And it's about to change how you work forever.
What Is Engram? The Memory Layer AI Coding Desperately Needed
Engram (/ˈen.ɡræm/) takes its name from neuroscience—the physical trace of memory in the brain. Fitting, because that's precisely what it builds for your AI agents: a persistent, structured, searchable engram of everything your coding assistant learns, decides, and discovers.
Created by Gentleman Programming, Engram emerged from a simple, brutal observation: despite all the hype around AI coding agents, none of them could remember what happened ten minutes ago, let alone last week. Claude Code, OpenCode, Gemini CLI, Codex, Cursor, Windsurf—they're all equally amnesiac by default.
The project's philosophy is radical in its simplicity. Where other solutions demand Docker containers, Node.js runtimes, Python environments, or proprietary cloud subscriptions, Engram ships as a single static Go binary with zero runtime dependencies. No npm install. No pip freeze. No docker pull. Download, run, done.
Under the hood, Engram leverages SQLite with FTS5 full-text search—battle-tested technology that powers everything from iPhones to Chrome. Your memories live in ~/.engram/engram.db, a file you own completely. Local-first, optionally cloud-replicated, always queryable.
The architecture is deliberately agent-agnostic. Engram speaks MCP (Model Context Protocol) over stdio, the emerging standard for agent-tool communication. If your agent supports MCP—and virtually all modern ones do—it gets persistent memory. Full stop. No vendor lock-in, no agent-specific plugins to maintain.
What's driving Engram's rapid ascent in the developer community? Three converging forces: the explosion of AI coding agents without memory solutions, growing developer fatigue with cloud-only proprietary tools, and a hunger for local-first infrastructure that respects code privacy. When your memory contains proprietary architecture decisions and security patterns, keeping it on your machine isn't paranoia—it's professionalism.
Key Features: The Technical Depth That Matters
Engram isn't a thin wrapper around SQLite. It's a comprehensive memory operating system with nineteen purpose-built MCP tools, multiple interfaces, and sophisticated data lifecycle management.
SQLite + FTS5 Full-Text Search Engine The core storage layer combines SQLite's ACID reliability with FTS5's advanced text indexing. This means fuzzy matching, prefix searches, and relevance-ranked results across memory titles, content, and metadata. Your agent doesn't need exact keywords—it finds conceptually related memories even with imprecise queries.
Nineteen MCP Tools Across Five Categories
Engram exposes granular memory operations: mem_save and mem_update for persistence; mem_search, mem_context, and mem_timeline for retrieval; mem_session_start and mem_session_end for lifecycle management; mem_judge and mem_compare for conflict detection; plus utilities for stats, passive capture, and project management. This isn't a simple key-value store—it's a structured knowledge system with explicit memory hygiene protocols.
Multi-Modal Interface Architecture
Beyond MCP, Engram provides: an HTTP API (engram serve) for programmatic integration; a CLI for scripting and automation; an interactive TUI (engram tui) with vim keybindings and Catppuccin Mocha theming; and Git sync for compressed, conflict-free memory replication across machines.
Cloud-Optional Replication
Local SQLite remains the authoritative source of truth. Cloud enrollment is strictly opt-in, project-scoped, and never auto-repairs. The engram cloud upgrade state machine provides explicit doctor → repair → bootstrap → status flows for transparent, controlled synchronization.
Conflict Surfacing & Semantic Analysis (Beta)
The bleeding-edge beta introduces automated detection of contradictory memories—when your agent saves "Use Postgres" today and "Switch to MongoDB" tomorrow. FTS5 lexical matching surfaces candidates; optional LLM semantic judgment (via your existing Claude Code or OpenCode subscription, at zero marginal cost) resolves whether relationships constitute supersedes, conflicts_with, or coexistence.
Use Cases: Where Engram Transforms Your Workflow
1. Multi-Session Architecture Preservation
You're designing a distributed system across three days of sporadic Claude Code sessions. Without Engram, you re-explain consensus algorithms, retry policies, and circuit breaker configurations every single time. With Engram, your agent recalls: "We chose Raft over Paxos for operational simplicity, with 150ms heartbeat intervals and leader leases for read throughput." The context surfaces automatically. You iterate, never restart.
2. Team Knowledge Transfer Through Git Sync
Your teammate joins the project. Instead of verbose handoff documents that rot, engram sync exports compressed memory chunks to your repository. They engram sync --import, and their agent inherits the project's accumulated wisdom: deprecated approaches, accepted patterns, security constraints discovered through incident response. The .engram/ directory becomes a living, queryable team brain.
3. Cross-Agent Memory Portability
You prototype with Claude Code's conversational depth, then switch to Cursor for inline editing, then deploy via OpenCode's automation. Without Engram, each transition is a memory reset. With Engram's MCP stdio transport, the same SQLite brain serves all agents. Your context follows you across tools, not the other way around.
4. Retroactive Conflict Detection & Technical Debt Prevention
That beta feature isn't theoretical—it's surgical. When your agent saves "Adopt GraphQL for API layer" in March and "REST simplicity reduces client complexity" in June, Engram's conflict surfacing flags the tension. You review, resolve, document the decision rationale. Six months later, when someone proposes gRPC, the full decision genealogy is searchable. No circular debates, no forgotten constraints.
Step-by-Step Installation & Setup Guide
macOS Installation (Homebrew)
The fastest path to persistent memory:
# Add the tap and install the binary
brew install gentleman-programming/tap/engram
# Verify installation
engram version
Linux & Windows Installation
For Linux binaries, Windows executables, and alternative methods, consult the installation documentation. The project provides pre-built releases for major platforms.
Agent Integration (One-Liner Setup)
| Agent | Command |
|---|---|
| Claude Code | claude plugin marketplace add Gentleman-Programming/engram && claude plugin install engram |
| Pi | engram setup pi |
| OpenCode | engram setup opencode |
| Gemini CLI | engram setup gemini-cli |
| Codex | engram setup codex |
| VS Code | code --add-mcp '{"name":"engram","command":"engram","args":["mcp"]}' |
For Cursor, Windsurf, and other MCP-compatible tools, see the agent setup guide.
Environment Configuration
Engram respects several environment variables for advanced configuration:
# Custom data directory (default: ~/.engram/)
export ENGRAM_DATA_DIR=/path/to/custom/location
# Cloud server endpoint (for opt-in replication)
export ENGRAM_CLOUD_SERVER=http://your-server:18080
# Cloud authentication token
export ENGRAM_CLOUD_TOKEN=your-token-here
# Agent CLI for semantic conflict scanning (beta)
export ENGRAM_AGENT_CLI=claude # or opencode
Local Smoke Test with Cloud
# Start local cloud services
docker compose -f docker-compose.cloud.yml up -d
# Configure and enroll
engram cloud config --server http://127.0.0.1:18080
engram cloud enroll smoke-project
# Verify sync pathway
engram sync --cloud --project smoke-project
REAL Code Examples from the Repository
Example 1: Saving a Memory with Structured Context
The fundamental operation—your agent persists significant work with searchable metadata:
# Save an architecture decision with full structured context
./engram-beta save \
"Use Clean Architecture" \
"Layers: entities, use cases, adapters." \
--type architecture --project beta-test
What's happening here? The save command creates an observation with:
- Title: Human-readable identifier for retrieval
- Message: Detailed content explaining the decision
- Type: Categorical tag (
architecture,decision,bugfix, etc.) - Project: Namespace for isolation and scoping
FTS5 immediately indexes this content. Subsequent searches for "architecture" or "clean" surface this memory with relevance ranking.
Example 2: Conflict Detection Through Contradictory Saves
This is where Engram gets genuinely intelligent—surfacing tensions in your project's evolving knowledge:
# First architectural commitment
./engram-beta save \
"Use Clean Architecture" \
"Layers: entities, use cases, adapters." \
--type architecture --project beta-test
# Contradictory subsequent commitment
./engram-beta save \
"Use Hexagonal Architecture" \
"Ports and adapters separate domain from infra." \
--type architecture --project beta-test
The critical behavior: On the second save, Engram returns candidates[] containing the first memory's ID. Your agent—or you, via the TUI—can now see the tension. Are these complementary (Clean Architecture and Hexagonal share DNA) or conflicting (different directory structures, different dependency rules)? The system surfaces; humans or LLMs judge.
Example 3: Semantic LLM-Powered Conflict Resolution
The beta's killer feature—using your existing AI subscription for zero-cost semantic analysis:
# Configure which agent CLI performs semantic judgment
export ENGRAM_AGENT_CLI=claude # or opencode
# Scan for conflicts with LLM reasoning
./engram-beta conflicts scan --project beta-test --semantic --apply \
--max-semantic 5 --concurrency 3 --yes
Deep dive on this pipeline:
- FTS5 lexical matching identifies candidate pairs sharing terms (e.g., "user" + "database")
- LLM semantic judgment evaluates whether candidates truly conflict, supersede, or coexist
- Concurrency control (
--concurrency 3) parallelizes judgments for throughput --applypersists discovered relationships to the database--yesskips interactive confirmation for automation
The --max-semantic 5 limits LLM calls per run—cost control even when subscription-based. This is $0 marginal cost if you're already on Pro/Max/Plus plans, since it invokes your local CLI, not an API endpoint.
Example 4: Lexical-to-Semantic Conflict Pipeline
This example demonstrates the full intelligence stack—where FTS5's limitations end and LLM judgment begins:
# Save lexically related but semantically conflicting memories
./engram-beta save \
"Use Postgres for the user database" \
"Postgres 15 is our SQL store for users." \
--type architecture --project beta-test
./engram-beta save \
"Replace the user database with MongoDB" \
"Document store now backs the user collection. SQL is gone." \
--type decision --project beta-test
# Execute semantic scan
./engram-beta conflicts scan --project beta-test --semantic --apply \
--max-semantic 5 --yes
# Review judged conflicts
./engram-beta conflicts list --project beta-test --status judged
Critical insight: FTS5 finds these candidates through shared terms "user" and "database"—pure lexical overlap. But the semantic LLM recognizes the operational contradiction: one mandates SQL, the other explicitly retires SQL. The judgment supersedes or conflicts_with emerges from meaning, not keyword matching. Note the README's honest limitation: --semantic "does not discover totally lexically unrelated pairs on its own." This is architecturally correct—FTS5 for recall, LLM for precision.
Example 5: Git-Based Memory Replication
For teams and multi-machine workflows:
# Export new memories as compressed chunk
engram sync
# Commit to repository for team sharing
git add .engram/ && git commit -m "sync engram memories"
# On another machine: import new chunks
engram sync --import
# Verify sync status
engram sync --status
Why compressed chunks? The README emphasizes "no merge conflicts, no huge files." Engram's sync format is append-only compressed chunks, not raw SQLite dumps. Multiple developers can sync independently; imports are idempotent. Your .engram/ directory stays <1MB even for months of active development.
Advanced Usage & Best Practices
Memory Hygiene with the What/Why/Where/Learned Protocol The architecture documentation specifies a structured memory format. Train your agent to save with explicit sections: What was decided, Why it was chosen, Where it applies, and What was learned from alternatives rejected. This transforms search from keyword guessing to structured querying.
Session Lifecycle Management
Explicit mem_session_start and mem_session_end calls create temporal boundaries. Use mem_session_summary for automatic condensation of lengthy sessions. This prevents context bloat—your agent retrieves relevant decisions, not every intermediate thought.
Project Consolidation for Long-Term Maintenance
The engram projects consolidate command merges related project namespaces. After six months of backend-v2, backend-v2-refactor, and backend-v2-prod, consolidate for unified search. Prune abandoned experiments with engram projects prune.
Passive Capture Without Agent Action
The mem_capture_passive utility (via MCP) enables automatic memory creation from significant file changes, test failures, or deployment events. Configure your CI to call this—build breakage patterns become searchable institutional knowledge.
Cloud Upgrade Safety
Never auto-apply repairs. The prescribed flow—doctor (read-only check) → repair --dry-run → repair --apply → bootstrap → status—ensures you understand changes before they touch data. For blocked sync, the rescue helper tools/repair-missing-session-directory.sh with --fix-exported handles edge cases the main flow misses.
Comparison with Alternatives
| Dimension | Engram | claude-mem | Proprietary Cloud Memory |
|---|---|---|---|
| Agent Support | Any MCP-compatible | Claude-specific | Vendor-locked |
| Deployment | Single Go binary, zero deps | Node.js/Python stack | SaaS subscription |
| Data Ownership | Local SQLite, you own it | Local files | Cloud-hosted, opaque |
| Search Technology | SQLite + FTS5 | Basic text search | Unknown/undisclosed |
| Conflict Detection | FTS5 + LLM semantic (beta) | None | None or basic |
| Team Sync | Git-based compressed chunks | Manual export/import | Proprietary collaboration |
| Interface Variety | MCP, HTTP API, CLI, TUI | Limited | Web-only or agent-only |
| Cost Model | Free, open-source | Free | Subscription tiers |
Why Engram wins: It's the only solution combining universal agent compatibility, local-first data sovereignty, sophisticated search, team synchronization without vendor lock-in, and zero runtime dependencies. The trade-off? You manage the binary. For professional developers, that's a feature, not a bug.
FAQ
Does Engram work with my specific AI agent?
If your agent supports MCP (Model Context Protocol), yes. Verified: Claude Code, OpenCode, Gemini CLI, Codex, VS Code Copilot, Cursor, Windsurf, Antigravity, and Pi. The engram setup [agent] command configures most automatically.
Where is my data actually stored?
Locally in ~/.engram/engram.db (SQLite). Cloud replication is strictly opt-in; the local file remains authoritative. You can inspect, backup, and migrate it with standard SQLite tools.
How does Engram differ from just using Git commit history? Git records what changed. Engram records why it changed, what was considered and rejected, and how decisions relate. It's searchable institutional knowledge, not code archaeology.
Is the cloud feature secure for proprietary code? Cloud is optional. When used, it's project-scoped with explicit enrollment. The sync protocol uses compressed chunks, not raw code. For maximum security, run local-only or self-host the cloud components via Docker Compose.
What happens when Engram updates?
Restart your MCP client after updating the binary. The engram setup claude-code (or your agent) refreshes hook files. The running stdio MCP process doesn't auto-update—this prevents mid-session crashes.
Can I export memories to other tools?
Yes. engram export produces JSON. engram obsidian-export (beta) generates an Obsidian knowledge graph. The SQLite schema is documented for custom integrations.
How do I handle memory bloat over months?
The mem_session_summary tool condenses sessions. mem_merge_projects consolidates namespaces. mem_stats reveals growth patterns. For aggressive cleanup, mem_delete removes specific observations or you can vacuum the SQLite file directly.
Conclusion: The Memory Infrastructure AI Coding Has Been Missing
We've accepted amnesiac AI agents as inevitable. Every session, we re-teach, re-contextualize, re-decide. It's the silent tax on AI-assisted development—a 20-30% productivity bleed that feels normal only because we've never had an alternative.
Engram changes the equation entirely.
One Go binary. One SQLite file. Nineteen precision-engineered MCP tools. Universal agent compatibility. Local-first sovereignty with optional cloud replication. Full-text search that actually finds what you mean. Conflict detection that prevents architectural drift. Git sync that turns personal memory into team intelligence.
This isn't a productivity tool. It's infrastructure—the missing layer that makes AI agents actually viable for serious, sustained development work. The neuroscience-inspired naming isn't marketing fluff. It's a declaration of intent: your agent deserves a real brain, not a goldfish bowl.
The beta's semantic conflict surfacing hints at even deeper possibilities. When your AI can recognize its own contradictions, query its decision genealogy, and learn from rejected alternatives, we're approaching something genuinely new in human-computer collaboration.
Stop restarting. Stop re-explaining. Stop forgetting.
Install Engram today. Give your agent the memory it deserves. Your future self—and your teammates—will thank you.
👉 Get Engram on GitHub — star the repo, try the quick start, and join the growing community of developers who refuse to let their AI's best work vanish into the void.
One brain. Local or cloud. Agent-agnostic, single binary, zero dependencies. This is how AI coding was meant to work.