一键导入
migrate-simple-session-memory
// Migrate an existing simple-session-memory installation to match the current release format. Run this after upgrading the template to bring CLAUDE.md instructions, directory structure, and index.md up to date.
// Migrate an existing simple-session-memory installation to match the current release format. Run this after upgrading the template to bring CLAUDE.md instructions, directory structure, and index.md up to date.
| name | migrate-simple-session-memory |
| description | Migrate an existing simple-session-memory installation to match the current release format. Run this after upgrading the template to bring CLAUDE.md instructions, directory structure, and index.md up to date. |
You are migrating the user's simple-session-memory installation to the current release format. This is a target-state migration — check what the user has, compare it to what the current release expects, and fix any differences. If everything is already current, report that and stop.
The current release uses directory-per-session layout and a formal content placement model:
.claude/memory/
session-YYYY-MM-DD-NNN/
session-YYYY-MM-DD-NNN.md # the session log
<supplementary files> # formerly "attachments"
index.md
archives/
archive-NAME/
archive-NAME.md # the archive log
<supplementary attachments> # optional — load-bearing reference content
Key changes from previous versions:
.claude/memory/).claude/memory/attachments/ tree)archives/archive-NAME/archive-NAME.md) mirroring sessions, replacing the old flat archive/archive-NAME.md files. Archive directories may contain supplementary attachments preserved verbatim from the archived sessions.archive/ → archives/ (plural)..md (e.g. session-2026-03-04-002, not session-2026-03-04-002.md)continues: field in YAML frontmatter also uses stems without .mdattachments: YAML field is no longer used (co-location replaces it).session-count global counter file is no longer used (per-day directory scanning replaces it)Bash(rm -r .claude/memory/session-*) replaces the old Bash(rm .claude/memory/session-*) and Bash(rm -r .claude/memory/attachments/*)Work through each audit in order. Read before writing. Report changes at the end.
The installer saves a reference copy of the current snippet at .claude/simple-session-memory/CLAUDE.snippet.md. This is the source of truth.
.claude/simple-session-memory/CLAUDE.snippet.md (the reference).CLAUDE.md in the project root.# Session Memory System and is delimited from the rest of CLAUDE.md by --- separators.--- delimiters).--- separator (same as a fresh install).This is the critical step. Convert flat session logs to directory-per-session layout.
Check first: If .claude/memory/ already contains session-*/ directories (not flat files), the structure may already be migrated. Verify by checking whether session logs exist as flat files (session-*.md directly in .claude/memory/) or inside directories.
If flat session log files exist in .claude/memory/:
For each session-*.md file directly in .claude/memory/ (not inside a subdirectory, not in archive/ or archives/):
.md, e.g. session-2026-03-09-004)mkdir -p .claude/memory/<stem>/mv .claude/memory/<stem>.md .claude/memory/<stem>/<stem>.md.claude/memory/attachments/<stem>/ exists, move its contents into the session directory:
mv .claude/memory/attachments/<stem>/* .claude/memory/<stem>/rmdir .claude/memory/attachments/<stem>/After processing all session logs:
.claude/memory/attachments/ exists and is empty, remove it: rmdir .claude/memory/attachments/.claude/memory/.session-count exists, remove it: rm .claude/memory/.session-countDo NOT touch (in this step):
.claude/memory/archive/ or .claude/memory/archives/ — archive layout is handled in step 3.claude/memory/index.md — handled in step 4Archives moved from flat files in archive/ to directory-per-archive in archives/. Two orthogonal changes: the parent directory was renamed (archive → archives), and each flat archive file became its own directory with the log inside.
Determine current state:
.claude/memory/archives/ exists and .claude/memory/archive/ does not, the rename is done — proceed to per-archive layout check..claude/memory/archive/ exists, rename it: mv .claude/memory/archive .claude/memory/archives.mkdir -p .claude/memory/archives.Per-archive directory layout:
For each archive-*.md file directly in .claude/memory/archives/ (a flat file, not inside a subdirectory):
.md, e.g. archive-2026-03-09).mkdir -p .claude/memory/archives/<stem>/.mv .claude/memory/archives/<stem>.md .claude/memory/archives/<stem>/<stem>.md.There are no pre-existing supplementary attachments to migrate (the old layout did not support them); the new directory will hold only the log file until a future archival run adds attachments.
If every archive is already laid out as archives/<stem>/<stem>.md, skip this step.
Read .claude/memory/index.md. If the file doesn't exist, skip this step.
The expected structure has three sections with specific column names:
## Active Sessions
| Session | Date | Summary |
## Archives
| Archive | Period | Summary |
## Appendices
### Month YYYY
#### archive-file.md (date range)
Summary paragraph...
Check and fix:
.md suffixes (e.g. session-2026-03-09-004.md), strip the .md to just the stem (session-2026-03-09-004).| File | Date | Summary | table without a ## Active Sessions heading above it, add the heading and rename the File column to Session.| Archive | Covers | columns, reshape to | Archive | Period | Summary | — move the Covers value to Period, leave Summary empty.archive/archive-NAME.md or archives/archive-NAME.md without the directory wrapper), update them to archives/archive-NAME/archive-NAME.md to match the directory-per-archive layout. Stem-only references with no path are also acceptable; only rewrite path-bearing links.## Appendices section, add it at the end (empty — appendices are populated by future archival runs).If the index already has all three sections with the correct column names, stem-based session references, and directory-per-archive links, skip it.
Read .claude/settings.local.json. Check for these entries and fix as needed:
Permissions — ensure permissions.allow contains:
Write(.claude/memory/**)Edit(.claude/memory/**)Bash(rm -r .claude/memory/session-*)Remove old permissions if present:
Bash(rm .claude/memory/session-*) (old flat-file permission — without -r)Bash(rm -r .claude/memory/attachments/*) (no longer needed)PreToolUse hook — ensure a PreToolUse hook entry exists with matcher Write|Edit pointing to the approve-memory-write script at .claude/simple-session-memory/hooks/approve-memory-write.sh.
Check that .claude/simple-session-memory/hooks/approve-memory-write.sh exists and is executable. If it's missing, warn the user to reinstall the template (npx cc-context-awareness@latest install simple-session-memory).
Check that .claude/skills/log-session-memory/SKILL.md exists. This skill contains the detailed session logging procedure referenced by threshold messages. If it's missing, warn the user to reinstall the template.
After completing all audits, report to the user:
archive/ → archives/) and how many flat archive files were wrapped into per-archive directoriesmkdir, mv, rm, rmdir for the directory structure migration.continues: session-*.md and attachments: fields are historical and harmless — leave them as-is.Create or update a session memory log. Called automatically by context threshold reminders, or manually to force a memory write.
Configure the cc-context-awareness context window warning system. Use when the user wants to change context warning thresholds, messages, or other cc-context-awareness settings.