Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement persistent memory patterns for AI agents using AgentDB. Includes session memory, long-term storage, pattern learning, and context management. Use when building stateful agents, chat systems, or intelligent assistants.
.claude/skills/ruvnet-agentdb-memory-patterns/SKILL.md| Model | Eval pass | Runs |
|---|---|---|
| gemini-3.6-flash | 100% | 4 |
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 414% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 166% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 155% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 52% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 236% | 0% |
Provides memory management patterns for AI agents using AgentDB's persistent storage and ReasoningBank integration. Enables agents to remember conversations, learn from interactions, and maintain context across sessions.
Performance: 150x-12,500x faster than traditional solutions with 100% backward compatibility.
bash# Initialize vector database npx agentdb@latest init .$agents.db # Or with custom dimensions npx agentdb@latest init .$agents.db --dimension 768 # Use preset configurations npx agentdb@latest init .$agents.db --preset large # In-memory database for testing npx agentdb@latest init .$memory.db --in-memory
bash# Start MCP server (integrates with Claude Code) npx agentdb@latest mcp # Add to Claude Code (one-time setup) claude mcp add agentdb npx agentdb@latest mcp
bash# Interactive plugin wizard npx agentdb@latest create-plugin # Use template directly npx agentdb@latest create-plugin -t decision-transformer -n my-agent # Available templates: # - decision-transformer (sequence modeling RL) # - q-learning (value-based learning) # - sarsa (on-policy TD learning) # - actor-critic (policy gradient) # - curiosity-driven (exploration-based)
typescriptimport { createAgentDBAdapter } from 'agentic-flow$reasoningbank'; // Initialize with default configuration const adapter = await createAgentDBAdapter({ dbPath: '.agentdb$reasoningbank.db', enableLearning: true, // Enable learning plugins enableReasoning: true, // Enable reasoning agents quantizationType: 'scalar', // binary | scalar | product | none cacheSize: 1000, // In-memory cache }); // Store interaction memory const patternId = await adapter.insertPattern({ id: '', type: 'pattern', domain: 'conversation', pattern_data: JSON.stringify({ embedding: await computeEmbedding('What is the capital of France?'), pattern: { user: 'What is the capital of France?', assistant: 'The capital of France is Paris.', timestamp: Date.now() } }), confidence: 0.95, usage_count: 1, success_count: 1, created_at: Date.now(), last_used: Date.now(), }); // Retrieve context with reasoning const context = await adapter.retrieveWithReasoning(queryEmbedding, { domain: 'conversation', k: 10, useMMR: true, // Maximal Marginal Relevance synthesizeContext: true, // Generate rich context });
typescriptclass SessionMemory { async storeMessage(role: string, content: string) { return await db.storeMemory({ sessionId: this.sessionId, role, content, timestamp: Date.now() }); } async getSessionHistory(limit = 20) { return await db.query({ filters: { sessionId: this.sessionId }, orderBy: 'timestamp', limit }); } }
typescript// Store important facts await db.storeFact({ category: 'user_preference', key: 'language', value: 'English', confidence: 1.0, source: 'explicit' }); // Retrieve facts const prefs = await db.getFacts({ category: 'user_preference' });
typescript// Learn from successful interactions await db.storePattern({ trigger: 'user_asks_time', response: 'provide_formatted_time', success: true, context: { timezone: 'UTC' } }); // Apply learned patterns const pattern = await db.matchPattern(currentContext);
typescript// Organize memory in hierarchy await memory.organize({ immediate: recentMessages, // Last 10 messages shortTerm: sessionContext, // Current session longTerm: importantFacts, // Persistent facts semantic: embeddedKnowledge // Vector search });
typescript// Periodically consolidate memories await memory.consolidate({ strategy: 'importance', // Keep important memories maxSize: 10000, // Size limit minScore: 0.5 // Relevance threshold });
bash# Query with vector embedding npx agentdb@latest query .$agents.db "[0.1,0.2,0.3,...]" # Top-k results npx agentdb@latest query .$agents.db "[0.1,0.2,0.3]" -k 10 # With similarity threshold npx agentdb@latest query .$agents.db "0.1 0.2 0.3" -t 0.75 # JSON output npx agentdb@latest query .$agents.db "[...]" -f json
bash# Export vectors to file npx agentdb@latest export .$agents.db .$backup.json # Import vectors from file npx agentdb@latest import .$backup.json # Get database statistics npx agentdb@latest stats .$agents.db
bash# Run performance benchmarks npx agentdb@latest benchmark # Results show: # - Pattern Search: 150x faster (100µs vs 15ms) # - Batch Insert: 500x faster (2ms vs 1s) # - Large-scale Query: 12,500x faster (8ms vs 100s)
typescriptimport { createAgentDBAdapter, migrateToAgentDB } from 'agentic-flow$reasoningbank'; // Migrate from legacy ReasoningBank const result = await migrateToAgentDB( '.swarm$memory.db', // Source (legacy) '.agentdb$reasoningbank.db' // Destination (AgentDB) ); console.log(`✅ Migrated ${result.patternsMigrated} patterns`); // Train learning model const adapter = await createAgentDBAdapter({ enableLearning: true, }); await adapter.train({ epochs: 50, batchSize: 32, }); // Get optimal strategy with reasoning const result = await adapter.retrieveWithReasoning(queryEmbedding, { domain: 'task-planning', synthesizeContext: true, optimizeMemory: true, });
bash# List available plugins npx agentdb@latest list-plugins # List plugin templates npx agentdb@latest list-templates # Get plugin info npx agentdb@latest plugin-info <name>
stats command to track performancebash# Check database size npx agentdb@latest stats .$agents.db # Enable quantization # Use 'binary' (32x smaller) or 'scalar' (4x smaller)
bash# Enable HNSW indexing and caching # Results: <100µs search time
bash# Automatic migration with validation npx agentdb@latest migrate --source .swarm$memory.db
npx agentdb@latest mcp for Claude Code| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-20 | pass→pass | 7,456 | 5,566 | -25% | 1 | 1 | 0% | 1,415 | 3,422 | +142% | 0 | 0 | — |
case-01 | fail→pass | 3,485 | 2,544 | -27% | 1 | 1 | 0% | 523 | 2,687 | +414% | 0 | 0 | — |
case-02 | fail→pass | 6,432 | 5,299 | -18% | 1 | 1 | 0% | 1,327 | 3,530 | +166% | 0 | 0 | — |
case-03 | fail→pass | 5,922 | 3,120 | -47% | 1 | 1 | 0% | 1,150 | 2,927 | +155% | 0 | 0 | — |
case-04 | fail→pass | 9,601 | 3,260 | -66% | 1 | 1 | 0% | 1,930 | 2,932 | +52% | 0 | 0 | — |
case-05 | fail→pass | 4,196 | 1,717 | -59% | 1 | 1 | 0% | 789 | 2,653 | +236% | 0 | 0 | — |
case-06 | fail→pass | 8,722 | 1,275 | -85% | 1 | 1 | 0% | 1,627 | 2,505 | +54% | 0 | 0 | — |
case-07 | fail→pass | 22,258 | 7,497 | -66% | 1 | 1 | 0% | 2,807 | 4,011 | +43% | 0 | 0 | — |
case-08 | fail→pass | 8,939 | 4,968 | -44% | 1 | 1 | 0% | 1,747 | 3,365 | +93% | 0 | 0 | — |
case-09 | pass→pass | 12,046 | 5,537 | -54% | 1 | 1 | 0% | 2,282 | 3,366 | +48% | 0 | 0 | — |
case-10 | pass→fail | 18,476 | 16,581 | -10% | 1 | 1 | 0% | 3,887 | 5,890 | +52% | 0 | 0 | — |
case-11 | fail→pass | 11,410 | 8,687 | -24% | 1 | 1 | 0% | 2,484 | 4,258 | +71% | 0 | 0 | — |
case-12 | fail→pass | 4,462 | 1,567 | -65% | 1 | 1 | 0% | 907 | 2,573 | +184% | 0 | 0 | — |
case-13 | fail→pass | 10,781 | 2,774 | -74% | 1 | 1 | 0% | 1,969 | 2,715 | +38% | 0 | 0 | — |
case-14 | fail→pass | 6,542 | 2,054 | -69% | 1 | 1 | 0% | 1,301 | 2,613 | +101% | 0 | 0 | — |
case-15 | pass→pass | 13,325 | 2,084 | -84% | 1 | 1 | 0% | 2,305 | 2,634 | +14% | 0 | 0 | — |
case-16 | fail→fail | 11,516 | 8,547 | -26% | 1 | 1 | 0% | 2,386 | 4,293 | +80% | 0 | 0 | — |
case-17 | fail→pass | 14,153 | 9,575 | -32% | 1 | 1 | 0% | 2,634 | 4,391 | +67% | 0 | 0 | — |
case-18 | fail→pass | 5,496 | 1,461 | -73% | 1 | 1 | 0% | 866 | 2,549 | +194% | 0 | 0 | — |
case-19 | fail→fail | 8,205 | 2,691 | -67% | 1 | 1 | 0% | 1,634 | 2,766 | +69% | 0 | 0 | — |
case-21 | pass→pass | 13,511 | 9,238 | -32% | 1 | 1 | 0% | 2,787 | 4,199 | +51% | 0 | 0 | — |
case-22 | fail→fail | 7,165 | 5,502 | -23% | 1 | 1 | 0% | 1,469 | 3,406 | +132% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +59 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.