LawdMemory Docs
The complete reference for building persistent memory into your AI engineering workflow. From first install to self-hosted production deployments.
Overview
Introduction
LawdMemory is a persistent memory layer for AI engineering teams. It ingests your repositories, PRs, incidents, and decisions, builds a temporal knowledge graph, and exposes it to AI agents via a simple API.
Use it to give Claude, Copilot, Cursor, or any custom agent actual memory of why your architecture looks the way it does — across sessions, sprints, and team members.
Memory Graph
Every commit, incident, and decision becomes a queryable node.
AI-Native
MCP-compatible. Works with Claude, GPT, and custom agents.
Self-hostable
MIT-licensed. Run on your infra or our managed cloud.
5-minute install
Quick Start
Get a working memory graph from your first repo in under 5 minutes.
1. Install the CLI
npm install -g @lawdmemory/cli
# or use npx — no install required
npx create-lawdmemory@latest --org your-team2. Authenticate
LawdMemory uses keypair-based identity. The CLI generates a DID for you on first run:
lawdmemory auth init
▸ generating Ed25519 keypair...
✓ identity created: did:key:z6MkpTHR8VNs...
✓ stored in ~/.lawdmemory/identity.json3. Connect your first repo
lawdmemory connect github \
--org acme-corp \
--repo backend \
--history 365d
▸ scanning 14,328 commits...
▸ extracting decisions from 482 PRs...
▸ indexing 1,204 incident reports...
✓ ingested 142,418 memories in 2m 38s4. Query the graph
lawdmemory ask "why was Redis added?"
✓ retrieved 3 memories · 2ms
Redis was introduced in commit a3f92b on 2024-01-15...Identity & Tokens
Authentication
LawdMemory uses decentralized identifiers (DIDs) for human and agent identity. Every actor — human or AI — is identified by a cryptographic keypair.
API tokens
For server-to-server calls, mint a scoped API token:
lawdmemory tokens create \
--name "ci-pipeline" \
--scopes "graph:read,memory:write" \
--expires 90dUsing tokens
import { LawdMemory } from "@lawdmemory/sdk";
const lm = new LawdMemory({
apiKey: process.env.LAWDMEMORY_API_KEY,
org: "acme-corp",
});
const results = await lm.search("authentication decisions");Core Concept
Memory Graph
Every signal LawdMemory ingests becomes a typed Node in a graph, connected by typed Edge relationships.
Node types
repo— a repositoryservice— a microservice or modulecommit— a git commit with extracted contextpr— a pull request and its discussionincident— an outage or postmortemdecision— an extracted architectural choiceagent— an AI agent that interacted with the graph
Querying the graph
const trace = await lm.graph.traverse({
start: "decision:redis-caching",
edges: ["caused_by", "fixed_by", "discussed_in"],
depth: 3,
direction: "both",
});
trace.nodes.forEach(n => console.log(n.type, n.label));Core Concept
Temporal Memory
Every memory is timestamped and versioned. You can query the graph as of any point in time.
// What did our architecture look like before INC-047?
const snapshot = await lm.recall({
query: "current architecture",
asOf: "2024-01-11",
});
// Diff between two points in time
const diff = await lm.diff({
from: "2024-01-01",
to: "2024-06-01",
scope: "auth",
});Core Concept
Semantic Search
Semantic search runs over embeddings of every memory in your graph. Vector store is pluggable — Pinecone, Qdrant, Weaviate, or self-hosted pgvector.
const hits = await lm.search({
query: "performance regression in payment flow",
k: 10,
filters: {
types: ["incident", "commit"],
after: "2024-01-01",
severity: ["P0", "P1"],
},
rerank: true,
});Integration
MCP Server (Claude)
LawdMemory ships a Model Context Protocol server with 25 tools that Claude and other MCP agents can call directly.
Claude Desktop config
{
"mcpServers": {
"lawdmemory": {
"command": "npx",
"args": ["-y", "@lawdmemory/mcp"],
"env": {
"LAWDMEMORY_API_KEY": "lm_...",
"LAWDMEMORY_ORG": "acme-corp"
}
}
}
}Available tools
Claude gains: recall_memory, search_graph, traverse_decisions, get_incident_history, find_related_commits, and 20 more.
Integration
GitHub
Install the GitHub App on your organization to auto-ingest commits, PRs, issues, and discussions.
lawdmemory connect github --org acme-corp --repos "*"The app subscribes to webhooks and ingests every event in real time. Historical backfill happens in parallel.
Integration
Webhooks
Stream events from any source into the memory graph:
import express from "express";
import { LawdMemory } from "@lawdmemory/sdk";
const app = express();
const lm = new LawdMemory({ apiKey: process.env.LM_KEY! });
app.post("/webhook/sentry", express.json(), async (req, res) => {
await lm.ingest.incident({
source: "sentry",
title: req.body.event.title,
severity: req.body.event.level,
metadata: req.body,
});
res.sendStatus(200);
});Reference
REST API
Base URL: https://api.lawdmemory.dev/v1
Common endpoints
/recallRetrieve memories matching a natural-language query./memories/:idFetch a single memory by ID./graph/queryRun a graph traversal./searchSemantic vector search./ingestIngest a new memory event.Example request
curl -X POST https://api.lawdmemory.dev/v1/recall \
-H "Authorization: Bearer $LM_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "why was Redis introduced",
"depth": 3
}'Reference
GraphQL
The GraphQL endpoint supports queries, mutations, and subscriptions.
query MemoryQuery($q: String!) {
recall(query: $q, depth: 3) {
memories {
id
type
label
createdAt
sources { type ref }
}
latencyMs
}
}Reference
SDKs
First-party SDKs for the two languages that matter for AI infra:
TypeScript
v1.0npm install @lawdmemory/sdkPython
v1.0pip install lawdmemoryfrom lawdmemory import LawdMemory
lm = LawdMemory(api_key=os.environ["LM_KEY"], org="acme-corp")
result = lm.recall("why was Redis added?")
print(result.summary)Operations
Self-Hosting
LawdMemory is MIT-licensed and ships as a single Docker image with a Postgres + pgvector dependency.
services:
lawdmemory:
image: ghcr.io/lawdmemory/server:latest
ports: ["8080:8080"]
environment:
DATABASE_URL: postgres://lm:lm@db:5432/lawdmemory
JWT_SECRET: ${JWT_SECRET}
db:
image: pgvector/pgvector:pg16
volumes: ["pgdata:/var/lib/postgresql/data"]
volumes: { pgdata: {} }Operations
CLI Reference
The CLI is the fastest way to interact with your workspace.
lawdmemory init
Initialize a new workspace
lawdmemory connect <source>
Connect a data source (github, linear, sentry...)
lawdmemory ask <query>
Query the memory graph from the terminal
lawdmemory tokens create
Mint an API token
lawdmemory sync
Force a re-sync of all sources
lawdmemory status
Show ingestion and indexing health
Resources
FAQs
Is LawdMemory really open source?
Yes — MIT licensed, source available on GitHub. You can self-host indefinitely without paying us a cent.
What's the difference between LawdMemory and a vector database?
Vector stores answer 'find me similar text'. LawdMemory answers 'why did this happen, when, and what changed because of it' — semantic + temporal + causal.
Do you train on my code?
No. Embeddings are generated locally or via your chosen provider (OpenAI, Cohere, Voyage). We never see plaintext.
How do AI agents access the memory?
Via the MCP server (for Claude / MCP-compatible agents), REST API, GraphQL, or our TypeScript/Python SDKs.