llm-wiki-memory
AGENTS.md131 starsChanged 3 months agoMITView on GitHub
llm-wiki-memory: local LLM-wiki-backed memory for AI coding agents. Capture, compile, recall, stored as leaves in a git-versioned local wiki (via @ctxr/skill-llm-wiki), with local-embedding recall. No RAG, no Docker. Rules for working ON this repo are canonical in .agents/rules/: live-runtime-safety.md (read first — this tree is executed live by the MCP server, hooks and cron; editing it can destroy live data), dev-principles.md (durability / parsing / injection / config invariants, cross-client portability, wiki placement, LLM-pipeline contracts, hook design), defensive-invariants.md (when a…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,700 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository19 other files it gives its agents.
- .cursor/rules/debug-capture-pipeline.mdcCursor rule
- .cursor/rules/defensive-invariants.mdcCursor rule
- .cursor/rules/dev-principles.mdcCursor rule
- .cursor/rules/docs-style.mdcCursor rule
- .cursor/rules/live-runtime-safety.mdcCursor rule
- .cursor/rules/module-state-ownership.mdcCursor rule
- .cursor/rules/release-migrations-authoring.mdcCursor rule
- .cursor/rules/run-tests-safely.mdcCursor rule
- .cursor/rules/self-observability.mdcCursor rule
- .cursor/rules/testing.mdcCursor rule
- .cursor/rules/triage-review-findings.mdcCursor rule
- .cursor/rules/verification-completeness.mdcCursor rule
- .cursor/rules/verify-live-change.mdcCursor rule
- .cursor/rules/write-migration.mdcCursor rule
- debug-capture-pipelineSkill
- run-tests-safelySkill
- triage-review-findingsSkill
- verify-live-changeSkill
- write-migrationSkill
The file
We split this AGENTS.md into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 118
No em dashes or en dashes in authored text (use commas, colons, parentheses, line breaks).
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
llm-wiki-memory: local LLM-wiki-backed memory for AI coding agents. Capture, compile,
recall, stored as leaves in a git-versioned local wiki (via @ctxr/skill-llm-wiki), with
local-embedding recall. No RAG, no Docker.
Development discipline (.agents/)
Rules for working ON this repo are canonical in .agents/rules/:
live-runtime-safety.md (read first — this tree is executed live by the MCP server,
hooks and cron; editing it can destroy live data),
dev-principles.md (durability / parsing / injection / config invariants, cross-client
portability, wiki placement, LLM-pipeline contracts, hook design),
defensive-invariants.md (when a guard may be deleted; guard vs tripwire; why
"unreachable by derivation" is not "unreachable in fact"),
verification-completeness.md (what "green" is allowed to mean — the full gate chain,
falsifiable tests, named before/after invariants for durable artifacts),
module-state-ownership.md (one state machine per module; keyed memos over hot-reloading
settings; the disposal duty a rebuild path creates),
testing.md (harness + mocking conventions, the /tmp/lwm-* leak trap),
release-migrations-authoring.md (a breaking change ships an idempotent,
state-detecting migration under scripts/migrations/ — never a runbook),
self-observability.md (capture confirmed engine bugs while you work),
and docs-style.md (README/docs conventions). Step-by-step procedures live in
.agents/skills/ (write-migration.md, run-tests-safely.md,
debug-capture-pipeline.md, verify-live-change.md, triage-review-findings.md).
Per-client shadows reference the canonical files via @-imports — .claude/rules/ +
.claude/skills/ (Claude Code), .cursor/rules/ (Cursor); always edit the .agents/
file, never a shadow. The shadows are GENERATED: run npm run wire:dev-surfaces after
adding or renaming a canonical file, and test/dev-surface-mirror.test.mjs fails the
gate if any client is missing one. That gate exists because Cursor silently went five
shadows short — a missing shadow means the rule simply does not apply in that client,
and nothing reports it.
These govern DEVELOPING llm-wiki-memory; the rules shipped into consumer installs live in
templates/rules/ and are rendered by bootstrap — keep the two audiences separate.
Layout
scripts/hooks/: Claude Code lifecycle hooks (bash wrappers calling.mjs).session-start(triggers daily compile, prints routing context),pre-compact/post-compact/session-end(callflush.mjs, extract atoms todaily/),exit-plan-mode(capture approved plans toplans/).scripts/compile.mjs: once-per-day promotion of daily atoms intoknowledge/andself_improvement/, with embedding plus metadata dedup; archives promoted dailies.scripts/lib/wiki-commit.mjs: the wiki auto-commit layer (wiki.autoCommit). Every wiki-store writer records per-leaf changes; orchestrators wrap a run inwithWikiCommitso one logical operation = one commit to the wiki's OWN repo (toplevel-checked — it can never commit into the workspace repo). Best-effort; failures breadcrumb tostate/.wiki-commit.log.scripts/cron-job.mjs: hourly compile+consolidate runner with two-tier logging (slimstate/.consolidate-attempts.log+ full shardedstate/logs/yyyy/mm/), per-entity healing state (state/.consolidate-entities.json), and escalation issue reports (issues/yyyy/mm/dd/<sig>.<version>.md; episode index instate/.issues-index.json). Compile exit69(EX_UNAVAILABLE: daily docs pending, no LLM provider reachable) counts as a FAILED attempt but still runs consolidate; the synthetic entitiessystem:compile-llm-providers/system:consolidate-llm-providersescalate persistent provider absence and resolve on the first healthy tick.scripts/lib/wiki-store.mjs: the storage seam, a drop-in for a RAG bridge whose every document is a wiki leaf. Drivesskill-llm-wikifor index-rebuild, validate, heal, rebuild (it owns tree-building; we own category routing). Hardens arbitrary names vianormalizeLeafNameand rejects unknown categories. Placement is always nested, never a flat category root: non-daily categories nest by the metadata facets they are searched by (knowledge/<project_module>/<atom_type>/,self_improvement/<project_module>/<task_type>/,plans/<project_module>/,investigations/<project_module>/), daily by capture date (daily/<yyyy>/<mm>/<dd>/); absent facets use the sentinelsunscoped(project_module) /unknown(task_type) /untyped(atom_type). Browsing the tree then mirrors howsearchMemoryFilteredfilters. Do NOT run the skill's topicalrebuildon these memory wikis (it would re-cluster by meaning and fight the facet layout); re-nest deterministically withnode scripts/cli.mjs nest.scripts/migrate-nest.mjs:cli.mjs nest- moves pre-existing flat leaves into the nested layout by reading each leaf's frontmatter facets (idempotent;--dry-run,--check).scripts/lib/embed.mjs: the FACADE over the embedding subsystem (default EmbeddingGemma-300m via@huggingface/transformers, inference in a worker thread so the event loop never blocks). One state machine per module behind it:embed-backend-state.mjs(which backend is serving),embed-runner.mjs(texts → vectors, single worker thread + in-process),embed-cache-dims.mjs(one vector dimension per cache file — a mixed file makes leaves score 0 and vanish from results),embed-cache-io.mjs(how the cache file is read/written),embed-cache-guards.mjs(whether a write is safe),keyed-memo.mjs(artefacts keyed on the settings that built them). Model families, retrieval prompts, and per-family dtype defaults resolve inembed-inference.mjs. The only retrieval engine (the skill has no query command). See.agents/rules/module-state-ownership.md.scripts/lib/fatal-guard.mjs: process-level diagnostics for the LONG-LIVED entrypoints only (MCP server, webapp daemon, embed worker). AnunhandledRejectionis reported to stderr plus one monitoring capture per signature and the process KEEPS SERVING — Node's default would otherwise remove a user's memory tools mid-session; anuncaughtExceptionreports then exits 70 (EX_SOFTWARE). Deliberately NOT installed in hooks or the one-shot CLI, whose wrappers make node's exit code the hook's own and which must always exit 0.scripts/lib/recall.mjs:recallLessons(fall-back ladder),searchMemory,saveLesson.scripts/lib/discipline.mjs: single source of the memory discipline (MCPinstructionsand the SessionStart context).scripts/lib/wiki-cli.mjs: wrapper around theskill-llm-wikibin; resolves it fromnode_modules(orLLM_WIKI_SKILL_CLI), runsindex-rebuild-onefor every touched ancestor dir, bottom-up.mcp-server/index.mjs: local stdio MCP server exposingsave_lesson,recall_lessons,save_to_dataset,search_memory, and the document/audit tools.templates/:.claude/settings.jsonhooks,.mcp.json,env.example, vendor-neutralagents/, and disciplineskills/. (Layout contracts are NOT here: theexamples/layouts/<name>/folders are the single source, installed bycli.mjs init --template <name>.)examples/layouts/<name>/: the shipped layout templates (default,tracker-issues,repo) — alayout.yamlplus any sibling path-compiler helpers and a README.initcopies the whole chosen folder into<wiki>/.layout/.bootstrap.sh: installer (npm install, render config, merge hooks and mcp, render rules to.agents/rules/.claude/skills/.cursor/rules, materialise the wiki, gitignore, optional--schedule).scripts/mcp-config.shprints per-client MCP config.
Tests
npm test (unit: wiki-store, recall, slug, discipline, MCP boot and round-trip) and
npm run test:e2e (full lifecycle against the real skill CLI; LLM stubbed via
MEMORY_LLM_PROVIDER=mock, embeddings via embed.backend: lexical in the test workspace's settings.yaml — see test/harness.mjs).
Conventions
- No em dashes or en dashes in authored text (use commas, colons, parentheses, line breaks).
- Runtime data lives outside the repo, under
<workspace>/.llm-wiki-memory/.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

