Agent skill
memory-management
Use when saving or retrieving important patterns, decisions, and learnings across sessions. Triggers on keywords like "remember", "save pattern", "recall", "memory", "persist", "knowledge base", "learnings".
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/memory-management
SKILL.md
Memory Management & Knowledge Persistence
Build and maintain a knowledge graph of patterns, decisions, and learnings across sessions.
Memory Entity Types
| Entity Type | Purpose | Examples |
|---|---|---|
Pattern |
Recurring code patterns | CQRS, Validation, Repository |
Decision |
Architectural/design decisions | Why we chose X over Y |
BugFix |
Bug solutions for future reference | Race condition fixes |
ServiceBoundary |
Service ownership and responsibilities | TextSnippet owns Snippets |
SessionSummary |
End-of-session progress snapshots | Task progress, next steps |
Dependency |
Cross-service dependencies | TextSnippet depends on Accounts |
AntiPattern |
Patterns to avoid | Don't call side effects in cmd |
Memory Operations
Create New Entity
mcp__memory__create_entities([
{
name: 'EmployeeValidationPattern',
entityType: 'Pattern',
observations: [
'Use PlatformValidationResult fluent API',
'Chain with .And() and .AndAsync()',
"Return validation result, don't throw",
'Location: Growth.Application/UseCaseCommands/'
]
}
]);
Create Relationships
mcp__memory__create_relations([
{
from: 'TextSnippetService',
to: 'AccountsService',
relationType: 'depends_on'
},
{
from: 'EmployeeEntity',
to: 'UserEntity',
relationType: 'syncs_from'
}
]);
Add Observations
mcp__memory__add_observations([
{
entityName: 'EmployeeValidationPattern',
contents: ['Also supports .AndNot() for negative validation', 'Use .Of<IPlatformCqrsRequest>() for type conversion']
}
]);
Search Knowledge
// Search by query
mcp__memory__search_nodes({ query: 'validation pattern' });
// Open specific entities
mcp__memory__open_nodes({ names: ['EmployeeValidationPattern', 'TextSnippetService'] });
// Read entire graph
mcp__memory__read_graph();
Delete Outdated Knowledge
// Delete entities
mcp__memory__delete_entities({ entityNames: ['OutdatedPattern'] });
// Delete specific observations
mcp__memory__delete_observations([
{
entityName: 'EmployeeValidationPattern',
observations: ['Outdated observation text']
}
]);
// Delete relations
mcp__memory__delete_relations([
{
from: 'OldService',
to: 'NewService',
relationType: 'depends_on'
}
]);
When to Save to Memory
Always Save
- Discovered Patterns: New code patterns not in documentation
- Bug Solutions: Complex bugs with non-obvious solutions
- Service Boundaries: Which service owns what
- Architectural Decisions: Why a particular approach was chosen
- Anti-Patterns: Mistakes to avoid
Save at Session End
// Session summary template
mcp__memory__create_entities([
{
name: `Session_${taskName}_${date}`,
entityType: 'SessionSummary',
observations: [
`Task: ${taskDescription}`,
`Completed: ${completedItems.join(', ')}`,
`Remaining: ${remainingItems.join(', ')}`,
`Key Files: ${keyFiles.join(', ')}`,
`Discoveries: ${discoveries.join(', ')}`,
`Next Steps: ${nextSteps.join(', ')}`
]
}
]);
Memory Retrieval Patterns
Session Start Protocol
// 1. Search for related context
const results = mcp__memory__search_nodes({
query: 'current feature or task keywords'
});
// 2. Load relevant entities
mcp__memory__open_nodes({
names: results.entities.map(e => e.name)
});
// 3. Check for incomplete sessions
mcp__memory__search_nodes({ query: 'SessionSummary Remaining' });
Before Implementation
// Check for existing patterns
mcp__memory__search_nodes({ query: 'CQRS command pattern' });
// Check for anti-patterns
mcp__memory__search_nodes({ query: 'AntiPattern command' });
// Check for related decisions
mcp__memory__search_nodes({ query: 'Decision validation' });
After Bug Fix
// Save the fix
mcp__memory__create_entities([
{
name: `BugFix_${bugName}`,
entityType: 'BugFix',
observations: [
`Symptom: ${symptomDescription}`,
`Root Cause: ${rootCause}`,
`Solution: ${solution}`,
`Files: ${affectedFiles.join(', ')}`,
`Prevention: ${preventionTip}`
]
}
]);
Knowledge Graph Structure
┌─────────────────────────────────────────────────────────────┐
│ EasyPlatform Knowledge │
├─────────────────────────────────────────────────────────────┤
│ Services │
│ ├── TextSnippetService ──depends_on──> AccountsService │
│ ├── TalentsService ──depends_on──> AccountsService │
│ └── SurveysService ──depends_on──> AccountsService │
│ │
│ Patterns │
│ ├── CQRSCommandPattern │
│ ├── CQRSQueryPattern │
│ ├── EntityEventPattern │
│ └── ValidationPattern │
│ │
│ Entities │
│ ├── Employee ──syncs_from──> User │
│ ├── Company ──syncs_from──> Organization │
│ └── LeaveRequest ──owned_by──> TextSnippetService │
│ │
│ Sessions │
│ ├── Session_LeaveRequest_2025-01-15 │
│ └── Session_EmployeeImport_2025-01-14 │
└─────────────────────────────────────────────────────────────┘
Importance Scoring
When saving observations, prioritize:
| Score | Criteria |
|---|---|
| 10 | Critical bug fixes, security issues |
| 8-9 | Architectural decisions, service boundaries |
| 6-7 | Code patterns, best practices |
| 4-5 | Session summaries, progress notes |
| 1-3 | Temporary notes, exploration results |
Memory Maintenance
Weekly Cleanup
// Find old session summaries (> 30 days)
mcp__memory__search_nodes({ query: 'SessionSummary' });
// Delete outdated sessions
mcp__memory__delete_entities({
entityNames: ['Session_OldTask_2024-12-01']
});
Consolidation
When multiple observations cover same topic:
// 1. Read existing entity
mcp__memory__open_nodes({ names: ['PatternName'] });
// 2. Delete fragmented observations
mcp__memory__delete_observations([
{
entityName: 'PatternName',
observations: ['Fragment 1', 'Fragment 2']
}
]);
// 3. Add consolidated observation
mcp__memory__add_observations([
{
entityName: 'PatternName',
contents: ['Consolidated comprehensive observation']
}
]);
Quick Reference
Create: mcp__memory__create_entities / mcp__memory__create_relations
Read: mcp__memory__read_graph / mcp__memory__open_nodes / mcp__memory__search_nodes
Update: mcp__memory__add_observations
Delete: mcp__memory__delete_entities / mcp__memory__delete_observations / mcp__memory__delete_relations
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?