remember

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Remember - Store Decisions and Patterns

Remember - 存储决策与模式

Store important decisions, patterns, or context in the knowledge graph for future sessions. Supports tracking success/failure outcomes for building a Best Practice Library.
将重要决策、模式或上下文存储在knowledge graph中,供后续会话使用。支持追踪成功/失败结果,用于构建最佳实践库。

Architecture

架构

The remember skill uses knowledge graph as storage:
  1. Knowledge Graph: Entity and relationship storage via
    mcp__memory__create_entities
    and
    mcp__memory__create_relations
    - FREE, zero-config, always works
Benefits:
  • Zero configuration required - works out of the box
  • Explicit relationship queries (e.g., "what does X use?")
  • Cross-referencing between entities
  • No cloud dependency
Automatic Entity Extraction:
  • Extracts capitalized terms as potential entities (PostgreSQL, React, pgvector)
  • Detects agent names (database-engineer, backend-system-architect)
  • Identifies pattern names (cursor-pagination, connection-pooling)
  • Recognizes "X uses Y", "X recommends Y", "X requires Y" relationship patterns
Remember技能使用knowledge graph作为存储:
  1. Knowledge Graph:通过
    mcp__memory__create_entities
    mcp__memory__create_relations
    进行实体和关系存储 - 免费、零配置、随时可用
优势:
  • 无需配置,开箱即用
  • 支持显式关系查询(例如:“X使用了什么?”)
  • 实体间可交叉引用
  • 无云依赖
自动实体提取:
  • 提取大写术语作为潜在实体(PostgreSQL, React, pgvector)
  • 检测Agent名称(database-engineer, backend-system-architect)
  • 识别模式名称(cursor-pagination, connection-pooling)
  • 识别“X uses Y”、“X recommends Y”、“X requires Y”这类关系模式

Usage

使用方法

Store Decisions (Default)

存储决策(默认)

/remember <text>
/remember --category <category> <text>
/remember --success <text>     # Mark as successful pattern
/remember --failed <text>      # Mark as anti-pattern
/remember --success --category <category> <text>
/remember <文本内容>
/remember --category <分类> <文本内容>
/remember --success <文本内容>     # 标记为成功模式
/remember --failed <文本内容>      # 标记为反模式
/remember --success --category <分类> <文本内容>

Agent-scoped memory

Agent专属记忆

/remember --agent <agent-id> <text> # Store in agent-specific scope /remember --global <text> # Store as cross-project best practice
undefined
/remember --agent <agent-id> <文本内容> # 存储在特定Agent的专属范围内 /remember --global <文本内容> # 存储为跨项目最佳实践
undefined

Flags

标记参数

FlagBehavior
(default)Write to graph
--success
Mark as successful pattern
--failed
Mark as anti-pattern
--category <cat>
Set category
--agent <agent-id>
Scope memory to a specific agent
--global
Store as cross-project best practice
参数行为
(默认)写入图谱
--success
标记为成功模式
--failed
标记为反模式
--category <cat>
设置分类
--agent <agent-id>
将记忆限定在特定Agent范围内
--global
存储为跨项目最佳实践

Categories

分类

  • decision
    - Why we chose X over Y (default)
  • architecture
    - System design and patterns
  • pattern
    - Code conventions and standards
  • blocker
    - Known issues and workarounds
  • constraint
    - Limitations and requirements
  • preference
    - User/team preferences
  • pagination
    - Pagination strategies
  • database
    - Database patterns
  • authentication
    - Auth approaches
  • api
    - API design patterns
  • frontend
    - Frontend patterns
  • performance
    - Performance optimizations
  • decision
    - 我们选择X而非Y的原因(默认)
  • architecture
    - 系统设计与模式
  • pattern
    - 代码规范与标准
  • blocker
    - 已知问题与解决方法
  • constraint
    - 限制条件与需求
  • preference
    - 用户/团队偏好
  • pagination
    - 分页策略
  • database
    - 数据库模式
  • authentication
    - 认证方案
  • api
    - API设计模式
  • frontend
    - 前端模式
  • performance
    - 性能优化

Outcome Flags

结果标记

  • --success
    - Pattern that worked well (positive outcome)
  • --failed
    - Pattern that caused problems (anti-pattern)
If neither flag is provided, the memory is stored as neutral (informational).
  • --success
    - 效果良好的模式(正向结果)
  • --failed
    - 引发问题的模式(反模式)
如果未提供任一标记,记忆将被存储为中性(仅信息性内容)。

Workflow

工作流程

1. Parse Input

1. 解析输入

Check for --success flag → outcome: success
Check for --failed flag → outcome: failed
Check for --category <category> flag
Check for --agent <agent-id> flag → agent_id: "ork:{agent-id}"
Check for --global flag → use global user_id
Extract the text to remember
If no category specified, auto-detect from content
检查是否存在--success标记 → 结果:success
检查是否存在--failed标记 → 结果:failed
检查是否存在--category <分类>标记
检查是否存在--agent <agent-id>标记 → agent_id: "ork:{agent-id}"
检查是否存在--global标记 → 使用全局user_id
提取需要记忆的文本内容
如果未指定分类,从内容中自动检测

2. Auto-Detect Category

2. 自动检测分类

KeywordsCategory
chose, decided, selecteddecision
architecture, design, systemarchitecture
pattern, convention, stylepattern
blocked, issue, bug, workaroundblocker
must, cannot, required, constraintconstraint
pagination, cursor, offset, pagepagination
database, sql, postgres, querydatabase
auth, jwt, oauth, token, sessionauthentication
api, endpoint, rest, graphqlapi
react, component, frontend, uifrontend
performance, slow, fast, cacheperformance
关键词分类
chose, decided, selecteddecision
architecture, design, systemarchitecture
pattern, convention, stylepattern
blocked, issue, bug, workaroundblocker
must, cannot, required, constraintconstraint
pagination, cursor, offset, pagepagination
database, sql, postgres, querydatabase
auth, jwt, oauth, token, sessionauthentication
api, endpoint, rest, graphqlapi
react, component, frontend, uifrontend
performance, slow, fast, cacheperformance

3. Extract Lesson (for anti-patterns)

3. 提取经验教训(针对反模式)

If outcome is "failed", look for:
  • "should have", "instead use", "better to"
  • If not found, prompt user: "What should be done instead?"
如果结果为“failed”,查找以下内容:
  • "should have", "instead use", "better to"
  • 如果未找到,提示用户:“应该改用什么方案?”

4. Extract Entities from Text

4. 从文本中提取实体

Step A: Detect entities:
1. Find capitalized terms (PostgreSQL, React, FastAPI)
2. Find agent names (database-engineer, backend-system-architect)
3. Find pattern names (cursor-pagination, connection-pooling)
4. Find technology keywords (pgvector, HNSW, RAG)
Step B: Detect relationship patterns:
PatternRelation Type
"X uses Y"USES
"X recommends Y"RECOMMENDS
"X requires Y"REQUIRES
"X enables Y"ENABLES
"X prefers Y"PREFERS
"chose X over Y"CHOSE_OVER
"X for Y"USED_FOR
步骤A:检测实体:
1. 查找大写术语(PostgreSQL, React, FastAPI)
2. 查找Agent名称(database-engineer, backend-system-architect)
3. 查找模式名称(cursor-pagination, connection-pooling)
4. 查找技术关键词(pgvector, HNSW, RAG)
步骤B:检测关系模式:
模式关系类型
"X uses Y"USES
"X recommends Y"RECOMMENDS
"X requires Y"REQUIRES
"X enables Y"ENABLES
"X prefers Y"PREFERS
"chose X over Y"CHOSE_OVER
"X for Y"USED_FOR

5. Create Graph Entities (PRIMARY)

5. 创建图谱实体(核心步骤)

Use
mcp__memory__create_entities
:
json
{
  "entities": [
    {
      "name": "pgvector",
      "entityType": "Technology",
      "observations": ["Used for vector search", "From remember: '{original text}'"]
    },
    {
      "name": "database-engineer",
      "entityType": "Agent",
      "observations": ["Recommends pgvector for RAG"]
    }
  ]
}
Entity Type Assignment:
  • Capitalized single words ending in common suffixes: Technology (PostgreSQL, FastAPI)
  • Words with hyphens matching agent pattern: Agent (database-engineer)
  • Words with hyphens matching pattern names: Pattern (cursor-pagination)
  • Project context: Project (current project name)
  • Failed patterns: AntiPattern
使用
mcp__memory__create_entities
json
{
  "entities": [
    {
      "name": "pgvector",
      "entityType": "Technology",
      "observations": ["Used for vector search", "From remember: '{original text}'"]
    },
    {
      "name": "database-engineer",
      "entityType": "Agent",
      "observations": ["Recommends pgvector for RAG"]
    }
  ]
}
实体类型分配:
  • 以常见后缀结尾的大写单个单词:Technology(PostgreSQL, FastAPI)
  • 符合Agent模式的带连字符单词:Agent(database-engineer)
  • 符合模式名称的带连字符单词:Pattern(cursor-pagination)
  • 项目上下文:Project(当前项目名称)
  • 失败的模式:AntiPattern

6. Create Graph Relations

6. 创建图谱关系

Use
mcp__memory__create_relations
:
json
{
  "relations": [
    {
      "from": "database-engineer",
      "to": "pgvector",
      "relationType": "RECOMMENDS"
    },
    {
      "from": "pgvector",
      "to": "RAG",
      "relationType": "USED_FOR"
    }
  ]
}
使用
mcp__memory__create_relations
json
{
  "relations": [
    {
      "from": "database-engineer",
      "to": "pgvector",
      "relationType": "RECOMMENDS"
    },
    {
      "from": "pgvector",
      "to": "RAG",
      "relationType": "USED_FOR"
    }
  ]
}

7. Confirm Storage

7. 确认存储

For success:
✅ Remembered SUCCESS (category): "summary of text"
   → Stored in knowledge graph
   → Created entity: {entity_name} ({entity_type})
   → Created relation: {from} → {relation_type} → {to}
   📊 Graph: {N} entities, {M} relations
For failed:
❌ Remembered ANTI-PATTERN (category): "summary of text"
   → Stored in knowledge graph
   → Created entity: {anti-pattern-name} (AntiPattern)
   💡 Lesson: {lesson if extracted}
For neutral:
✓ Remembered (category): "summary of text"
   → Stored in knowledge graph
   → Created entity: {entity_name} ({entity_type})
   📊 Graph: {N} entities, {M} relations
成功结果:
✅ 已记录成功模式(分类):"文本摘要"
   → 已存储在knowledge graph中
   → 已创建实体:{entity_name} ({entity_type})
   → 已创建关系:{from} → {relation_type} → {to}
   📊 图谱:{N}个实体,{M}个关系
失败结果:
❌ 已记录反模式(分类):"文本摘要"
   → 已存储在knowledge graph中
   → 已创建实体:{anti-pattern-name} (AntiPattern)
   💡 经验教训:{提取到的经验教训}
中性结果:
✓ 已记录(分类):"文本摘要"
   → 已存储在knowledge graph中
   → 已创建实体:{entity_name} ({entity_type})
   📊 图谱:{N}个实体,{M}个关系

Examples

示例

Basic Remember (Graph Only)

基础记忆(仅图谱存储)

Input:
/remember Cursor-based pagination scales well for large datasets
Output:
✓ Remembered (pagination): "Cursor-based pagination scales well for large datasets"
   → Stored in knowledge graph
   → Created entity: cursor-pagination (Pattern)
   📊 Graph: 1 entity, 0 relations
输入:
/remember Cursor-based pagination scales well for large datasets
输出:
✓ 已记录(pagination):"Cursor-based pagination scales well for large datasets"
   → 已存储在knowledge graph中
   → 已创建实体:cursor-pagination (Pattern)
   📊 图谱:1个实体,0个关系

Anti-Pattern

反模式示例

Input:
/remember --failed Offset pagination caused timeouts on tables with 1M+ rows
Output:
❌ Remembered ANTI-PATTERN (pagination): "Offset pagination caused timeouts on tables with 1M+ rows"
   → Stored in knowledge graph
   → Created entity: offset-pagination (AntiPattern)
   💡 Lesson: Use cursor-based pagination for large datasets
   📊 Graph: 1 entity, 0 relations
输入:
/remember --failed Offset pagination caused timeouts on tables with 1M+ rows
输出:
❌ 已记录反模式(pagination):"Offset pagination caused timeouts on tables with 1M+ rows"
   → 已存储在knowledge graph中
   → 已创建实体:offset-pagination (AntiPattern)
   💡 经验教训:对大型数据集使用cursor-based pagination
   📊 图谱:1个实体,0个关系

Agent-Scoped Memory

Agent专属记忆示例

Input:
/remember --agent backend-system-architect Use connection pooling with min=5, max=20
Output:
✓ Remembered (database): "Use connection pooling with min=5, max=20"
   → Stored in knowledge graph
   → Created entity: connection-pooling (Pattern)
   → Created relation: project → USES → connection-pooling
   📊 Graph: 1 entity, 1 relation
   🤖 Agent: backend-system-architect
输入:
/remember --agent backend-system-architect Use connection pooling with min=5, max=20
输出:
✓ 已记录(database):"Use connection pooling with min=5, max=20"
   → 已存储在knowledge graph中
   → 已创建实体:connection-pooling (Pattern)
   → 已创建关系:project → USES → connection-pooling
   📊 图谱:1个实体,1个关系
   🤖 Agent:backend-system-architect

Duplicate Detection

重复检测

Before storing, search for similar patterns in graph:
  1. Query graph with
    mcp__memory__search_nodes
    for entity names
  2. If exact entity exists:
    • Add observation to existing entity via
      mcp__memory__add_observations
    • Inform user: "✓ Updated existing entity (added observation)"
  3. If similar pattern found with opposite outcome:
    • Warn: "⚠️ This conflicts with an existing pattern. Store anyway?"
存储前,在图谱中搜索相似模式:
  1. 使用
    mcp__memory__search_nodes
    查询图谱中的实体名称
  2. 如果存在完全匹配的实体:
    • 通过
      mcp__memory__add_observations
      为现有实体添加观测记录
    • 告知用户:"✓ 已更新现有实体(添加观测记录)"
  3. 如果发现结果相反的相似模式:
    • 警告:"⚠️ 该模式与现有模式存在冲突。是否仍要存储?"

File-Based Memory Updates

基于文件的记忆更新

When updating
.claude/memory/MEMORY.md
or project memory files:
  • PREFER Edit over Write to preserve existing content and avoid overwriting
  • Use stable anchor lines:
    ## Recent Decisions
    ,
    ## Patterns
    ,
    ## Preferences
  • See the
    memory
    skill's "Permission-Free File Operations" section for the full Edit pattern
  • This applies to the calling agent's file operations, not to the knowledge graph operations above

更新
.claude/memory/MEMORY.md
或项目记忆文件时:
  • 优先使用编辑而非覆盖,以保留现有内容,避免覆写
  • 使用稳定的锚定行:
    ## Recent Decisions
    ,
    ## Patterns
    ,
    ## Preferences
  • 查看
    memory
    技能的“无权限文件操作”章节,了解完整的编辑模式
  • 此规则适用于调用Agent的文件操作,而非上述knowledge graph操作

Related Skills

相关技能

  • memory
    - Search, load, sync, visualize (read-side operations)
  • memory
    - 搜索、加载、同步、可视化(读取操作)

Error Handling

错误处理

  • If knowledge graph unavailable, show configuration instructions
  • If text is empty, ask user to provide something to remember
  • If text >2000 chars, truncate with notice
  • If both --success and --failed provided, ask user to clarify
  • If --agent used without agent-id, prompt for agent selection
  • If entity extraction fails, create a generic Decision entity
  • If relation creation fails (e.g., entity doesn't exist), create entities first then retry
  • 如果knowledge graph不可用,显示配置说明
  • 如果文本为空,提示用户提供需要记忆的内容
  • 如果文本超过2000字符,截断并通知用户
  • 如果同时提供--success和--failed标记,提示用户明确选择
  • 如果使用--agent但未提供agent-id,提示用户选择Agent
  • 如果实体提取失败,创建通用的Decision实体
  • 如果关系创建失败(例如:实体不存在),先创建实体再重试