memory-bank
Token-efficient persistent memory system for Claude Code that saves ~67% tokens on session warm-up (verified with tiktoken). Layered architecture with progressive loading, compact encoding, branch-aware context, smart compression, session diffing, conflict detection, session continuation protocol, and recovery mode. Activates at session start (if MEMORY.md exists), on "remember this", "pick up where we left off", "what were we doing", "wrap up", "save progress", "don't forget", "switch context", "hand off", "memory health", "save state", "continue where I left off", "context budget", "how much context left", or any session start on a project with existing memory files. This skill solves two problems at once: Claude forgetting everything between sessions, AND sessions hitting context limits too fast. It replaces thousands of wasted re-explanation tokens with a compact, structured memory load that gives Claude full project context in under 2,000 tokens.
What this skill does
# Memory Bank
An adaptive memory system that gives Claude Code persistent, intelligent
context across sessions — while cutting token waste so your sessions last
3-5x longer. Not a flat file — a layered architecture that compresses,
branches, diffs, self-heals, and loads only what matters.
---
## Core Architecture
Memory Bank operates on three layers:
```
┌─────────────────────────────────────────────┐
│ Layer 2: GLOBAL MEMORY │
│ ~/.claude/GLOBAL-MEMORY.md │
│ Cross-project patterns, user preferences, │
│ reusable decisions. Permanent. │
├─────────────────────────────────────────────┤
│ Layer 1: PROJECT MEMORY │
│ ./MEMORY.md (+ branch overlays) │
│ Architecture, decisions, active work. │
│ Lives as long as the project. │
├─────────────────────────────────────────────┤
│ Layer 0: SESSION CONTEXT │
│ In-conversation only. │
│ Current task focus, scratch notes. │
│ Dies when session ends (persisted to L1). │
└─────────────────────────────────────────────┘
```
**Layer 0 (Session)** — Ephemeral. Tracks what you're doing right now.
Automatically flushed to Layer 1 at session end.
**Layer 1 (Project)** — The primary memory file. Tracks project state,
decisions, active work, blockers. Branch-aware: each git branch can have
its own overlay that merges with the base memory.
**Layer 2 (Global)** — Cross-project knowledge. Your coding preferences,
tool choices, patterns you always use. Lives in `~/.claude/GLOBAL-MEMORY.md`.
Loaded alongside Layer 1 at session start.
> See `references/memory-layers.md` for full architecture details.
---
## When to Activate
| Trigger | Action |
|---------|--------|
| Session starts, `MEMORY.md` exists | Full load sequence |
| `"remember this"`, `"don't forget"` | Mid-session update |
| `"wrap up"`, `"save progress"`, `"done for now"` | Full session write |
| `"pick up where we left off"`, `"what were we doing"` | Load + summarize |
| `"switch to [branch]"`, `"context for [feature]"` | Branch-aware load |
| `"memory health"`, `"is memory stale"` | Health check |
| `"hand off"`, `"onboard someone"` | Generate handoff doc |
| `"compress memory"`, `"clean up memory"` | Run compression |
| `"rebuild memory"` | Recovery mode |
| `"save state"`, `"continue this later"` | Session continuation protocol |
| `"context budget"`, `"how much context left"` | Context budget check |
| `"running out of context"`, `"session is long"` | Emergency save + continuation file |
---
## Workflow
### 1. Session Start — The Load Sequence
Execute this sequence before doing anything else:
```
Step 1: Detect memory files
└─ Check for MEMORY.md in project root
└─ Check for ~/.claude/GLOBAL-MEMORY.md
└─ Check for MEMORY-ARCHIVE.md (has history been archived?)
Step 2: Detect git context
└─ Current branch name
└─ Check for .memory/branches/<branch>.md overlay
└─ Days since last session (from "Last updated" field)
Step 3: Session diff (if git available)
└─ Commits since last memory update
└─ Files changed since last session
└─ Any conflicts between memory and current code state
Step 4: Health check
└─ Score memory freshness (see Health Scoring below)
└─ Flag stale entries
└─ Flag referenced files that no longer exist
Step 5: Context-aware greeting
└─ Summarize where we left off (2-3 sentences, specific)
└─ Report any drift detected (code changed, memory stale)
└─ State the next immediate action
└─ Ask: "Ready to continue, or has the plan changed?"
```
**Example greeting (fresh memory, same branch):**
> "Welcome back! Last session you finished the Stripe webhook handler in
> `src/api/webhooks/stripe.ts` and were about to write integration tests.
> The `handlePaymentSuccess()` function is complete but `handleRefund()` is
> stubbed out. 3 commits have landed since — all yours, no surprises.
> Ready to pick up with the integration tests?"
**Example greeting (stale memory, branch switched):**
> "Welcome back! Your memory is from 5 days ago on `main`, but you're now
> on `feature/user-profiles`. I found a branch overlay from 3 days ago with
> context about the profile avatar upload. However, `src/components/Avatar.tsx`
> referenced in memory was renamed to `ProfileImage.tsx`. Want me to update
> memory with the current state before we continue?"
**If no MEMORY.md exists:**
- Proceed normally
- After first meaningful work, offer: "Want me to start tracking our
progress? I'll create a memory file so next session picks up instantly."
---
### 2. Mid-Session Updates
When the user says "remember this" or you complete a significant milestone:
1. Read current `MEMORY.md`
2. Determine what changed:
- New decision made? → Update `Key Decisions`
- Task completed? → Move from `Active Work` to `Completed`, update `Where We Left Off`
- New blocker? → Add to `Blockers`
- Important context? → Add to `Notes`
3. Write the updated file
4. Confirm with specifics: "Saved — added the Zod migration decision and
marked the user model as complete."
**Do NOT rewrite the entire file on mid-session updates.** Only modify
the sections that changed. This preserves context from session start.
---
### 3. Session End — The Write Sequence
When wrapping up, execute a full memory write:
```
Step 1: Audit the session
└─ What was accomplished? (be specific: files, functions, lines)
└─ What decisions were made and why?
└─ What's blocked or unresolved?
└─ What should happen next? (crystal clear next step)
Step 2: Compress completed work
└─ Move finished items to Completed with one-line summaries
└─ Remove resolved blockers
└─ Archive stale notes
Step 3: Update memory health metadata
└─ Update "Last updated" timestamp
└─ Increment session counter
└─ Update file reference table (verify paths still exist)
Step 4: Write MEMORY.md
└─ Full overwrite with current state
└─ Verify the file was written successfully
Step 5: Check compression threshold
└─ If > 150 lines, suggest compression
└─ If > 200 lines, auto-compress (see Smart Compression)
Step 6: Prompt for global memory
└─ Any cross-project learnings worth saving to Layer 2?
└─ New user preferences discovered?
```
---
## MEMORY.md Template
```markdown
# Project Memory
Last updated: [DATE] | Session [N] | Branch: [BRANCH]
Memory health: [SCORE]/10
## Project Overview
[1-2 sentences. What this is, what stack, what stage.]
## Where We Left Off
- **Current task:** [specific task with file/function reference]
- **Status:** [done | in progress | blocked]
- **Next immediate step:** [so clear Claude can start without asking anything]
- **Open question:** [decision pending, if any]
## Completed
- [DATE] [one-line summary with key files touched]
- [DATE] [one-line summary]
## Active Work
- [ ] [task — specific file, function, or component]
- [ ] [task]
- [x] [recently completed, will archive on next compression]
## Blockers
- [blocker with context on what's needed to unblock]
## Key Decisions
| Date | Decision | Reasoning | Affects |
|------|----------|-----------|---------|
| [DATE] | [what was decided] | [why] | [files/areas impacted] |
## Key Files
| File | Purpose | Last Modified |
|------|---------|---------------|
| [path] | [what it does] | [session N] |
## Architecture Notes
[Non-obvious design choices, data flow, system boundaries]
## Known Issues
- [issue, severity, and workaround if any]
## Session Log
| Session | Date | Summary |
|---------|------|---------|
| [N] | [DATE] | [one-line summary of what happened] |
## User Preferences
[How the user likes to work — discovered across sessions]
## External Context
[APIs, services, env setup — NO secrets, NO credentials, NEVER]
```
---
## Branch-Aware Memory
When working across multiple git branches, memory adapts:
```
MEMORY.md <- Base project memory (main/trunk)
.memory/
branches/
feature-authRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.