Local-First AI Memory System for Coding Agents
A local-first AI memory system that gives your coding agents persistent, searchable, tamper-evident memory across sessions—with zero cloud dependencies.
# 1. Install via Homebrew
brew install bonjoski/tap/coppermind
# 2. Verify your local SQLite WAL vault (zero cloud config needed)
coppermind doctor --strict && coppermind status
# 3. Store and recall a durable architectural invariant (supports '-' stdin piping)
coppermind remember --category architecture "Serialize SQLite WAL writes through a single-writer channel."
coppermind recall --why "How are SQLite writes serialized?"
# 4. Compile a <8ms, <=800-token deterministic brief for your coding agent
coppermind brief --json
# 5. Mount in Claude Code / Cursor / Antigravity over MCP STDIO
coppermind mcpQuick tips: Run
coppermind --helpfor the 5-tier workflow command guide,coppermind <cmd> --helpfor any subcommand, orcoppermind completion zshfor shell completions.
In Brandon Sanderson's Mistborn, Feruchemists store memories inside copper metalminds and tap them later with perfect fidelity.
Coppermind is a local-first, self-sovereign AI memory system built as an MCP-native daemon. It solves the "amnesiac agent" problem by giving AI coding agents (Claude Code, Cursor, Antigravity, OpenCode, Aider) persistent, searchable, tamper-evident memory—combining SQLite/pgvector hybrid search, a lightweight knowledge graph, a fast working scratchpad, signed memory cartridges, and host-evaluated memory lenses—running 100% locally on developer workstations or in an optional self-hosted Docker stack.
flowchart TD
subgraph ClientPlane ["Client & Agent Plane"]
Agents["AI Agents & IDEs<br/>(Claude Code, Cursor, Antigravity)"]
end
subgraph CoppermindRuntime ["Coppermind MCP Core (Go 1.27+)"]
MCP["MCP JSON-RPC 2.0 Engine<br/>(STDIO / SSE / UDS)"]
subgraph MemoryTiers ["Multi-Tier Memory Hierarchy"]
Working["Working Memory Tier<br/>(Fast In-Memory Scratchpad & Mutexes)"]
Episodic["Episodic Memory Tier<br/>(Chronological Logs & Commit History)"]
Semantic["Semantic Memory Tier<br/>(Hybrid Vector + BM25 Search & Knowledge Graph)"]
end
subgraph StorageCore ["Storage Engine"]
SQLite["Pure-Go SQLite (WAL Mode)<br/>(Single-Writer Ring + Parallel Reader Pool)"]
end
end
Agents <-->|"MCP Tools (coppermind_*)"| MCP
MCP --> MemoryTiers
MemoryTiers --> StorageCore
-
MCP-Native First: Exposes standard Model Context Protocol tools (
coppermind_remember,coppermind_recall,coppermind_scratchpad,coppermind_dispatch_task,coppermind_status,coppermind_lens_prepare/submit,coppermind_consolidate_prepare/submit) directly over STDIO, allowing instant mounting in any IDE agent configuration. - Zero Hop Tax & Sub-10ms Latency: Connects over persistent STDIO or Unix Domain Sockets; eliminates intermediate CLI wrapper latency.
-
Multi-Agent Concurrency (
$N=8$ Stress-Tested): Features a single-writer channel worker with SQLite Write-Ahead Logging (WAL mode), enabling 8+ parallel subagents to store, search, and lock memory without database collisions or lock timeouts. - Memory Firewall & Taint Defense: Normalizes all inbound memories via NFKC Unicode decomposition and strips invisible zero-width characters (OWASP LLM01 indirect prompt injection defense).
-
Absolute Secret & Credential Quarantine: Strict fail-closed defense scanning for private keys, AWS/OpenAI/Anthropic/GitHub API keys, and high-entropy tokens. Raw keys are rejected with typed security errors, and embedded tokens are redacted (
[REDACTED_*]) before reaching SQLite or vector embeddings. -
Asynchronous AMQP / RabbitMQ Task Engine: Dispatches background memory workflows (
deep_reflect,summarize_session,defrag_memory) onto an embedded topic bus or external RabbitMQ cluster (COPPERMIND_RABBITMQ_URL). - LiteLLM Model Router: Optional upstream reflection and synthesis router with outbound API key scrubbing on upstream HTTP error frames.
-
Memory Lenses: Event-driven and zero-API-key host-evaluated analytical personas (
red-team,security-architect,systems-architect,drift-auditor,synthesizer,devils-advocate) that evaluate stored memories and code diffs and persist structured observations back into project vaults without recursive loops.
Memory Lenses provide continuous analytical evaluation of project memories via configurable personas:
red-team: Aggressively attacks code, configurations, and sandbox policies from an adversary's mindset; identifies concrete exploit vectors, sandbox escapes (Seatbelt/Landlock/seccomp), TOCTOU symlink races, parameter injections, and token replay.security-architect: Audits code diffs, command executions, and configuration changes for OWASP vulnerabilities, credential exposure, unsafe syscalls, and privilege escalation vectors.systems-architect: Analyzes architectural coherence, modularity, single-responsibility invariants, and multi-agent concurrency bottlenecks.drift-auditor: Detects drift between architectural specifications/docs and live implementations, flagging regressions and configuration drift.synthesizer: Cross-correlates memories across sessions, distilling high-level decisions, patterns, and overarching system state.devils-advocate: Stress-tests technical decisions, ADRs, and plans; highlights single-points-of-failure, scalability walls, and unexamined tradeoffs.
- Zero-Cost Pre-Filter Gates: Fast regex/AST matching (e.g. scanning for
exec,syscall,unsafe, credentials) skips 85%+ of candidate memories before invoking LLMs, preserving local VRAM and CPU. - OWASP LLM01 Prompt Injection Defense: Candidate memories and code diffs are fenced inside
<untrusted_artifact id="...">...</untrusted_artifact>tags with strict system directives instructing the model to treat contents strictly as data, never directives. - Loop Prevention (
derived=true): Lenses write observations withderived=true. The memory manager and topic bus guarantee that derived records never emitingest.*orepisodic.*events, making recursive trigger cascades structurally impossible. - Deterministic Deduplication: Computes
SHA256(project + ":" + lens_name + ":" + target_hash + ":" + summary)to skip duplicate observations and eliminate alert fatigue. - Append-Only Authority: Lenses create observations and resolve existing observations from the same lens; they can never alter or delete canonical memories.
Lenses are declaratively configured with sensible embedded defaults when the file is absent:
version: "1"
lenses:
- name: "security-architect"
model: "local-coder"
subscribe:
- "episodic.commit"
- "ingest.code"
- "dispatch.deep_reflect"
recall_categories:
- "architecture"
- "security"
- "invariant"
prefilter_regex: "(?i)(exec|unsafe|syscall|os\\.Open|crypto|socket|eval|password|secret|token|api_key|auth|chmod|chown)"
system_prompt: |
You are the Lead Security Architect. Analyze the provided untrusted artifact for vulnerabilities.
Respond strictly in JSON: {"findings": [{"severity": "high", "category": "security", "summary": "...", "evidence": "..."}]}# Trigger deep reflection using a specific lens or all lenses
coppermind dispatch reflect --lens security-architect --since 24h
coppermind dispatch reflect --lens devils-advocate --since 24h
# Recall memories and filter strictly to observations from a specific lens
coppermind recall --lens security-architect "command execution"
# Recall canonical memories with linked memory lens observations automatically attached (default)
coppermind recall --include-observations "sandbox configuration"
# Inspect and resolve open memory lens observations
coppermind observations --status open --min-severity high
coppermind observations --resolve <observation-id>
# Automated Git Post-Commit Hook with background lens evaluation
coppermind hook install
coppermind hook checkIn MCP:
coppermind_recallaccepts optionallens(string filter),include_observations(bool, defaulttrue),session_id(string), andemit_receipt(bool).- Zero-API-Key Host-Evaluated Lenses & MCP Prompts: Coppermind advertises
capabilities.prompts(prompts/list&prompts/getexposing/coppermind:security-audit,/coppermind:systems-audit, and/coppermind:drift-audit) pluscoppermind_lens_prepareandcoppermind_lens_submit. Your active IDE AI subscription evaluates fenced<untrusted_artifact>bundles with zero extra API keys or Ollama RAM, while Coppermind deterministically enforces HMAC-SHA256 single-useeval_tokenvalidation, NFKC/secret quarantine,EnforcePoCGate, SHA-256 deduplication,TIER_3_DERIVEDstorage, and optionalBLPR-v1receipts. - BLPR-v1 Ideation Receipts: When
FABRIAL_RECEIPT_DIRis set andemit_receipt: trueis passed tocoppermind_recall(especially withlens="mentor"orlens="requirements"), Coppermind atomically writes aBLPR-v1DSSE / in-toto Statement v1 receipt (producer.tool: "coppermind",producer.stage: "ideation",claims: {lens, results_count, open_high_observations}) viaos.OpenRoot(O_NOFOLLOW,0600), signs it viaLOCKSMITH_SOCKET(action: "sign_dsse") when reachable, and linksCONJOINER_SIR_IDintoparent_receipts/claims. Symlinked receipt directories fail closed (exit_code: 10). - UB-MCP-v1 Structured Errors: Quarantine, memory firewall, validation, and receipt policy denials return MCP
CallToolResult(isError: true) with ANSI-sanitized calm<=3-line text incontent[0].textand machine-readablestructuredContentconforming toub-mcp-v1-error.schema.json(schema_version: "ub-cli-v2",tool: "coppermind",exit_code: 10). coppermind_dispatch_taskacceptstask="reflect"with optionallensargument.- On
coppermind mcpstartup, the active project's scratchpad is automatically seeded with the top 3 unresolvedhigh/criticalobservations.
# Via Homebrew Tap (Recommended)
brew tap bonjoski/tap
brew install coppermind
# Or build from source with Go 1.27+
go build -o bin/coppermind ./cmd/coppermind
cp bin/coppermind ~/.local/bin/coppermind# Manage isolated project vaults (0% cross-contamination)
coppermind project list
coppermind project use personal
coppermind --project personal remember --category "family" "Bailey the dog is allergic to chicken"
coppermind --project personal recall "What is Bailey allergic to?"
# Store an architectural invariant into default (github) vault
coppermind remember --category architecture "Always use Go 1.27 pure-Go SQLite with WAL mode"
# Semantic and BM25 hybrid recall using natural language query
coppermind recall "What database engine and journal mode do we use?"
# Fast in-memory scratchpad operations
coppermind scratchpad set active_task "Refactor auth middleware"
coppermind scratchpad get active_task
coppermind scratchpad keys
# Install automated episodic git commit hook in current repository
coppermind hook install
coppermind hook status
# Run background reflection or memory defragmentation
coppermind dispatch summarize_session
coppermind dispatch extract_decisions
coppermind dispatch defrag_memory
# Purge expired TTL nodes and compact database
coppermind vacuum
# Run 10-pillar diagnostic inspection
coppermind doctor
# Memory system health and metrics
coppermind statusCoppermind separates hard isolation from layered inheritance:
- Projects (
--project) are flat, isolated vaults (e.g.,githubvspersonal— separate databases, 0% sharing). You do not create child projects. - Scopes (
--scope) form a slash-delimited hierarchy inside a single project vault (<parent>/<child>/<grandchild>, e.g.,platform→platform/payments→platform/payments/webhooks). - No
createcommand is needed: a child scope is created implicitly the first time you store a memory with--scopeor declare it in.coppermind.yaml.
- Lowercase ASCII segments separated by
/:^[a-z0-9][a-z0-9._-]{0,31}$(max 32 chars/segment, max depth8, max length128bytes). - Leading/trailing
/,//,.,.., spaces, wildcards (*,%), and non-ASCII characters are rejected fail-closed.
Commit a .coppermind.yaml at the root of each child repository so CLI commands, git hooks, and MCP calls auto-resolve the scope:
scope: platform/payments
# Optional: map subdirectories to deeper child or sibling scopes
paths:
services/webhooks: platform/payments/webhooks
docs/runbooks: platform/runbooksStrict Allowlist: Only
scopeandpathsare permitted keys in.coppermind.yaml(unknown keys likeproject:fail closed). Symlinks and files over16 KiBare rejected.
# 1. Write org/platform-wide guidance into the parent scope
coppermind --project acme remember --scope platform --category architecture \
"All HTTP services must propagate X-Request-ID."
# 2. Write component-specific guidance into a child scope
coppermind --project acme remember --scope platform/payments/webhooks --category convention \
"Verify Stripe-Signature over raw unparsed bytes before JSON decoding."
# 3. Recall from the child scope (default --scope-mode: ancestors)
# Inherits vault-global + platform + platform/payments + exact; excludes sibling scopes
coppermind --project acme recall --scope platform/payments/webhooks "request logging and signatures"
# 4. Inspect existing scopes and inheritance chains
coppermind --project acme scope list
coppermind --project acme scope show platform/payments/webhooks- Resolution Precedence:
--scopeflag (or MCPscope) →COPPERMIND_SCOPEenv var → nearest.coppermind.yamlinside the git repo root →""(vault-global). - Recall Modes (
--scope-mode):ancestors(default),exact,subtree(target + descendants),lineage(ancestors + descendants),all. - See the full guide: Use Case 11: Hierarchical Platform Scopes.
Every primary developer use case is backed by dedicated, copy-pasteable recipes in docs/use-cases/:
| Use Case | Scenario & Quick Recipe | Full Guide |
|---|---|---|
| Cross-Session Persistent Memory & Retrieval | Store and query architectural facts via hybrid vector search:coppermind remember && coppermind recall "<query>" |
Guide |
| Security Mentor Capsules for AI & Web Apps | Zero-config 18 embedded v1.0 mentor cards (<= 120-token passive nudges out of the box), plus Ed25519 capsule signing and lesson distillation:coppermind recall --lens mentor "RAG prompt"coppermind capsule keygen --out ./keys && coppermind capsule sign --in capsules/ai-app-and-rag-safety.mentor.json --key ./keys/ed25519.keycoppermind distill --from-file lesson-to-capsule.md --out-dir ./distilled |
Guide |
| Product Owner Abuse-Case Acceptance Criteria | Generate <= 3 jargon-free Given / When / Then safety acceptance criteria (<= 180 tokens, ephemeral) from a user story or 5-Q triggers:coppermind requirements --story "AI refund assistant" --triggers ai_rag_context,ai_state_mutation |
Guide |
| Automated Git Post-Commit Reflection | Ingest commit diffs and flag architectural drifts automatically:coppermind hook install && coppermind observations |
Guide |
| Multi-Perspective Analytical Threat Lenses | Stress-test RFCs with automated Devil's Advocate and Red Team lenses:coppermind radar --lenses all --file <doc> |
Guide |
| Zero-API-Key Host-Evaluated Lenses | Run security, systems, and ADR drift audits using your active IDE AI subscription (0 extra API keys, 0 Ollama RAM):/coppermind:security-audit or coppermind_lens_prepare → coppermind_lens_submit |
Guide |
| Exporting Signed Knowledge Capsules | Create immutable, signed .capsule archives linking memory to release tags:coppermind export-capsule --sign |
Guide |
| Episodic Scratchpad Integrity & Observation Quarantine | Verify Ed25519 signatures, defang XML tool reflections, and quarantine untrusted observations:coppermind remember && coppermind recall |
Guide |
| Pure-Go Static Neural Recall & Temporal Filtering | Install offline CMVEC1 embeddings, reindex in micro-batches, and run temporal recall with --explain:coppermind models pull sovereign-dev-256 && coppermind reindex-vectors && coppermind recall --since 7d --explain "<query>" |
Guide |
| Knowledge Graph Impact & Incremental AST Indexing | AST-chunk Go/Markdown incrementally without Merkle breaks and trace file impact:coppermind index . && coppermind graph impact pkg/mcp/server.go |
Guide |
<8ms Context Briefs, MCP Resources & Zero-Key Sleep Cycle |
Compile <=800-token workspace briefs, manage pending commit inbox, and consolidate episodic trails:coppermind brief && coppermind inbox list + /coppermind:consolidate |
Guide |
Mergeable Cartridges & Local Memory Explorer (tui/ui) |
Export/merge selective Ed25519 .capsule v2 packs and inspect your memory vault locally on 127.0.0.1:coppermind capsule export --repo fabrial --tier TIER_1_ARCHITECTURE --out pack.capsule && coppermind capsule inspect pack.capsule && coppermind ui |
Guide |
| Obsidian/ADR Vault Watcher, Git-Tag Recall & Flightdeck Post-Mortems | Read-only hash-incremental Markdown/Obsidian [[wikilink]] sync, --since v0.5.0 git-tag recall, Memory Explorer v2 timeline/lineage, and Flightdeck trace ingestion:coppermind --project personal watch --once ~/Obsidian && coppermind recall --since v0.7.0 "<q>" && coppermind ingest-flightdeck trace.jsonl |
Guide |
| Hierarchical Platform Scopes & Inherited Knowledge | Layer platform-wide guidance (platform) with component specifics (platform/payments/webhooks) inside one vault with default ancestor inheritance, sibling exclusion, .coppermind.yaml auto-scoping, and Merkle v2 scope tamper detection:coppermind remember --scope platform/payments/webhooks "..." && coppermind recall --scope platform/payments/webhooks "<q>" && coppermind scope list |
Guide |
| Vault Diagnostics, Scope Modes, Watcher, Tinmind & Explorer Curation | Unified status/doctor (--fix, --strict, --json), --scope-mode + --why provenance, CI-safe watch --once, bounded ingest-tinmind, and tui/ui curation:coppermind status --json && coppermind doctor --strict --json && coppermind brief --scope-mode ancestors --why --json |
Guide |
Add Coppermind to your agent's MCP configuration (mcp_config.json or claude_desktop_config.json):
{
"mcpServers": {
"coppermind": {
"command": "coppermind",
"args": ["mcp"]
}
}
}Coppermind is engineered primarily as a 100% local, single-developer workstation micro-appliance (Profile A, zero external dependencies) with an optional self-hosted local container stack (Profile B) for personal homelab/PostgreSQL pgvector experimentation.
| Architectural Component | Profile A: Local Micro-Appliance (Default) | Profile B: Optional Self-Hosted Docker Stack |
|---|---|---|
| Target Workload | Individual developer workstations & local agent sessions | Local Docker Compose / personal homelab pgvector testing |
| Activation Environment | COPPERMIND_PROFILE=local (or unset) |
COPPERMIND_PROFILE=cluster |
| Relational Storage | Pure-Go SQLite in WAL mode (coppermind.db) |
PostgreSQL 17 (pgvector/pgvector:pg17) |
| Vector Engine | Embedded 128-dim subword vectorizer + FTS5 BM25 | pgvector HNSW cosine index (vector(128)) |
| Working Memory | In-memory thread-safe RESP scratchpad with mutexes | Redis Cluster 7.x / Dragonfly (COPPERMIND_REDIS_ADDR) |
| Task Queue | Embedded Go buffered channel topic bus (256 queue) | RabbitMQ Cluster AMQP 0-9-1 (COPPERMIND_RABBITMQ_URL) |
| Model Router & Keys | LiteLLM client + Locksmith Touch ID biometric leasing | Centralized LiteLLM proxy pool + SPIFFE mTLS tokens |
| Resource Footprint | Single Go binary (<50MB, <80MB RAM, <150ms cold boot) | OCI container pods (deploy/helm/coppermind) |
| Variable | Default Value | Profile | Description |
|---|---|---|---|
COPPERMIND_PROFILE |
local |
Both | Runtime profile selection: local or cluster. |
COPPERMIND_DATA_DIR |
~/.coppermind |
Both | Root directory for SQLite databases, vaults, and sockets. |
COPPERMIND_PROJECT |
github |
Both | Active project vault (enforces 0% context cross-contamination). |
COPPERMIND_POSTGRES_URL |
postgres://coppermind:sovereign_secret@localhost:5433/coppermind?sslmode=disable |
Profile B | Connection string for PostgreSQL 17 + pgvector. |
COPPERMIND_PG_PORT |
5433 |
Profile B | Port mapped for PostgreSQL container in Docker Compose. |
COPPERMIND_REDIS_ADDR |
127.0.0.1:6379 |
Profile B | Host and port for external Redis working memory scratchpad. |
COPPERMIND_RABBITMQ_URL |
amqp://guest:guest@localhost:5672/ |
Profile B | AMQP broker connection URL for async task queues. |
COPPERMIND_LITELLM_URL |
None (offline fallback) | Both | Optional upstream LiteLLM gateway endpoint for deep reflection. |
OPENAI_API_KEY |
None | Both | Optional API key (auto-resolved from Locksmith Secure Enclave if installed). |
A production-grade Docker Compose manifest is included at the repository root (docker-compose.yml), provisioning PostgreSQL 17 with pgvector, Redis 7, RabbitMQ 3, and Coppermind:
# 1. Start the distributed Profile B infrastructure in the background
docker compose up -d
# 2. Verify all cluster services are healthy
docker compose ps
# 3. Confirm pgvector extension is operational
docker compose exec postgres psql -U coppermind -d coppermind -c \
"SELECT extname, extversion FROM pg_extension WHERE extname = 'vector';"
# 4. Confirm Redis working memory responds
docker compose exec redis redis-cli ping
# 5. Run Coppermind diagnostic inspection against the cluster
COPPERMIND_PROFILE=cluster coppermind doctor
# 6. Store and recall memories using Profile B cluster
COPPERMIND_PROFILE=cluster coppermind remember --category architecture "Postgres 17 pgvector cluster verified"
COPPERMIND_PROFILE=cluster coppermind recall "Which database engine is active?"
# 7. Tear down cluster stack
docker compose downFor enterprise team clusters and cloud-native orchestration, deploy Coppermind via its official Helm chart located at deploy/helm/coppermind:
# 1. Inspect default chart values
helm show values deploy/helm/coppermind
# 2. Deploy Coppermind into dedicated namespace
helm upgrade --install coppermind deploy/helm/coppermind \
--namespace coppermind \
--create-namespace \
--set profile=cluster \
--set postgres.url="postgres://coppermind:secret@postgres-service.coppermind.svc.cluster.local:5432/coppermind?sslmode=disable" \
--set redis.addr="redis-service.coppermind.svc.cluster.local:6379" \
--set rabbitmq.url="amqp://guest:guest@rabbitmq-service.coppermind.svc.cluster.local:5672/"
# 3. Verify running pods and service endpoints
kubectl get pods -n coppermind -l app.kubernetes.io/name=coppermind
kubectl get svc -n coppermind coppermindConfigure your AI agent to mount Coppermind using either Profile A (local zero-dependency) or Profile B (connected to your team cluster):
{
"mcpServers": {
"coppermind": {
"command": "coppermind",
"args": ["mcp"],
"env": {
"COPPERMIND_PROFILE": "local",
"COPPERMIND_PROJECT": "github"
}
}
}
}{
"mcpServers": {
"coppermind-cluster": {
"command": "coppermind",
"args": ["mcp"],
"env": {
"COPPERMIND_PROFILE": "cluster",
"COPPERMIND_POSTGRES_URL": "postgres://coppermind:sovereign_secret@localhost:5433/coppermind?sslmode=disable",
"COPPERMIND_REDIS_ADDR": "127.0.0.1:6379",
"COPPERMIND_RABBITMQ_URL": "amqp://guest:guest@localhost:5672/",
"COPPERMIND_PROJECT": "team-shared"
}
}
}
}Coppermind operates as the persistent AI memory system within the bonjoski sovereign AI agent security ecosystem, integrating natively alongside:
bonjoski/fabrial: Unified security fabric and dynamic multi-tier agent router.bonjoski/airlock: Sub-15ms kernel-enforced sandbox for AI agents and build tools.bonjoski/locksmith: Hardware biometric secrets vault and MCP credential manager.bonjoski/homebrew-tap: Official distribution tap for pre-compiled binaries.
Coppermind adheres to the SLSA v1.0 specification.
Verify provenance with GitHub CLI:
gh attestation verify coppermind --repo bonjoski/coppermindOr verify offline using Soulcaster:
soulcaster verify --attestation coppermind.intoto.jsonl bin/coppermindApache License 2.0. Copyright 2026 Ben Skolmoski (bonjoski). See LICENSE for details.