tanstack-ai-memory-in-memory

An in-memory storage adapter for TanStack AI memory. It keeps conversation records in a process’s temporary memory, so they disappear when the process restarts.

In plain words
What is it for?
Use it for local development, automated tests, and single-process demonstrations. Its options can control recall, semantic scoring, and extracting facts from conversations.
Why use it?
It provides memory without setting up a database, but it is unsuitable when several processes must share data or when records must survive restarts.

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/tanstack/ai/tanstack-ai-memory-in-memory
Any agent
npx skills add TanStack/ai --skill tanstack-ai-memory-in-memory
Clone the repo
git clone --depth 1 https://github.com/TanStack/ai

Made for: Claude Code, Codex.

Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 418 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.00063 $0.00418
Opus 5 $0.00032 $0.00209
Sonnet 5 $0.00013 $0.00084
Haiku 4.5 $0.00006 $0.00042

Measured 2d ago against content hash 15645031ba36, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tanstack-ai-memory-in-memory 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 2d ago.

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.

packages/ai-memory/skills/tanstack-ai-memory-in-memory/SKILL.md · 52 lines

What it actually says

In-Memory Memory Adapter

Zero-dependency recall/save adapter backed by a Map. Records vanish on process restart.

When to use it

  • Local development.
  • Vitest / Playwright tests.
  • Single-process demos where users don't need persistence.

When NOT to use it

  • Production multi-process deployments — every worker has its own Map; users get inconsistent memory.
  • Anything that needs survival across restarts.

For production, use redis() (see the tanstack-ai-memory-redis skill).

Setup

import { memoryMiddleware } from '@tanstack/ai-memory'
import { inMemory } from '@tanstack/ai-memory/in-memory'

const memory = inMemory()

memoryMiddleware({ adapter: memory, scope })

Options

inMemory(options?) accepts:

  • topK (default 6), minScore (default 0.15), kinds — recall tuning.
  • embedder: { embed(text): Promise<number[]> } — enable semantic scoring (both recall and save embed through it).
  • extract(turn, scope) — return derived facts to persist alongside the raw turn (e.g. call an LLM to pull out preferences). Without it, save stores the raw user/assistant messages and recall scores them lexically + by recency.
  • render(hits) — replace the built-in prompt renderer.

Capacity

The adapter scans every record in a scope per recall. Fine up to ~100k records; beyond that, switch to Redis.

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. 2d ago First seen · 52 lines · 63 tokens per session scan A 15645031ba36

Subscribe to this mod's changes

tanstack-ai-memory-in-memory is a skill published in the GitHub repository TanStack/ai (3,056 stars, last pushed today), licensed MIT. It adds 63 tokens to every session and 418 once invoked, about $0.0003 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-30.