- commands/save-memories.md: slash command that analyzes session context, finds cutoff point from last memory save, gates on value, and spawns memory-saver agent in background with structured summary - agents/memory-saver.md: sonnet-based agent that stores cognitive memories from structured summaries via MCP tools or CLI fallback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2.7 KiB
| allowed-tools | description |
|---|---|
| Task | Save session learnings to cognitive memory |
Analyze the current conversation and create a structured session summary, then delegate memory storage to the memory-saver agent.
Step 1: Find the cutoff point
Scan the conversation for the most recent memory_store MCP call or claude-memory store Bash call. If found, only analyze the conversation AFTER that point — everything before it has already been captured. If no prior memory storage is found, analyze the full conversation.
Step 2: Analyze the session (after cutoff)
Review the conversation (from cutoff onward) and identify:
- Project(s) worked on (e.g., "cognitive-memory", "paper-dynasty", "homelab")
- Key accomplishments — what was built, fixed, changed, or decided
- Technical details — specific files, functions, configs, or commands involved
- Decisions made — any architectural choices, tradeoffs evaluated, or conventions established
- Problems solved — bugs found, root causes identified, solutions implemented
- Performance data — any before/after measurements
Step 3: Evaluate whether anything is worth storing
If the work after the cutoff is trivial (routine chat, simple questions answered, minor file reads with no actionable outcome), tell the user "Nothing new worth storing since the last save" and stop — do not spawn the agent.
Only proceed if there are concrete storable items: solutions, decisions, fixes, configs, patterns, or insights.
Step 4: Build the summary
Write a structured summary using this format:
PROJECT: <project name(s)>
ALREADY_STORED: <brief list of memories stored during session, or "none">
ITEMS:
1. [type: solution|decision|fix|configuration|code_pattern|workflow|insight]
Title: <concise, searchable title>
Tags: <comma-separated lowercase tags>
Importance: <0.3-1.0>
Content: <self-contained description with context, problem, solution, key details>
2. [type: ...]
...
Step 5: Launch the memory-saver agent
Use the Task tool to spawn the memory-saver agent in the background with the summary as the prompt. Use sonnet model.
Task(
subagent_type="memory-saver",
model="sonnet",
run_in_background=true,
description="Store session memories",
prompt="<your structured summary here>"
)
Step 6: Confirm
Tell the user how many memory items you identified and that the agent is saving them in the background.
Guidelines
- Be thorough — capture everything worth remembering
- Don't duplicate memories already stored during the session
- Each item should be self-contained and useful on its own
- 1-6 items per session is typical; more is fine for large sessions
- Prefer specific, searchable titles over vague ones