midmem-dev

A development guide for MidMem, a shared knowledge layer for language models that stores and retrieves project information. It covers the core packages and their command-line, MCP, and hook interfaces.

In plain words
What is it for?
It is for adding or changing retrieval, lifecycle tiers, work-memory events, concept routing, claims, grounding, integrations, and tests in MidMem.
Why use it?
It helps contributors change the knowledge system without breaking its storage model, deterministic behavior, grounding checks, or support for different host environments.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/u4csolutions/midmem/midmem-dev
Any agent
npx skills add U4CSolutions/MidMem --skill midmem-dev
Clone the repo
git clone --depth 1 https://github.com/U4CSolutions/MidMem

Made for: Claude Code, Codex.

Per session 136 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,549 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00136 $0.01549
Opus 5 $0.00068 $0.00775
Sonnet 5 $0.00027 $0.00310
Haiku 4.5 $0.00014 $0.00155

Measured yesterday against content hash 66e10ce02b61, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

midmem-dev scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/midmem-dev/SKILL.md · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MidMem development loop

Repo: this checkout (own git). Node ESM, node:sqlite, zero external deps. Core: packages/core/. Paths below are repo-relative; <repo> = the midmem-kb-store checkout root.

The architecture you must preserve

  • Pure-core. Everything lives in packages/core/src over one state.db, reached via exactly three surfaces: CLI bin/cli.mjs, MCP bin/mcp-server.mjs, hook seam bin/hook.mjs. No file in the core may reference OpenClaw, Hermes, Claude Code, or any host stack. This is what makes it run in 4 modes (standalone · OpenClaw add-on · Hermes add-on · bridge); see docs/INTEGRATION-MODES.md.
  • state.db = source of truth; the Obsidian LLM Wiki = deterministic projection (regenerable; never canonical, never hand-edited).
  • Determinism + grounding. Categorization, work-events, community detection, contradiction detection are deterministic (no LLM). Ingest runs the DELEGATE-52 grounding check before persisting. Never bypass grounding; never use LLM self-review for grounding/promotion.

Map of the core (where things go)

  • orchestrator.mjs — the coordinator; every public op + governance + #maybeMaintain. Add new public methods here.
  • db.mjs — schema (entries, vectors, nodes, edges, claims, sources, log, audit). Prefer using entries.type + provenance over new tables/columns.
  • memory.mjs tiers/lifecycle · retrieval.mjs hybrid lanes + post-RRF boosts · graph.mjs nodes/edges (extend EDGE_TYPES for new relations) · claims.mjs · workmemory.mjs work events + categorization · concepts.mjs concept embeddings + communities · grounding.mjs · config.mjs (env-tunable knobs) · index.mjs (public exports).

Adding a capability — the checklist

  1. Core logic in the right module (or a new src/<feature>.mjs); keep it deterministic where it can be. Read the module first and match its idiom/comment density.
  2. Wire an Orchestrator method → export in index.mjs → expose via MCP tool (bin/mcp-server.mjs) and CLI command (bin/cli.mjs). Add a config block (env-tunable) in config.mjs if it has knobs.
  3. Boosts go post-RRF in retrieval.mjs, small (≈ trust/graph magnitude, ~0.004–0.01), additive.
  4. Anything that ingests inside maintain() must be re-entrancy-guarded (this._maintaining) — the bridge→ingest→#maybeMaintain→maintain path recurses infinitely on a low intervalMs; the throttle alone is not safe. Heavy work (embedding) runs on forced/daily maintain only.
  5. Test it. Add assertions to packages/core/test/smoke.mjs (offline, hermetic — pass autoIngest:{enabled:false} to test orchestrators so maintain() doesn't bridge real dirs).

Read the full file on GitHub · 88 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 88 lines · 136 tokens per session scan A 66e10ce02b61

Subscribe to this mod's changes

midmem-dev is a skill published in the GitHub repository U4CSolutions/MidMem (2 stars, last pushed 8d ago), licensed Apache-2.0. It adds 136 tokens to every session and 1,549 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

graph-mutation-plan

Cookbook for composing an applygraphmutations plan — stable entitykey patterns, the canonical label/edge vocabulary, evidence/invalidation/confidence discipline, and a worked example. Load this when building a non-trivial mutation plan.

potpie-ai/potpie · 51 tokens

potpie-infra-architecture

Use for project infra and architecture context: environments, adapters, runtime configuration, deployments, service dependencies, datastores, API contracts, ownership, incidents, and dependency blast radius.

potpie-ai/potpie · 43 tokens

wiki-context-pack

Produce a token-bounded, citation-ready context slice from an existing Obsidian vault for a downstream agent or task. Use for "/wiki-context-pack", "use my vault as context", "context slice for X", "pack the wiki for my agent", or "bounded context for Y".

Ar9av/obsidian-wiki · 63 tokens

alfworld-receptacle-finder

Searches for a suitable empty or appropriately occupied receptacle (like a shelf or table) to place an object. Use when you are holding an object that needs to be stored or placed and must find a receptacle that meets the placement criteria. Examines candidate receptacles by navigating to and inspecting each one until…

zjunlp/SkillNet · 76 tokens

alfworld-search-pattern-executor

Systematically searches a sequence of likely locations for a target object based on common sense. Use when you need to find a specific object and know which receptacles to check but not which one contains it. Takes a list of candidate receptacles, orchestrates navigation and inspection, and outputs when the target is…

zjunlp/SkillNet · 74 tokens

ux-ui-analyze-single-page

Analyze exactly one captured UI page (from uxuimap screenshots + request JSON) and immediately write/update uxuimap/pages/{page}.md in neutral descriptive language. Use when asked to analyze screenshots, rewrite corresponding analysis immediately, or avoid memory/context saturation.

raphaelmansuy/edgequake · 58 tokens