Agent skill
save-context
Save important session context to MCP memory before compaction. This skill should be used when: (1) Claude detects the conversation is getting long, (2) Before starting a risky operation, (3) After completing significant work, (4) User requests context preservation. Triggers: "save context", "preserve session", "remember this", "before we lose context", "context getting long".
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/save-context
SKILL.md
Save Context
Overview
This skill saves important session context to MCP memory, ensuring critical information survives context compaction. Use proactively when conversations get long or before significant work is lost.
When to Use
- Approaching compaction - Conversation has been long with many tool calls
- Completed milestone - Just finished implementing a feature or fix
- Complex decisions - Made architectural choices that should persist
- User request - User explicitly asks to save/preserve context
- Before risky operations - About to make breaking changes
Workflow
To save context to MCP memory:
Step 1: Gather Context
Collect key information to preserve:
- Current task status - What was being worked on
- Decisions made - Key choices and their rationale
- Files modified - Recent changes and their purpose
- Blockers/issues - Unresolved problems
- Next steps - What should happen next
Step 2: Create Entities
Use mcp__memory__create_entities() to save structured data:
// Example entities to create
entities = [
{
name: "Session_2026-01-28_TaskName",
entityType: "session_context",
observations: [
"Working on: [task description]",
"Completed: [what was done]",
"Decision: [key choice made]",
"Files: [files modified]",
"Next: [pending work]",
],
},
{
name: "Decision_FeatureName",
entityType: "architectural_decision",
observations: [
"Context: [why this came up]",
"Options considered: [list]",
"Chosen: [option]",
"Rationale: [why]",
],
},
];
Step 3: Create Relations
Link related entities:
// Example relations
relations = [
{
from: "Session_2026-01-28_TaskName",
relationType: "decided",
to: "Decision_FeatureName",
},
];
Step 4: Confirm Save
After saving, confirm what was preserved:
Saved to MCP memory:
- Session context: [summary]
- Decisions: [count]
- Relations: [count]
To retrieve later: mcp__memory__read_graph()
Entity Types
| Type | Use For |
|---|---|
session_context |
Current work status, progress, next steps |
architectural_decision |
Design choices with rationale |
bug_investigation |
Debugging context, findings, hypotheses |
feature_implementation |
Feature details, approach, progress |
user_preference |
User's stated preferences and requirements |
Naming Conventions
- Sessions:
Session_YYYY-MM-DD_BriefTaskName - Decisions:
Decision_FeatureName_Choice - Bugs:
Bug_ComponentName_Issue - Features:
Feature_FeatureName
Best Practices
- Save early, save often - Don't wait until context is about to compact
- Be concise - MCP memory has limits; focus on key information
- Use clear names - Entity names should be searchable and meaningful
- Link entities - Relations help reconstruct context later
- Include next steps - Future sessions need to know what's pending
Context Size Indicators
Watch for these signs that context is getting large:
- Many tool calls - 50+ tool uses in the session
- Large file reads - Multiple large files read
- Long conversation - Many back-and-forth exchanges
- Complex task - Multi-step implementation with decisions
When you see these, proactively suggest using /save-context.
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?