The Claude Code Memory Stack: CLAUDE.md, Skills, Auto-Memory, and Session Resume

Beginner3h 48m readFull-stack developers

Claude Code's persistent context system has grown well beyond three documents. Today it operates as a five-layer memory stack — managed policy, personal and project CLAUDE.md files, on-demand Skills, AI-written auto-memory, and session resume — each layer serving a distinct purpose and loading at a different point in the session lifecycle.

Primary Focus

ai development

AI Tools Covered

AI-firstNext.jsConvex

What You'll Learn

  • What is CLAUDE.md?
  • Crafting an Effective CLAUDE.md
  • Critical Rules
  • Structuring for Scalability
  • Quick Reference (READ FIRST)
  • Database & Deployment

Guide Curriculum

Understanding CLAUDE.md: Your Project's Blueprint

2 lessons
  • What is CLAUDE.md?12m
  • Crafting an Effective CLAUDE.md12m

Critical Rules

- **Database Queries**: Use `npm run convex:prod` (NEVER `export CONVEX_DEPLOYMENT=...`) - **Logging**: Use `lib/logger.ts` not `console.log` in production code - **Content**: ONLY use `/content` command for content operations - **Testing**: Always run `npm run playwright:cleanup` after tests

1 lessons
  • Critical Rules12m

Code Patterns

- Components: Use `cn()` for className merging, typed props - Mutations: Validate inputs, wrap in try/catch, return `{success, id/data}` - API Routes: Check `userId` with Clerk, proper HTTP status codes ```

1 lessons
  • Structuring for Scalability12m

Quick Reference (READ FIRST)

- Platform: vybecoding.ai (always lowercase) - Branch: main (single branch workflow) - Database: modest-lobster-37

1 lessons
  • Quick Reference (READ FIRST)12m

Database & Deployment

[details]

1 lessons
  • Database & Deployment12m

Testing

[details]

1 lessons
  • Testing12m

Security

[details] ```

1 lessons
  • Security12m

Memory Files: Persistent Context Across Sessions

3 lessons
  • How Memory Works12m
  • Types of Memory12m
  • The Memory Index12m

User

- [user_role.md](user_role.md) -- Backend engineer, new to React

1 lessons
  • User12m

Feedback

- [feedback_testing.md](feedback_testing.md) -- Use real DB in integration tests, not mocks

1 lessons
  • Feedback12m

Project

- [project_sprint.md](project_sprint.md) -- Sprint 7 completed, merge freeze Mar 5 ``` Keep `MEMORY.md` concise, ideally under 200 lines, with each entry succinctly described.

1 lessons
  • Project12m

Slash Commands: Automating Reusable Workflows

3 lessons
  • What Are Slash Commands?12m
  • Creating Your First Command12m
  • Advanced Command Patterns12m

Putting It All Together: The Context Stack in Practice

When you initiate a Claude Code session, the context stack loads in the following order: 1. **CLAUDE.md**: Provides project rules and conventions. 2. **MEMORY.md**: Loads indexed memories. 3. **Relevant Memories**: Loaded based on the conversation's context. 4. **Slash Commands**: Available for invocation as needed.

1 lessons
  • Before and After Context Documents12m

Summary: Key Takeaways

The three context layers—CLAUDE.md, Memory Files, and Slash Commands—work synergistically to enhance Claude's utility: | Layer | File | Scope | Purpose | |-------|------|-------|---------| | CLAUDE.md | Project root | All sessions | Project rules and conventions | | Memory | ~/.claude/projects/*/memory/ | Across sessions | Persistent preferences and context | | Commands | .claude/commands/ | On demand | Reusable workflows |

1 lessons
  • Getting Started Today12m

The Full Memory Stack: Beyond Three Documents

12 min1 lessons
  • The Full Memory Stack: Beyond Three Documents12m

Preview: First Lesson

Understanding CLAUDE.md: Your Project's Blueprint

What is CLAUDE.md?

Think of CLAUDE.md as your project's personalized README for Claude. This markdown file, located at the root of your project, serves as a comprehensive guide that Claude reads at the start of every session. It outlines your project's architecture, coding conventions, and critical rules, ensuring that Claude's actions align with your specific requirements.

Example: With and Without CLAUDE.md

Without CLAUDE.md:

You: "Add a new API route for user profiles"
Claude: *creates a generic Express.js route with console.log*

With CLAUDE.md:

You: "Add a new API route for user profiles"
Claude: *creates a Next.js API route using Clerk auth, Convex queries, and lib/logger.ts—matching your exact stack*

With CLAUDE.md, Claude tailors its actions to your tech stack, authentication methods, and logging practices.

Free Access

Start learning with this comprehensive guide

This guide includes:

15 modules with 20 lessons
3h 48m estimated reading time

About the Author

H
✨ Vibe Coder
@hiram-clark

Hiram Clark is the founder and managing editor of vybecoding.ai and sets editorial direction for the guides and news published here. Articles are drafted with AI assistance and edited before publication. He works hands-on with the AI development tools, workflows, and infrastructure covered on the site.

Full Guide Content

Complete lesson text — start the interactive course above for exercises and progress tracking.

Module 1Understanding CLAUDE.md: Your Project's Blueprint

1.1What is CLAUDE.md?

Think of CLAUDE.md as your project's personalized README for Claude. This markdown file, located at the root of your project, serves as a comprehensive guide that Claude reads at the start of every session. It outlines your project's architecture, coding conventions, and critical rules, ensuring that Claude's actions align with your specific requirements.

Example: With and Without CLAUDE.md

Without CLAUDE.md:
You: "Add a new API route for user profiles"
Claude: *creates a generic Express.js route with console.log*
With CLAUDE.md:
You: "Add a new API route for user profiles"
Claude: *creates a Next.js API route using Clerk auth, Convex queries, and lib/logger.ts—matching your exact stack*

With CLAUDE.md, Claude tailors its actions to your tech stack, authentication methods, and logging practices.

1.2Crafting an Effective CLAUDE.md

A well-crafted CLAUDE.md should include:

  1. Tech Stack and Architecture: Specify frameworks, databases, and authentication providers.
  2. Code Conventions: Define naming conventions, file structures, and import patterns.
  3. Critical Rules: Highlight non-negotiable practices, such as avoiding console.log in production.
  4. Common Tasks: Describe deployment processes, testing protocols, and feature addition guidelines.

Real-World Example from vybecoding.ai

```markdown

Module 2Critical Rules

2.1Critical Rules

  • Database Queries: Use npm run convex:prod (NEVER export CONVEX_DEPLOYMENT=...)
  • Logging: Use lib/logger.ts not console.log in production code
  • Content: ONLY use /content command for content operations
  • Testing: Always run npm run playwright:cleanup after tests

Module 3Code Patterns

3.1Structuring for Scalability

As your project grows, so should your CLAUDE.md. Organize it with clear sections and a quick-reference header to ensure essential rules are easily accessible:

```markdown

Claude Code Development Guide

Module 4Quick Reference (READ FIRST)

4.1Quick Reference (READ FIRST)

  • Platform: vybecoding.ai (always lowercase)
  • Branch: main (single branch workflow)
  • Database: modest-lobster-37

Module 5Database & Deployment

5.1Database & Deployment

[details]

Module 6Testing

6.1Testing

[details]

Module 7Security

7.1Security

[details]

```

Module 8Memory Files: Persistent Context Across Sessions

8.1How Memory Works

Memory files are stored at ~/.claude/projects//memory/ and provide conversation-level context that persists across sessions. Unlike CLAUDE.md, which is project-wide, memory files capture personal and project-specific nuances that Claude recalls automatically.

Example: With and Without Memory

Without Memory:
Session 1: "I'm a backend engineer, new to React"
Session 2: "How do I add a component?"
Claude: *explains from scratch, doesn't know your background*
With Memory:
Session 1: "I'm a backend engineer, new to React"
Claude: *saves to memory: user is backend engineer, new to React*
Session 2: "How do I add a component?"
Claude: *explains React components using backend analogies, skips basics they'd already know*

8.2Types of Memory

Claude supports several memory types, each serving a unique purpose:

  • User Memory: Captures your role, preferences, and expertise level.
  • Feedback Memory: Records corrections and confirmed approaches.
  • Project Memory: Maintains ongoing work context.
  • Reference Memory: Points to external resources.

Each memory file includes frontmatter for clarity:

---
name: user_role
description: User's role and technical background
type: user
---

Backend engineer with 10 years of Go experience.
New to React and this project's frontend.
Frame frontend explanations using backend analogies.

8.3The Memory Index

All memories are indexed in MEMORY.md, which Claude uses to decide which memories to load:

```markdown

Project Memory Index

Module 9User

9.1User

Module 10Feedback

10.1Feedback

Module 11Project

11.1Project

``

Keep MEMORY.md` concise, ideally under 200 lines, with each entry succinctly described.

Module 12Slash Commands: Automating Reusable Workflows

12.1What Are Slash Commands?

Slash commands are markdown files located in .claude/commands/ that function as reusable prompt templates. They allow you to execute complex instructions with a simple command, streamlining repetitive tasks.

Example: With and Without Slash Commands

Without Slash Commands:
You: "Check all TypeScript files for console.log statements, verify no any types exist, run the linter, check for security issues, then summarize findings in a table..."
With Slash Commands:
You: /code-review
Claude: *runs the full review workflow automatically*

12.2Creating Your First Command

To create a command, save a markdown file in .claude/commands/:

# Code Review

Review the current changes for quality issues:

1. Run `npx tsc --noEmit` and report errors
2. Search for `console.log` in modified files
3. Search for `: any` type annotations
4. Check for hardcoded secrets or API keys
5. Verify error handling in new functions

Output a summary table:
| Check | Status | Details |
|-------|--------|---------|

Invoke it with /code-review in any session.

12.3Advanced Command Patterns

Commands can be parameterized, reference other files, and chain together for more complex workflows:

Parameterized Command (.claude/commands/deploy.md):
# Deploy

Deploy changes to production:
1. Run `npm run typecheck`
2. Run `npm run test:safe`
3. Commit with descriptive message
4. Push to main
5. Verify deployment at $1 (URL argument)

Invoke with: /deploy https://vybecoding.ai

Commands Referencing Context:
# Sprint Status

Read `docs/sprints/current-sprint.md` and report:
- Stories completed vs total
- Blocked items and reasons
- Estimated completion

Module 13Putting It All Together: The Context Stack in Practice

13.1Before and After Context Documents

Before Context Documents:
  • Each session starts from scratch.
  • Repetitive instructions are necessary.
  • Claude may repeat mistakes.
  • Workflows are inconsistent.
After Context Documents:
  • Claude understands your project from the outset.
  • Preferences persist across sessions.
  • Mistakes are corrected once and remembered.
  • Workflows are standardized and repeatable.

The investment in creating these documents is minimal, yet the benefits are substantial. Every interaction with Claude becomes more efficient and tailored to your needs.

Module 14Summary: Key Takeaways

14.1Getting Started Today

  1. Create a CLAUDE.md at your project root with your tech stack and top 5 rules.
  2. In your next Claude Code session, share something about yourself to initiate memory storage.
  3. Identify a frequently repeated workflow and convert it into a .claude/commands/ file.
  4. Continuously iterate and refine your context documents based on real-world usage.

By leveraging these tools, you empower Claude to become a more effective collaborator, streamlining your development process and enhancing productivity.

Module 100The Full Memory Stack: Beyond Three Documents

100.1The Full Memory Stack: Beyond Three Documents

The Full Memory Stack: Beyond Three Documents

The three-document model (CLAUDE.md, Skills, memory files) is the foundation. But Claude Code in 2026 has a fuller memory stack — and understanding all five layers helps you build agents that maintain meaningful context across sessions, across projects, and across time.

The Five-Layer Memory Stack

Layer 1: CLAUDE.md (Project Rules)

Loaded into every context window for the project. Covers constraints, commands, conventions, and tooling patterns. Scoped to the project directory.

  • Optimal size: 1,000–3,000 words
  • Decay rate: Low (review quarterly)
  • Audience: Claude working in this specific project
Layer 2: Skills (Reusable Workflows)

Structured workflows in .claude/skills//SKILL.md. Loaded on demand via /skill-name. Covers multi-step procedures, tool sequences, decision trees.

  • Optimal size: 200–800 words per skill
  • Decay rate: Medium (update when workflow changes)
  • Audience: Claude executing a specific type of task
Layer 3: Auto-Memory (Persistent Facts)

Files in ~/.claude/projects//memory/. Written by Claude during sessions when you say "remember this." Recalled at session start. Covers user preferences, project state, recurring facts.

  • Optimal size: Unlimited (but prune regularly)
  • Decay rate: Variable — actively prune stale entries
  • Audience: Claude across all sessions for this project
Layer 4: The /memory Command

Direct memory management via /memory in the Claude Code CLI. Lists current memories, shows what's loaded, lets you delete or edit entries.

/memory list          # Show all active memories
/memory delete    # Remove a specific memory
/memory search RAG    # Find memories mentioning RAG

Use /memory list before starting a complex task to confirm Claude has the right context. Use /memory delete to remove stale or incorrect memories that might bias Claude's behavior.

Layer 5: Session Resume

Claude Code can resume a previous session with full context. Use claude --resume or /resume in the CLI. Session context includes the full conversation history, tool outputs, and file state from the previous run.

  • Use case: Long research tasks, multi-day implementation work
  • Limit: Sessions expire after 30 days of inactivity
  • Gotcha: Resuming a session bypasses auto-memory loading (session memory supersedes)

Auto-Memory in Practice

Auto-memory is the most powerful layer for building agents that improve over time. When Claude learns something useful about your project, workflow, or preferences during a session, it can save that as a memory file.

What Claude saves automatically (if configured):
  • User preferences ("user prefers TypeScript over JavaScript")
  • Project patterns ("this project uses 0-based indexing for module orders")
  • Recurring facts ("the production DB ID is modest-lobster-37")
What you should explicitly ask Claude to save:
  • Non-obvious decisions ("we decided to use soft-delete instead of hard-delete because of the audit requirement")
  • Debugging solutions that aren't obvious from code ("if the Convex deploy fails with this error, run npx convex codegen first")
  • External system mappings ("the Linear project INGEST is where pipeline bugs are tracked")
Triggering a save:
"Remember this for future sessions: [fact]"
"Save this to memory: [decision + reasoning]"
"Keep this context: [project state]"

Claude writes the memory to a structured file with metadata and updates the MEMORY.md index. You can verify with /memory list.

Avoiding Memory Bloat

Memory files accumulate over time. Bloated memory slows context loading and can introduce conflicting information.

Prune quarterly:
  • Run /memory list to see all entries
  • Delete memories that are project-specific and the project is done
  • Delete memories that conflict with current code state
  • Consolidate multiple related memories into one
Watch for memory rot: A memory that says "the API rate limit is 100 req/sec" becomes wrong when you upgrade your plan. Memory rot is subtle because Claude will follow the memory rather than checking current code. Good memory hygiene:
  • Date-stamp important project-state memories ("as of April 2026, the schema uses...")
  • Include a "why" for non-obvious decisions
  • Don't save things that are evident from code (code is always fresher than memory)

The Session Resume Pattern for Long Tasks

For multi-day implementation tasks:

Session 1: Start the task, let Claude build context, complete Phase 1.
claude "Design and implement the database schema for the billing system"
End of session: Claude saves progress notes to memory if configured. Session 2: Resume with full context.
claude --resume  "Continue from where we left off — implement the API layer on top of the schema"

Session resume is more reliable than re-establishing context via a fresh session for tasks with complex intermediate state. Use it for tasks that span more than 2 hours or involve more than 20 files.

The /memory Command Deep Dive

# See what's loaded in your current context
/memory list

# Search for specific memories
/memory search "production database"

# Edit a memory (opens in $EDITOR)
/memory edit 

# Delete stale memories
/memory delete 

# Export memories for sharing or backup
/memory export > project-memories-2026-04.md

# Import memories (e.g., from a teammate)
/memory import teammate-memories.md

The /memory command is your control plane for the auto-memory layer. Checking it before starting complex tasks ensures Claude has the right foundational context — and isn't working from outdated information that memory files might contain.