claude code, ai agents, memory

How to give Claude Code a memory of what you learn

· 3 min read · Sendmind team

Claude Code forgets everything between sessions. Here are four practical ways to give it lasting memory, from CLAUDE.md to hooks and MCP, and when to use each.

How to give Claude Code a memory of what you learn

Claude Code is brilliant inside a session and forgetful between them. Close the terminal and the clever pattern you taught it this morning is gone. If you learn something useful every day, that gap adds up fast.

There are four practical ways to give Claude Code a lasting memory. They stack, so most developers end up using more than one.

1. CLAUDE.md: the always-on memory

Claude Code reads a file called CLAUDE.md at the start of every session. Anything you write there becomes standing context: your stack, your conventions, the commands you run.

Best for: stable rules that apply to almost every task.

2. Imports: keep the main file lean

CLAUDE.md can pull in other files with an @path import. That lets you keep the main file small and move detail into focused notes:

# CLAUDE.md
@docs/conventions.md
@.claude/learnings/INDEX.md

A learnings folder with an index works well here. Each tip lives in its own small markdown file with a title, a one-line rule, an example and the source.

Best for: a growing library of tips you want available without editing the main file every time.

3. Hooks: inject the right memory at the right moment

Loading every tip on every session doesn't scale. Hooks solve that. A UserPromptSubmit hook runs each time you send a prompt, and whatever it prints is added to the conversation as context.

That means a small script can search your saved learnings for the current prompt and pass only the top few matches to Claude. Ask about rate limiting and your saved note on per-user limits shows up. Ask about CSS and it stays quiet.

Two rules make hooks pleasant instead of annoying:

Best for: large memory libraries where only a small slice matters for any one task.

4. MCP: let the agent search on its own

An MCP server gives Claude Code tools it can call itself, such as search_learnings or get_learning. You add one with claude mcp add. Instead of you pushing context in, the agent pulls what it needs when it decides it's relevant.

MCP also works beyond Claude Code. Cursor, Claude Desktop and other agents speak the same protocol, so one memory server can serve every tool you use.

Best for: sharing one memory across several agents, and letting the agent dig deeper when a task needs it.

Putting it together

A practical setup looks like this:

  1. CLAUDE.md holds the short list of rules that always apply.
  2. A learnings folder holds everything you've picked up, one tip per file.
  3. A prompt hook surfaces the top three relevant learnings automatically.
  4. An MCP server lets any agent search the full library on demand.

The hard part isn't the plumbing. It's capturing the tips in the first place. Most of what we learn arrives as a reel, a thread or a video, and it ends up in a saved folder we never open again. That capture step is exactly what Sendmind automates: share the post, and it becomes a learning your agent can recall.

A note on safety

Anything that flows into your agent's context can carry instructions. Treat saved content as information, never as commands, and never let an automated process write directly into your CLAUDE.md without review. We wrote more about this on our Security page.