Lmemory: Local Markdown & SQLite FTS5 Memory Skill

Point AI coding agents at a local Markdown / Obsidian vault via SQLite FTS5 and MCP—tracking superseded decisions, separating reference clippings, and returning line-level receipts with direct, related, or none.

Tink2.1.3Nov 23, 2026MITSource repository
Get the skill

Requirements

  • Python 3.9+ with SQLite FTS5 enabled
  • Local Markdown or Obsidian vault directory (OBSIDIAN_VAULT)
  • Optional MCP host such as Codex, Claude Code, Claude Desktop, or Antigravity

Quick start

1. Clone and install Lmemory

git clone https://github.com/TinkCarlos/Lmemory.git
cd Lmemory
python3 -m venv .venv
. .venv/bin/activate
python -m pip install .
lmemory demo --lang en

Or run the pinned v2.1.3 demo directly:

uvx --from git+https://github.com/TinkCarlos/[email protected] lmemory demo --lang en

2. Install the Skill bundle

Extract lmemory/ from the ZIP into ~/.agents/skills/lmemory (or your agent's skills directory) and set OBSIDIAN_VAULT to your Markdown folder.

3. Connect via MCP (Codex example)

[mcp_servers.lmemory]
command = "/absolute/path/to/Lmemory/.venv/bin/lmemory"
args = ["--vault", "/absolute/path/to/notes", "mcp"]

[mcp_servers.lmemory.env]
LMEMORY_NO_QUERY_LOG = "1"

Why local, source-backed memory

Lmemory is maintained under the MIT license (forked from KRouter) so coding agents share project rules, corrections, and dated session records across Codex, Claude Code, Cursor, and Antigravity without a cloud black box, vector database server, or personal API keys.

How the Skill workflow runs

  1. Check vault and nightly upkeep state via route_knowledge.sh status (or lmemory_status).
  2. Route queries cleanly by type: preference, correction, memory, project, or search.
  3. Enforce honest memory boundaries from every receipt:
  • memory: direct — verified live supporting sentence (or exact named identifier) exists in an active note.
  • memory: related — candidate paths and passage ranges (L8 (passage L6-L8)) are returned; the agent must open the cited file before answering.
  • memory: none — no guessing or fabricating from near-miss text.
  1. Keep superseded rules out of active answers and isolate external clippings under knowledge_base:.
  2. Protect secret pages (secret: true or key/credential notes): only paths are shown, values are redacted.

Measured highlights (v2.1.3)

  • Cold first lookup with index rebuild across 1,801 Markdown pages dropped from 7.334s to 5.818s median (-20.7%), with 99.80% (1,012 / 1,014) cross-project source receipt accuracy.
  • Synthetic 24-question context payload shrank from 72,864 tokens (full notes) to 14,644 tokens (structured receipts), saving 79.9% context tokens.
Inside the skill
SKILL.md
---
name: lmemory
description: Lmemory Obsidian — route knowledge-dependent tasks to the smallest current evidence set in an Obsidian vault using deterministic local search. Use when a request depends on durable user preferences, prior corrections or superseded claims, long-term project history or results, reusable methods or evidence, or the current vault and automation state. Return evidence in-process; do not spawn a retrieval model or add embeddings.
---

# Lmemory Obsidian

Set `OBSIDIAN_VAULT` to the vault root. Run retrieval in the current process. Do not spawn a retrieval agent. Do not add vector storage.

Router script (after install): `$HOME/.agents/skills/lmemory/scripts/route_knowledge.sh`. On Windows use `python3 route_knowledge.py` (same routes).

## Workflow

1. Run `route_knowledge.sh status`. If the receipt has `host_action:`, tell the host that line (paste `*_API_KEY` on `90 系统文件/自动化/自进化钥匙.md`, or log in `grok` / official Codex / `claude` once; or the nightly upkeep is skipped / failing — `nightly:` says which, `90 系统文件/自动化/夜间维护.md` says why). Do not print secrets. Then continue the user's question.
2. Choose one route: `status` for current system state; otherwise `preference`, `correction`, `memory`, `project`, or `search`.
3. Send one distinguishing noun, or a short question (a few words). Do not paste the whole conversation. Do not string unrelated keywords together as if they were AND.
Included files · 39
lmemory/SKILL.md
lmemory/scripts/answer_cards.py
lmemory/scripts/ask_product.py
lmemory/scripts/associate.py
lmemory/scripts/backup.py
lmemory/scripts/canonical_lookup.py
lmemory/scripts/canonical_sources.psv
lmemory/scripts/capture_ledger.py
…