A tiered memory system for AI agents. Like CPU cache hierarchy, but for your context window.
text
MEMORY.md (Tier 1 — Hot) ← Always loaded, ~100 lines max
↕ promote (accessed) / demote (stale 7+ days)
memory/tier2-recent.md (Warm) ← On-demand, last 30 days
↕ promote / demote (stale 30+ days)
memory/tier3-archive.md (Cold) ← Search only, deep history
↕
memory/YYYY-MM-DD.md (Raw) ← Immutable daily logs
All scripts are in scripts/ relative to this SKILL.md.
Scans session transcripts for memory file reads/writes/searches. Run regularly.
bash
node scripts/track.js # scan last 24h
node scripts/track.js --since 72 # scan last 72 hours
Output: Updates state/access-log.json with per-file and per-section access data.
Promotes/demotes sections between tiers based on access patterns.
bash
node scripts/maintain.js --dry-run # preview changes
node scripts/maintain.js # apply changes
node scripts/maintain.js --demote-days-t1 5 # custom T1 demotion threshold
Rules:
Move a specific section between tiers.
bash
node scripts/promote.js --list # show all sections
node scripts/promote.js --section "LARC" --from 3 --to 1 # promote
node scripts/promote.js --section "TextWeb" --from 1 --to 2 # demote
Show current tier sizes, staleness, and recommendations.
bash
node scripts/report.js # pretty-printed
node scripts/report.js --json # machine-readable
Add to your heartbeat routine (every few hours):
markdown
## Memory Maintenance
1. Run `node <skill_dir>/scripts/track.js` to update access tracking
2. Run `node <skill_dir>/scripts/maintain.js --dry-run` to check for needed changes
3. If changes look good, run without --dry-run
4. Run `node <skill_dir>/scripts/report.js` to verify health
state/access-log.json — Per-file and per-section access timestamps and countsstate/maintenance-log.json — History of maintenance actions takenRuleThresholdActionT1 staleNot accessed 7 daysDemote to T2T2 staleNot accessed 30 daysDemote to T3T2/T3 accessedAccessed in last 24hPromote to T1T1 over limit>100 linesDemote lowest-access sectionsDaily logNever modified after day endsSource of truth
Tier files should have these headers:
markdown
# MEMORY.md — Working Memory (Tier 1)
<!-- last_maintained: YYYY-MM-DD -->
<!-- tier: 1 — hot context -->
Sections use ## or ### headers. The maintenance scripts parse these to identify movable units.
The ## Index → Deeper Tiers section in MEMORY.md should always be last — it provides pointers to content in lower tiers.