Agent skill

Tanstack AI Memory

by TanStack in TanStack/ai

A skill your agent uses when wiring memoryMiddleware from @tanstack/ai-memory into a chat() call — covers the recall/save adapter contract, scope shape and server-side scope security, the…

MITAuto-check passedDatabases

Install Tanstack AI Memory

skills CLI
$ npx skills add TanStack/ai --skill tanstack-ai-memory -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install TanStack/ai tanstack-ai-memory --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/TanStack/ai.git skills-src && mkdir -p .claude/skills && cp -r skills-src/packages/ai-memory/skills/tanstack-ai-memory .claude/skills/tanstack-ai-memory && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
tanstack-ai-memory
GitHub stars
3.2k
Token cost
~1.2k tokens
SKILL.md length
346 words
Files
1
Skills in repo
24
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when wiring memoryMiddleware from @tanstack/ai-memory into a chat() call — covers the recall/save adapter contract, scope shape and server-side scope security, the…

  • Wiring memoryMiddleware from @tanstack/ai-memory into a chat() call — covers the recall/save adapter contract
  • SKILL.md covers When to reach for it, Wire it up, The contract and Scope security, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Scope shape and server-side scope security

What it does

Tanstack AI Memory is an agent skill from TanStack/ai. Use when wiring memoryMiddleware from @tanstack/ai-memory into a chat() call — covers the recall/save adapter contract, scope shape and server-side scope security, the recall-inject / deferred-save lifecycle, choosing an adapter (inMemory, redis, hindsight, mem0, honcho), and devtools events.

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Backend development. It works with TanStack, Mem0 and Redis. The repository describes itself as: 🤖 Type-safe, provider-agnostic TypeScript AI SDK for streaming chat, tool calling, agents, and multimodal apps across OpenAI, Anthropic, Gemini, React, Vue, Svelte, and Solid. The licence is MIT.

When your agent uses it

  • Wiring memoryMiddleware from @tanstack/ai-memory into a chat() call — covers the recall/save adapter contract
  • Scope shape and server-side scope security
  • The recall-inject / deferred-save lifecycle
  • Choosing an adapter (inMemory

Example prompts

  • “/tanstack-ai-memory”

What it can do on your machine

Read from SKILL.md and the folder at commit 5a41239. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Tanstack AI Memory loads about 1.2k tokens when it runs. Until then it costs about 78 tokens; SKILL.md has 346 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~78
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from TanStack/ai at commit 5a41239, republished under its MIT licence (© TanStack). 346 words, ~1,156 tokens.

Download SKILL.mdSave it as .claude/skills/tanstack-ai-memory/SKILL.md (or your agent's skills folder).
name
tanstack-ai-memory
description
Use when wiring memoryMiddleware from @tanstack/ai-memory into a chat() call — covers the recall/save adapter contract, scope shape and server-side scope security, the recall-inject / deferred-save lifecycle, choosing an adapter (inMemory, redis, hindsight, mem0, honcho), and devtools events.

TanStack AI Memory Middleware

Use this when adding server-side memory to a chat() call. Everything lives in @tanstack/ai-memory. A memory adapter is a single contract with two verbs — recall and save — and the middleware is thin: it recalls into the system prompt before the model runs and defers save after the turn finishes.

When to reach for it

  • A user expects "remember what I told you last time."
  • Per-user or per-thread context that must survive across sessions.
  • A hosted memory service (mem0, Honcho, Hindsight).

Do NOT use this just to keep recent messages — that's the messages array on chat(). Memory is for cross-turn / cross-session recall, not within-turn history.

Wire it up

ts
import { chat, toServerSentEventsResponse } from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'
import { memoryMiddleware } from '@tanstack/ai-memory'
import { inMemory } from '@tanstack/ai-memory/in-memory'
import { requireSession } from './auth'

const memory = inMemory() // dev/tests only — see the in-memory skill

export async function POST(request: Request) {
  const { messages } = await request.json()
  // Resolved by your auth layer from cookies/headers — never from the request body.
  const session = await requireSession(request)

  const stream = chat({
    adapter: openaiText('gpt-5.5'),
    messages,
    context: { session },
    middleware: [
      memoryMiddleware({
        adapter: memory,
        // Derive scope server-side from trusted session state.
        scope: () => ({ threadId: session.threadId, userId: session.userId }),
      }),
    ],
  })
  return toServerSentEventsResponse(stream)
}

memoryMiddleware options: adapter, scope (static or a function of ctx), role ('recall+save' default, or 'save-only'), and onRecall / onSave telemetry callbacks.

The contract

ts
import type {
  MemoryFact,
  MemoryScope,
  MemorySnapshot,
  MemoryTurn,
  RecallResult,
  SaveReceipt,
} from '@tanstack/ai-memory'

interface MemoryAdapter {
  readonly id: string
  recall: (scope: MemoryScope, query: string) => Promise<RecallResult> // { systemPrompt, fragments?, tools?, toolGuidance? }
  save: (scope: MemoryScope, turn: MemoryTurn) => Promise<Array<SaveReceipt>> // turn = { user, assistant }; extraction lives HERE
  inspect?: (scope: MemoryScope) => Promise<MemorySnapshot> // optional (devtools)
  listFacts?: (scope: MemoryScope) => Promise<Array<MemoryFact>> // optional (devtools)
}
  • recall decides relevance and renders a systemPrompt; it may also return tools + toolGuidance to hand the model direct control of memory (hindsight does this).
  • save owns extraction — turning the raw turn into whatever gets persisted.

Scope security

MemoryScope is an alias of the shared Scope type from @tanstack/ai: { threadId, userId?, tenantId?, namespace? }. It is the isolation boundary. Never trust a client-supplied userId/threadId. Resolve scope server-side from session/auth and pass the validated session through chat({ context: { session } }). If you accept a thread id from the request body, validate it belongs to the session user BEFORE using it.

Adapters

  • inMemory() / redis() — exact match on threadId + optional userId/tenantId (namespace ignored). Redis index keys include all three segments.
  • hindsight() — bank {tenant|_}__{user}__{threadId}.
  • mem0() — user_id + run_id (threadId); no tenantId.
  • honcho() — session {tenant|_}__{threadId}; peer tenant-prefixed when set.
  • Custom — implement recall/save and run runMemoryAdapterContract from @tanstack/ai-memory/testkit.

Failure modes

Memory failures are non-fatal: a throwing recall or save emits memory:error and the run continues with degraded memory. Streaming is never blocked; a failed save never fails the turn.

Devtools

Five events on aiEventClient (from @tanstack/ai-event-client): memory:retrieve:started / :completed, memory:persist:started / :completed, memory:error (phase: 'recall' | 'save'). Payloads carry the adapter id and fragment/receipt counts, not full memory text. Error events include scope only when it was already resolved; if the resolver threw, scope is omitted.

© TanStack, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in packages/ai-memory/skills/tanstack-ai-memory of TanStack/ai.

Open the folder on GitHubat commit 5a41239

Compare with similar skills

Tanstack AI Memory next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Tanstack AI Memory compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Tanstack AI Memory this skillTanStack/ai3.2k—~1.2kAutomated safety check: PassMIT
Cloudrun DevelopmentTencentCloudBase/CloudBase-AI-Toolkit1.1k1 repos~7.2kAutomated safety check: PassMIT
Redis Guide Skilljiushiwon/wg-skills110—~2.3kAutomated safety check: PassApache-2.0
Python Redis Module Skilljiushiwon/wg-skills110—~1.7kAutomated safety check: NotesApache-2.0
Springboot Redis Module Skilljiushiwon/wg-skills110—~1.2kAutomated safety check: PassApache-2.0
Configuring Horizoncoollabsio/coolify63k4 repos~898Automated safety check: PassMIT

Similar skills

  • Cloudrun Development

    TencentCloudBase/CloudBase-AI-Toolkit

    CloudBase Run backend development rules (Function mode/Container mode).

    1.1k GitHub starsUsed in 1 repo~7.2k tokens
    DatabasesAuto-check passed
  • Redis Guide Skill

    jiushiwon/wg-skills

    Redis 学习与选型指南。面向需要了解 Redis 的开发者,提供核心数据结构、安装部署、缓存策略、分布式锁原理、与业务场景匹配推荐、设计规则等(不含具体框架集成,Spring Boot 集成请用 springboot-redis-module-skill,Python 集成请用 python-redis-module-skill)。触发词:"Redis 学习"、"Redis…

    110 GitHub stars~2.3k tokensUpdated 3 days ago
    DatabasesAuto-check passed
  • Python Redis Module Skill

    jiushiwon/wg-skills

    Python Redis 模块快速集成技能。面向已拥有 FastAPI 项目骨架的开发者,提供 Redis 缓存、Session 存储、分布式锁、限流、消息队列等能力的快速集成。触发词:"Python Redis"、"FastAPI Redis"、"Redis 集成"、"redis cache"、"redis session"、"redis lock"、"redis 限流"、"redis…

    110 GitHub stars~1.7k tokensUpdated 3 days ago
    DatabasesAuto-check: notes
  • Spring Redis 模块快速集成技能。面向已拥有 Spring Boot 项目骨架的开发者,提供 Redis 缓存、Session 存储、分布式锁、限流、消息队列等能力的快速集成。触发词:"Spring Redis"、"Spring Boot Redis"、"Redis 集成"、"redis cache"、"redis session"、"redis lock"、"redis…

    110 GitHub stars~1.2k tokensUpdated 3 days ago
    DatabasesAuto-check passed
  • Configuring Horizon

    coollabsio/coolify

    A skill your agent uses whenever the user mentions Horizon by name in a Laravel context.

    63k GitHub starsUsed in 4 repos~898 tokens
    Backend & APIsAuto-check passed
  • Extend Commands API

    redis/lettuce

    Official

    Add or extend Redis commands in the Lettuce client API end-to-end — a new core command, a family of new commands, an extension to an existing command's options, or a module/area command…

    5.8k GitHub stars~7.7k tokensUpdated today
    DatabasesAuto-check: notes

More from TanStack/ai

All 24 skills in this repo
  • I Have Adhd

    TanStack/ai

    A skill your agent uses when the user invokes /i-have-adhd, says they have ADHD, or asks for ADHD-friendly output.

    3.2k GitHub starsUsed in 5 repos~1.8k tokens
    Auto-check passed
  • PR Sweep

    TanStack/ai

    Sweep open (or listed) PRs with up to 100 parallel agents: security-scan outside contributors, rebase onto main when behind (push --force-with-lease), approve pending first-time-contributor CI when…

    3.2k GitHub stars~4.6k tokensUpdated today
    Auto-check passed
  • A skill your agent uses when wiring honcho() from @tanstack/ai-memory/honcho — a hosted memory adapter where recall is a dialectic answer over the user's representation (no discrete fragments).

    3.2k GitHub starsUsed in 1 repo~457 tokens
    Auto-check passed
  • A skill your agent uses when wiring inMemory() from @tanstack/ai-memory/in-memory — explains setup, options (embedder, extract, topK/minScore), when to pick it (dev/tests/single-process demos), and…

    3.2k GitHub starsUsed in 1 repo~448 tokens
    Auto-check passed
  • A skill your agent uses when wiring redis() from @tanstack/ai-memory/redis in production — covers client setup (ioredis or node-redis via fromNodeRedis), the storage model, client-side ranking…

    3.2k GitHub starsUsed in 1 repo~840 tokens
    Auto-check passed
  • A skill your agent uses when adding a public teaching example or a docs tutorial.

    3.2k GitHub stars~1.4k tokensUpdated today
    Auto-check passed

Questions about Tanstack AI Memory

What does Tanstack AI Memory do?

A skill your agent uses when wiring memoryMiddleware from @tanstack/ai-memory into a chat() call — covers the recall/save adapter contract, scope shape and server-side scope security, the…. Tanstack AI Memory is an agent skill from TanStack/ai. Use when wiring memoryMiddleware from @tanstack/ai-memory into a chat() call — covers the recall/save adapter contract, scope shape and server-side scope security, the recall-inject / deferred-save lifecycle, choosing an adapter (inMemory, redis, hindsight, mem0, honcho), and devtools events.

When should I use Tanstack AI Memory?

Tanstack AI Memory fits situations like: wiring memoryMiddleware from @tanstack/ai-memory into a chat() call — covers the recall/save adapter contract; scope shape and server-side scope security; the recall-inject / deferred-save lifecycle; choosing an adapter (inMemory.

How do I install Tanstack AI Memory in Claude Code?

Run `npx skills add TanStack/ai --skill tanstack-ai-memory -a claude-code`. Or copy the skill folder (packages/ai-memory/skills/tanstack-ai-memory in TanStack/ai) into .claude/skills/tanstack-ai-memory in your project. Claude Code loads it when a task matches its description.

How do I install Tanstack AI Memory in Codex?

Run `npx skills add TanStack/ai --skill tanstack-ai-memory -a codex`. Or copy the skill folder (packages/ai-memory/skills/tanstack-ai-memory in TanStack/ai) into .agents/skills/tanstack-ai-memory in your project. Codex loads it when a task matches its description.

Can I use Tanstack AI Memory in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add TanStack/ai --skill tanstack-ai-memory -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/tanstack-ai-memory, .gemini/skills/tanstack-ai-memory, .github/skills/tanstack-ai-memory and .opencode/skills/tanstack-ai-memory in your project.

What does Tanstack AI Memory need to run?

SKILL.md names no scripts, command-line tools or credentials: Tanstack AI Memory is instructions for the agent only.

Does Tanstack AI Memory access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Tanstack AI Memory safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Tanstack AI Memory use?

Tanstack AI Memory is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Tanstack AI Memory use?

About 1.2k tokens (SKILL.md is roughly 4.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Tanstack AI Memory?

Skills that share tags, products or a category with Tanstack AI Memory: Cloudrun Development (TencentCloudBase/CloudBase-AI-Toolkit, 1.1k stars), Redis Guide Skill (jiushiwon/wg-skills, 110 stars), Python Redis Module Skill (jiushiwon/wg-skills, 110 stars) and Springboot Redis Module Skill (jiushiwon/wg-skills, 110 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Tanstack AI Memory?

TanStack (a GitHub organization) maintains it in TanStack/ai, which has 3,169 GitHub stars. The repository holds 24 skills in this directory. The repository was last updated on October 7, 2026.

Source: TanStack/ai on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.