session #00417 · live

A memory stronghold for your AI coding agent.

Install once. Every session your agent has — Claude Code, Codex, Copilot, Kiro — flows into one Postgres knowledge graph. Next session, it walks in already briefed.

$curl -fsSL https://raw.githubusercontent.com/villanub/borgmemory/main/install.sh | sh
$borg init
copy
What Borg knows about this project, right now
LIVE GRAPH NEIGHBORHOOD · ns=product-engineering
mentionsmentionsuses_patterndepends_onpersists_tovalidatesWebhook GatewayWebhook RuleHMAC PatternBackground JobsPostgresep · 2026-03-01 · claude-code
entity fact (typed predicate) episode
TASK SUCCESS — ENGINEERING-TASK BENCH10/ 10Borg-compiled context completes every task. No-memory baseline: 0/10.
RETRIEVAL PRECISION91.3%+12.7 pts over top-10 vector RAG. Measured against labeled ground-truth.
STALE-FACT RATE−78%Temporal supersession keeps contradicted decisions out of compiled context.
borg_think · classify → retrieve → rank → compilepostgres-native · pgvector · recursive CTE24 canonical predicates3-pass entity resolutionapache 2.0claude code · codex · copilot · kirovalid_from / valid_until supersessionsingle-user · localhost · no login15 tables · 1 function78% fewer stale facts vs RAGborg_think · classify → retrieve → rank → compilepostgres-native · pgvector · recursive CTE24 canonical predicates3-pass entity resolutionapache 2.0claude code · codex · copilot · kirovalid_from / valid_until supersessionsingle-user · localhost · no login15 tables · 1 function78% fewer stale facts vs RAG
§ 01 — THE LOOP

Not search.
Compilation.

Every borg_think call runs the same five-stage pipeline: classify the intent, retrieve across facts / episodes / graph, rank on four dimensions, compile for the target model, log the trace. You see every candidate and why it was picked or rejected.

Query from claude-code · ns: product-engineering
task: debuggraph_neighborhoodepisode_recallfact_lookup
Classify intent · debug
0.92 / 0.31
Retrieve across 3 strategies
graph · episodes · facts
Score 14 candidates, select 6
relevance · recency · stability · prov.
Compile XML for claude
1,840 tokens
Audit log + access tracking
12 ms
§ 02 — WHAT'S INSIDE

Six decisions,
one system.

Every choice below ships in the open-source release under Apache 2.0. Read the full tradeoffs on /features.

01

Knowledge Graph Extraction

An LLM pipeline turns conversations into typed entities, temporal facts, and reusable procedures — with three-pass resolution that prefers fragmentation over collision.
Graph is mergeable. Collisions are not.
MODEL · gpt-5-mini
CAP · 10 entities / ep.
THRESH · 0.92 semantic
02

Temporal Facts with Supersession

Every fact carries valid_from and valid_until. New contradictions mark old facts superseded — never deleted. Compliance queries still see history; working memory doesn't.
78% fewer stale facts in bench C vs RAG.
STATUSES · 7
PREDICATES · 24 canonical
HISTORY · bitemporal
03

Task-Specific Compilation

Dual-profile intent classification picks what kind of memory a query needs. Debug gets episodic + procedural. Architecture gets semantic facts. Compliance excludes procedural entirely.
Weights bias ranking, not hard excludes.
PROFILES · 2
FORMATS · XML · JSON
BUDGET · per namespace
04

Inspectable Ranking

Four orthogonal scores — relevance, recency, stability, provenance — surfaced individually. Every compilation emits an audit trail of selected, rejected, and why. No opaque composites.
The audit log is the debugger.
DIMENSIONS · 4
AUDIT · pgAudit
OPS · insert · select
05

Namespace Isolation

Hard by default: every entity, fact, and episode belongs to exactly one namespace. No cross-namespace queries. Per-namespace token budgets. Projects stay cleanly separate.
Cross-ns is a future feature, not an accident.
MODE · hard
BUDGETS · token-per-ns
LEAK · structurally impossible
06

PostgreSQL Maximalism

One database. Graph via recursive CTE. Embeddings via pgvector. Audit via pgAudit. No Qdrant. No Neo4j. No sync daemons. Runs on Supabase, Neon, managed Postgres, or your laptop.
Nothing gets out of sync if there is nothing to sync.
TABLES · 15 + 1 fn
EXT · pgvector · pgAudit
MIN · PG 14
§ 03 — MCP SURFACE

Three tools.
Not five.

The entire interaction surface is three MCP tools. Works unchanged across Claude Code, Codex CLI, Copilot, Kiro, and anything else that speaks MCP over streamable HTTP.

borg_thinkcompile

Compile context for a query. Runs the full online pipeline — classify, retrieve, rank, compile — and returns a ranked, token-budgeted context package.

borg_think(
query: "debug webhook delivery timeout",
namespace: "product-engineering",
model: "claude",
task_hint: "debug"
)
borg_learnrecord

Record a decision or discovery. Stored immediately, extraction runs async. Returns in milliseconds so nothing blocks the agent loop.

borg_learn(
content: "Versioned event payloads via schema registry…",
source: "claude-code",
namespace: "product-engineering"
)
borg_recallbrowse

Direct memory search without compilation. Raw episodes, facts, and procedures — for UI, audits, or you-the-developer.

borg_recall(
query: "release checklist",
namespace: "product-engineering",
memory_type: "semantic"
)
§ 04 — THE LANDSCAPE

Everyone else returns results.
Borg returns context.

Every competitor wraps 2–3 databases and hands the agent raw matches. Borg is one Postgres that compiles.

Mem0ZepCogneeBorg
Databases requiredQdrant + Neo4jNeo4j + vectors3+1 · Postgres
IntegrationPython SDKPython SDKPython SDK1 line in CLAUDE.md
Retrieval outputRaw resultsRaw resultsRaw resultsCompiled ranked context
Stale-fact handlingNoneTemporal (Neo4j)NoneTemporal · supersession
Cross-client reusePer SDKPer SDKPer SDKAny MCP client, same DB
Audit + inspectLimitedPartialLimitedFull trace, per compile
LicenseMixedMixedOpenApache 2.0
§ 05 — THE BENCH

Ten tasks.
Three conditions.

Modeled on real cloud-infrastructure engineering work — incident response, schema migration, architecture review. Each condition runs the same evaluator against the same ground-truth labels. Seeds + code: /bench.

Condition A

No memory

Baseline — every session starts from zero.

Task success0/ 10
Retrieval precision6.0%
Stale-fact rate0.0%
Condition B

Top-10 vector RAG

Standard similarity search over conversation chunks.

Task success8/ 10
Retrieval precision81.0%
Stale-fact rate11.5%
Condition C

Borg · compiled

Full pipeline: classify, retrieve, rank on 4 dims, compile.

Task success10/ 10
Retrieval precision91.3%
Stale-fact rate2.5%
— install it now —

One command. One Postgres.
Every session after, smarter.

Apache 2.0. Single-user, local-first, bring your own key. Shared-deployment auth is on the roadmap.

$curl -fsSL https://raw.githubusercontent.com/villanub/borgmemory/main/install.sh | sh
$borg init
copy
view on github