Skip to content
Back to skills

Memory Patterns

ASecurity

Configure the 4-layer memory system with SQLite/FTS5/vec storage for persistent agent knowledge that survives sessions.

  • 33 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
ai-agentstypescriptsqlreactnodeapidatabasedocumentation

Works with

  • api

Security analysis

A100/100

Scanned December 5, 2026

npx -y skills add tylerjrbuell/reactive-agents-ts --skill memory-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Memory Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Memory Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tylerjrbuell-memory-patterns-reactive-agents-ts/badge)](https://www.skillsdirectory.com/skills/tylerjrbuell-memory-patterns-reactive-agents-ts)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: memory-patterns
description: Configure the 4-layer memory system with SQLite/FTS5/vec storage for persistent agent knowledge that survives sessions.
compatibility: Reactive Agents TypeScript projects using @reactive-agents/*
metadata:
  author: reactive-agents
  version: "2.0"
  tier: "capability"
---

# Memory Patterns

## Agent objective

Produce a builder with the right memory tier, database path, and tool configuration so the agent retains and retrieves knowledge correctly across interactions and sessions.

## When to load this skill

- Agent needs to remember facts across multiple `agent.run()` calls
- Agent accumulates knowledge over time (research, learning, preference tracking)
- Building a conversational agent with multi-turn context
- Agent must search past observations semantically (`recall`) or by key (`find`)

## Implementation baseline

```ts
// Standard (default tier: FTS5 keyword search, no embedding provider needed)
// A bare .withMemory() persists to ~/.reactive-agents/memory/<agentId>/memory.db
// (SQLite ":memory:" only under the test provider / NODE_ENV=test)
const agent = await ReactiveAgents.create()
  .withProvider("anthropic")
  .withReasoning({ defaultStrategy: "adaptive" })
  .withTools({ allowedTools: ["checkpoint", "recall"] })
  .withMemory()
  .build();

// Enhanced (FTS5 + vector search; needs an embedding provider and sqlite-vec), custom path
const agent = await ReactiveAgents.create()
  .withProvider("anthropic")
  .withReasoning({ defaultStrategy: "adaptive" })
  .withTools({ allowedTools: ["checkpoint", "recall", "find"] })
  .withMemory({ tier: "enhanced", dbPath: "./agent-memory.db" })
  .build();
```

## 4-layer memory architecture

All four layers exist in both tiers; the tier only picks the retrieval method (`"standard"` = FTS5 keyword search, `"enhanced"` = FTS5 + vector similarity). Full guide: https://docs.reactiveagents.dev/guides/memory/.

| Layer | Purpose | Storage |
|-------|---------|---------|
| **Working** | Current task context, active reasoning | In-memory |
| **Semantic** | Factual knowledge, SQLite + FTS5 full-text | SQLite |
| **Episodic** | Past interactions, timestamped experience log | SQLite |
| **Procedural** | Learned behaviors, skill patterns | SQLite |

## Key patterns

### Memory tiers

```ts
// Standard (default) — FTS5 keyword search, SQLite persistence
.withMemory()
.withMemory({ tier: "standard" })

// Enhanced — FTS5 + vector search, custom database path
.withMemory({ tier: "enhanced" })
.withMemory({ tier: "enhanced", dbPath: "./data/agent.db" })
.withMemory({ tier: "enhanced", dbPath: "./data/agent.db", capacity: 24 })
// capacity: working memory slots (default 7)
```

### Memory tools

```ts
// recall — semantic search over episodic + semantic memory
.withTools({ allowedTools: ["recall", "find", "checkpoint"] })

// In system prompt: guide the agent to use memory tools
.withSystemPrompt(`
  Before answering questions about past work, use recall("topic keywords").
  After completing a task, checkpoint the key findings.
`)
```

### Combining memory with RAG documents

```ts
.withDocuments([
  { source: "docs-1", content: "Product documentation..." },   // DocumentSpec: { source, content?, format?, chunkStrategy?, maxChunkSize? }
  { source: "policy-1", content: "Company policy..." },        // omit `content` to read `source` as a file path
])
.withMemory({ tier: "enhanced", dbPath: "./agent.db" })
.withTools({ allowedTools: ["find", "recall", "checkpoint"] })
// find: searches over .withDocuments() content (rag-search was removed in v0.10.0 — use find)
// find also searches semantic memory if memory is enabled
// recall: searches over past agent interactions in memory only
```

### Multi-agent memory isolation

```ts
// Give each agent a separate DB to prevent cross-contamination
const researchAgent = await ReactiveAgents.create()
  .withMemory({ tier: "enhanced", dbPath: "./memory/researcher.db" })
  .build();

const writerAgent = await ReactiveAgents.create()
  .withMemory({ tier: "enhanced", dbPath: "./memory/writer.db" })
  .build();
```

### Inspecting and editing stored memory

```ts
// Each semantic/procedural entry carries the taskId/runId of the run that wrote it.
const result = await agent.run("Summarize the deploy runbook");
const hits = await agent.memory().search("deploy", { taskId: String(result.taskId) });
await agent.memory().semantic.update(hits[0]!.id, { content: "corrected fact" });
await agent.memory().semantic.delete(hits[0]!.id);
const workflows = await agent.memory().procedural.list();
const log = await agent.memory().episodic.list({ limit: 20 });
```

## Builder API reference

| Method | Key params | Notes |
|--------|-----------|-------|
| `.withMemory(opts?)` | `{ tier?: "standard"\|"enhanced", dbPath?, capacity?, maxEntries?, evictionPolicy?, retainDays?, importanceThreshold? }` | No args = `"standard"`; bare `"1"`/`"2"` strings are deprecated, the `"standard"`/`"enhanced"` strings are not accepted as positional args |
| `.withDocuments(docs)` | `DocumentSpec[]` | RAG context — pairs with `find` tool |
| `.withExperienceLearning()` | — | Injects prior-run experience tips from episodic memory |
| `agent.memory()` | — | `search`, `semantic.*`, `procedural.*`, `episodic.list`; rejects `MemoryNotEnabledError` without `.withMemory()` |

## Pitfalls

- `.withMemory("1")` and `.withMemory("2")` are **deprecated** (they log a warning) — pass `{ tier: "standard" }` or `{ tier: "enhanced" }`
- `"enhanced"` without `dbPath` uses a default path — always set `dbPath` explicitly in multi-agent environments to prevent collisions
- `recall` requires `.withMemory()` — silently returns empty results without it
- `find` routes across multiple sources: `scope: "documents"` needs `.withDocuments()`, `scope: "memory"` needs `.withMemory()`, `scope: "web"` needs web-search enabled, `scope: "auto"` (default) tries documents first, falls back to web
- SQLite requires a writable filesystem path — check permissions before deployment
- `capacity` too low causes premature eviction of working memory; keep at 12–24 for long tasks
- `.withExperienceLearning()` requires `.withMemory()` (either tier) — without a memory layer, no experience is persisted to inject

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.