AgentSkillsCN

memory-management

AgentDB 内存系统结合 HNSW 向量检索引擎,可在学习与知识管理领域提供 150 倍至 12,500 倍的模式检索速度,同时兼具持久化存储与语义搜索能力。适用场景:需要存储成功模式、查找相似解决方案、对过往工作进行语义查询、从先前任务中汲取经验、在智能体间共享知识、构建知识库时使用。若无需学习、仅执行一次性临时任务、已有外部数据源可用,或仅需进行只读探索,则可跳过此步骤。

SKILL.md
--- frontmatter
name: memory-management
description: >
  AgentDB memory system with HNSW vector search. Provides 150x-12,500x faster pattern retrieval, persistent storage, and semantic search capabilities for learning and knowledge management.
  Use when: need to store successful patterns, searching for similar solutions, semantic lookup of past work, learning from previous tasks, sharing knowledge between agents, building knowledge base.
  Skip when: no learning needed, ephemeral one-off tasks, external data sources available, read-only exploration.

Memory Management Skill

Purpose

AgentDB memory system with HNSW vector search. Provides 150x-12,500x faster pattern retrieval, persistent storage, and semantic search capabilities for learning and knowledge management.

When to Trigger

  • need to store successful patterns
  • searching for similar solutions
  • semantic lookup of past work
  • learning from previous tasks
  • sharing knowledge between agents
  • building knowledge base

When to Skip

  • no learning needed
  • ephemeral one-off tasks
  • external data sources available
  • read-only exploration

Commands

Store Pattern

Store a pattern or knowledge item in memory

bash
npx @claude-flow/cli memory store --key "[key]" --value "[value]" --namespace patterns

Example:

bash
npx @claude-flow/cli memory store --key "auth-jwt-pattern" --value "JWT validation with refresh tokens" --namespace patterns

Semantic Search

Search memory using semantic similarity

bash
npx @claude-flow/cli memory search --query "[search terms]" --limit 10

Example:

bash
npx @claude-flow/cli memory search --query "authentication best practices" --limit 5

Retrieve Entry

Retrieve a specific memory entry by key

bash
npx @claude-flow/cli memory get --key "[key]" --namespace [namespace]

Example:

bash
npx @claude-flow/cli memory get --key "auth-jwt-pattern" --namespace patterns

List Entries

List all entries in a namespace

bash
npx @claude-flow/cli memory list --namespace [namespace]

Example:

bash
npx @claude-flow/cli memory list --namespace patterns --limit 20

Delete Entry

Delete a memory entry

bash
npx @claude-flow/cli memory delete --key "[key]" --namespace [namespace]

Initialize HNSW Index

Initialize HNSW vector search index

bash
npx @claude-flow/cli memory init --enable-hnsw

Memory Stats

Show memory usage statistics

bash
npx @claude-flow/cli memory stats

Export Memory

Export memory to JSON

bash
npx @claude-flow/cli memory export --output memory-backup.json

Scripts

ScriptPathDescription
memory-backup.agents/scripts/memory-backup.shBackup memory to external storage
memory-consolidate.agents/scripts/memory-consolidate.shConsolidate and optimize memory

References

DocumentPathDescription
HNSW Guidedocs/hnsw.mdHNSW vector search configuration
Memory Schemadocs/memory-schema.mdMemory namespace and schema reference

Best Practices

  1. Check memory for existing patterns before starting
  2. Use hierarchical topology for coordination
  3. Store successful patterns after completion
  4. Document any new learnings