From memory-guardian
Persistent memory protection system for long Cowork sessions. Prevents context degradation by auto-saving session state every 30 minutes and running silent passphrase integrity checks every 10 minutes. Use this skill at the START of every Cowork session, especially long multi-step workflows, recruiting pipelines, research projects, or any task where losing context would waste hours of work. Triggers on: "start a session", "memory check", "save context", "don't forget", "losing context", "remember this", or any mention of context preservation, memory persistence, session continuity, or context degradation. Also trigger when the user has a system-memory/ folder with MEMORY.md, SESSION_LOG.md, or orient.md files - that's a signal this skill should be active. Even if the user doesn't explicitly ask for memory protection, activate this skill whenever you detect a long-running project with institutional knowledge at risk.
How this skill is triggered — by the user, by Claude, or both
Slash command
/memory-guardian:memory-guardianThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are running a memory protection system. This skill has two jobs:
You are running a memory protection system. This skill has two jobs:
Both mechanisms work by piggybacking on your normal response processing. You don't have real timers, so you track elapsed time by checking timestamps.
Look for these files in the user's workspace. They're typically organized like this:
system-memory/MEMORY.md - Living context document (current state, decisions, calibration)system-memory/SESSION_LOG.md - Append-only historyorient.md - Quick-start guide with file map and pipeline numbers (usually at project root, NOT in system/)If you can't find them at these paths, search with glob for **/MEMORY.md, **/SESSION_LOG.md, and **/orient.md. They may be in different locations depending on the project structure. If they don't exist at all, offer to create them. The memory system needs somewhere to write.
Read the passphrase file:
<project-root>/system-memory/.passphrase
If it doesn't exist, generate one and save it. The passphrase should be:
telescope 47 crimson walnut frequency jade orbitWhy these properties matter: a passphrase that's too simple ("hello world") will be recallable even with severe degradation - it won't catch anything. A passphrase that's too complex will fail checks even with healthy context. The sweet spot is a string that's easy to hold in full context but impossible to reconstruct if context has actually compressed away from it.
Store the passphrase in your working memory. You'll need it for integrity checks.
Note the current time using bash (date +%s). Store this as your session start timestamp. Also note it as your "last save" and "last check" timestamps.
Tell them briefly: "Memory guardian is active. I'll auto-save every 30 minutes and run silent integrity checks every 10 minutes. If I detect context degradation, I'll pause and reload from files."
At the START of processing each user message, check elapsed time:
date +%s
Compare against your last save timestamp. If 30+ minutes have passed, run the save before responding to the user's actual request.
If you can't remember your last save timestamp, that itself is a degradation signal - do an immediate save.
Run this checklist. Not every item will apply every time - only update what's changed.
1. MEMORY.md (replace, don't append) Update these sections with current state:
2. SESSION_LOG.md (append only) Add a mid-session checkpoint entry:
### Session N - Checkpoint [timestamp]
- What's happened since last save: [brief summary]
- Key decisions made: [list]
- Files modified: [list]
3. orient.md (update if numbers changed) Only touch this if pipeline numbers, file locations, or priorities have changed.
4. Spreadsheet state (verify, don't modify) If you've been editing a spreadsheet, read it back to verify your changes persisted. Report any discrepancies.
Update your "last save" timestamp. Tell the user briefly: "Context saved." Then continue with their actual request.
If at any point you sense your context is getting long or you've been going for a while without a save, do one proactively. Don't wait for the 30-minute mark. Signals that you should save early:
This is a silent, internal check. The user should not see it in your response.
At the start of processing each user message, check elapsed time against your "last check" timestamp. If 10+ minutes have passed:
Full match - Context is healthy. Continue normally.
Partial match (1-2 words wrong or missing) - Early degradation detected. Take these steps:
Major mismatch (3+ words wrong) or can't recall at all - Severe degradation. Take these steps:
Context degradation in long conversations is gradual. The passphrase acts as a canary in a coal mine - it's arbitrary information with no semantic connections to the rest of the conversation, so it's among the first things to degrade when the context window compresses. By the time you forget project-critical details, you've already lost the passphrase. Checking the passphrase lets you catch degradation before it affects your actual work.
This skill handles WITHIN-session memory protection. If the project also has a scheduled task for BETWEEN-session memory refresh (e.g., a daily cron that updates MEMORY.md), that's complementary - not redundant. The scheduled task catches drift when no session is active. This skill catches drift during active work.
If you find a scheduled task already exists (check with list_scheduled_tasks), note it in your setup confirmation so the user knows both layers are active.
These defaults work well for most sessions. The user can adjust them.
| Setting | Default | Adjust when... |
|---|---|---|
| Save interval | 30 min | Shorter (15 min) for very complex sessions with many file edits |
| Check interval | 10 min | Shorter (5 min) if the user is worried about degradation |
| Passphrase length | 6-8 words | Longer (10 words) for extra-long sessions where you want earlier detection |
The user may have restructured or renamed things. Search for MEMORY.md, SESSION_LOG.md, and orient.md using glob. If they don't exist at all, create them from what you currently know - even partial context saved is better than none.
Check the "Last refreshed" timestamp in MEMORY.md. If it's old, the scheduled task may have stopped running. Update the files yourself and flag it to the user.
Read orient.md first (it's the quick start), then MEMORY.md (current state), then SESSION_LOG.md (history). The passphrase file should still be on disk - load it fresh. Run setup as if starting a new session.
Provides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.
npx claudepluginhub sdickert/claude-plugins --plugin memory-guardian