agent-memory-systems
Use this skill when implementing memory for AI agents. Activate when the user needs agents to remember past interactions, implement context persistence, build knowledge bases for agents, design agent state management, or create shared memory between multiple agents.
What this skill does
# Agent Memory Systems
Design and implement memory systems that give agents persistent knowledge and context.
## When to Use
- Agents need to remember across sessions
- Multiple agents share knowledge
- Long-running tasks require state persistence
- Building agents that learn from experience
## Memory Types
```
┌─────────────────────────────────────────────────────────────┐
│ AGENT MEMORY TAXONOMY │
├─────────────────────────────────────────────────────────────┤
│ │
│ Working Memory (Active Context) │
│ └─ Current conversation, immediate task state │
│ │
│ Short-Term Memory (Session) │
│ └─ Recent interactions, temporary facts │
│ │
│ Long-Term Memory (Persistent) │
│ ├─ Episodic: Past events, experiences │
│ ├─ Semantic: Facts, knowledge, learned info │
│ └─ Procedural: How to do things, skills │
│ │
└─────────────────────────────────────────────────────────────┘
```
## Working Memory
The agent's current context window.
```typescript
interface WorkingMemory {
// Current task context
task: {
description: string;
requirements: string[];
progress: string[];
};
// Active entities being discussed
entities: Map<string, Entity>;
// Recent messages
conversationWindow: Message[];
// Scratchpad for reasoning
scratchpad: string;
}
class WorkingMemoryManager {
private memory: WorkingMemory;
private MAX_MESSAGES = 20;
addMessage(message: Message) {
this.memory.conversationWindow.push(message);
// Evict old messages
if (this.memory.conversationWindow.length > this.MAX_MESSAGES) {
const evicted = this.memory.conversationWindow.shift();
// Optionally summarize and store
this.summarizeToShortTerm(evicted);
}
}
updateEntity(id: string, entity: Entity) {
this.memory.entities.set(id, entity);
}
getContext(): string {
return `
Task: ${this.memory.task.description}
Progress: ${this.memory.task.progress.join(', ')}
Key Entities: ${[...this.memory.entities.values()].map(e => e.summary).join('\n')}
Recent Discussion: ${this.memory.conversationWindow.slice(-5).map(m => m.content).join('\n')}
`;
}
}
```
## Short-Term Memory
Session-scoped, expires after inactivity.
```typescript
interface ShortTermMemory {
sessionId: string;
startedAt: Date;
lastAccessedAt: Date;
expiresAt: Date;
// Conversation summary
summary: string;
// Key facts learned this session
facts: Fact[];
// Decisions made
decisions: Decision[];
// Files accessed
touchedFiles: string[];
}
class ShortTermStore {
private store = new Map<string, ShortTermMemory>();
private TTL_MS = 30 * 60 * 1000; // 30 minutes
async get(sessionId: string): Promise<ShortTermMemory | null> {
const memory = this.store.get(sessionId);
if (!memory) return null;
if (Date.now() > memory.expiresAt.getTime()) {
// Expired - archive to long-term
await this.archiveToLongTerm(memory);
this.store.delete(sessionId);
return null;
}
// Touch
memory.lastAccessedAt = new Date();
memory.expiresAt = new Date(Date.now() + this.TTL_MS);
return memory;
}
async addFact(sessionId: string, fact: Fact) {
const memory = await this.getOrCreate(sessionId);
memory.facts.push(fact);
// Check if fact should be promoted to long-term
if (this.shouldPromote(fact)) {
await this.promoteToLongTerm(fact);
}
}
}
```
## Long-Term Memory
### Episodic Memory (Events/Experiences)
```typescript
interface Episode {
id: string;
timestamp: Date;
type: 'task_completed' | 'error_resolved' | 'user_feedback' | 'learning';
// What happened
description: string;
context: Record<string, unknown>;
// Outcome
outcome: 'success' | 'failure' | 'partial';
lessons: string[];
// For retrieval
embedding: number[];
tags: string[];
}
class EpisodicMemory {
private vectorStore: VectorStore;
async remember(episode: Episode): Promise<void> {
// Generate embedding for semantic search
episode.embedding = await this.embed(
`${episode.description} ${episode.lessons.join(' ')}`
);
await this.vectorStore.insert(episode);
}
async recall(query: string, limit: number = 5): Promise<Episode[]> {
const queryEmbedding = await this.embed(query);
return this.vectorStore.similaritySearch(queryEmbedding, {
limit,
threshold: 0.7
});
}
async recallByType(type: Episode['type'], limit: number = 10): Promise<Episode[]> {
return this.vectorStore.filter({ type }, { limit, orderBy: 'timestamp DESC' });
}
}
```
### Semantic Memory (Facts/Knowledge)
```typescript
interface Fact {
id: string;
subject: string;
predicate: string;
object: string;
confidence: number;
source: string;
learnedAt: Date;
lastVerified: Date;
embedding: number[];
}
class SemanticMemory {
private facts: VectorStore<Fact>;
async learn(fact: Omit<Fact, 'id' | 'embedding'>): Promise<void> {
// Check for conflicts
const existing = await this.findRelated(fact.subject, fact.predicate);
if (existing.length > 0) {
// Handle contradiction or update
await this.resolveConflict(existing, fact);
return;
}
// Store new fact
await this.facts.insert({
...fact,
id: generateId(),
embedding: await this.embed(`${fact.subject} ${fact.predicate} ${fact.object}`)
});
}
async query(question: string): Promise<Fact[]> {
// Semantic search for relevant facts
const embedding = await this.embed(question);
return this.facts.similaritySearch(embedding, { limit: 10 });
}
async getFactsAbout(subject: string): Promise<Fact[]> {
return this.facts.filter({ subject });
}
}
```
### Procedural Memory (Skills/How-To)
```typescript
interface Procedure {
id: string;
name: string;
description: string;
trigger: string; // When to use this
steps: string[];
examples: Example[];
successRate: number;
usageCount: number;
}
class ProceduralMemory {
private procedures: Map<string, Procedure> = new Map();
async findProcedure(task: string): Promise<Procedure | null> {
// Match task to known procedures
const candidates = await this.matchProcedures(task);
if (candidates.length === 0) return null;
// Return best match by success rate and relevance
return candidates.sort((a, b) =>
(b.successRate * b.relevanceScore) - (a.successRate * a.relevanceScore)
)[0];
}
async recordOutcome(procedureId: string, success: boolean): Promise<void> {
const proc = this.procedures.get(procedureId);
if (!proc) return;
// Update success rate with exponential moving average
const alpha = 0.1;
proc.successRate = alpha * (success ? 1 : 0) + (1 - alpha) * proc.successRate;
proc.usageCount++;
}
async learnProcedure(
name: string,
steps: string[],
fromEpisode: Episode
): Promise<void> {
// Create new procedure from successful episode
this.procedures.set(generateId(), {
id: generateId(),
name,
description: fromEpisode.description,
trigger: this.extractTrigger(fromEpisode),
steps,
examples: [{ input: fromEpisode.context, output: fromEpisode.outcome }],
successRate: 1.0,
usageCount: 1
});
}
}
```
## Shared Memory (Multi-Agent)
```typescript
interface SharedMemory {
// Namespace for isolation
namespace: string;
// Read/write with locking
read(key: string): Promise<unknown>;
write(key: string, value: unknown): Promise<void>;
// Atomic operations
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.