一键导入
memory-patterns
mem0 integration patterns — when to use memory, hook-based auto-capture, scoping strategy, and practical examples per agent type
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
mem0 integration patterns — when to use memory, hook-based auto-capture, scoping strategy, and practical examples per agent type
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Resolving PR review comments and merging stacked PRs — gathering all feedback, addressing every finding, delegating to expert subagents, managing review states, and merging bottom-to-top
Stacked PR workflow with vanilla Git — creating and managing PR stacks, parallel stacks with git worktrees, propagating fixes up a stack, and safe merging bottom-to-top
Resolving PR review comments and merging stacked PRs — gathering all feedback, addressing every finding, delegating to expert subagents, managing review states, and merging bottom-to-top
Stacked PR workflow with vanilla Git — creating and managing PR stacks, parallel stacks with git worktrees, propagating fixes up a stack, and safe merging bottom-to-top
GitHub development workflow — issue discipline, commit format, pre-PR conformance gate, gh CLI recipes, and PR review handling
Writing well-structured GitHub issues — standard templates, removal issue discipline, design doc references, test update requirements, epic sizing, and dependency declaration
| name | memory-patterns |
| description | mem0 integration patterns — when to use memory, hook-based auto-capture, scoping strategy, and practical examples per agent type |
Load this skill when working with persistent memory or setting up memory automation.
mem0 provides persistent memory across sessions through an MCP server. Memories are shared across all agents (user_id scope by default) and survive context compaction, session restarts, and even project switches.
Store information that should persist across sessions:
Search memories when:
Use hooks to automatically capture memories at key points. Reference implementations available in .claude/hooks/examples/ (copy and customize).
After Edit/Write operations, extract code style preferences:
PostToolUse:
- matcher: "Edit|Write"
hooks:
- type: command
command: "$CLAUDE_PROJECT_DIR/.claude/hooks/examples/capture-code-style.sh"
What it captures:
Before context compaction, save important information that would be lost:
PreCompact:
- hooks:
- type: command
command: "$CLAUDE_PROJECT_DIR/.claude/hooks/examples/preserve-context.sh"
What it captures:
At session end, create searchable summary:
SessionEnd:
- hooks:
- type: command
command: "$CLAUDE_PROJECT_DIR/.claude/hooks/examples/session-summary.sh"
What it captures:
After each agent response, optionally extract insights:
Stop:
- hooks:
- type: command
command: "$CLAUDE_PROJECT_DIR/.claude/hooks/examples/conversation-insights.sh"
Use sparingly - fires frequently. Best for:
Default scope: user_id (shared across all agents)
# Add memory (visible to all agents)
mem0_add_memory(
text="User prefers functional components over class components in React",
user_id="default" # Shared across agents
)
# Search memories (all agents can find this)
mem0_search_memories(
query="React component preferences"
)
When to use agent_id scope:
# Agent-specific memory
mem0_add_memory(
text="@llm-engineer: qwen3:4b performs better than llama3.3:8b for structured output on this project",
agent_id="llm-engineer"
)
When to delete:
# Clean up outdated memories
mem0_delete_all_memories(user_id="default") # Nuclear option
mem0_delete_memory(memory_id="specific_id") # Surgical removal
When to update:
mem0_update_memory(
memory_id="abc123",
text="Updated: User prefers 88-char line length (not 80)"
)
Store: Architectural decisions, design trade-offs, refactoring strategies Search: Before proposing major structural changes Example: "We chose SQLAlchemy over raw SQL for maintainability despite performance cost"
Store: Model performance observations, effective prompt patterns, provider quirks Search: Before choosing models or designing prompts Example: "Small models (4B) outperform 8B on structured output with constrained generation"
Store: Successful prompt templates, few-shot examples that worked Search: When designing new prompts for similar tasks Example: "Chain-of-thought prompting reduces hallucination for small models on this task"
Store: Security patterns found in codebase, vulnerabilities discovered, fixes applied Search: Before auditing similar code Example: "This project uses cryptography library for password hashing, not bcrypt"
Store: PR merge patterns, team reviewer preferences, CI/CD quirks Search: Before creating PRs or releases Example: "Team prefers squash merges, always tag @reviewer-name for API changes"
Store: UI/UX decisions, user feedback, component patterns Search: Before implementing similar UI features Example: "User prefers spinner over progress bar for indeterminate operations"
❌ Don't store ephemeral state (current file contents, temporary variables) ❌ Don't duplicate information already in AGENTS.md or project docs ❌ Don't store too frequently (creates noise, use PreCompact instead) ❌ Don't forget to search before storing similar information ✅ Do store decisions with context (why, not just what) ✅ Do use descriptive memory text (searchable, specific) ✅ Do review memories periodically (delete outdated information)