Back to Phantom Notes
AI Agents

Your AI Has Amnesia. Here's the 5-Tier Fix.

April 7, 20269 min readBy T.W. Ghost
Claude CodeAuto MemoryCLAUDE.mdAI MemoryDeveloper ToolsLightRAGAnthropicProductivity

You Have Been Starting From Zero Every Session

You open Claude Code. You type your first message. And somewhere in the first few exchanges, you realize: it has no idea who you are.

It does not know your stack. It does not remember that you told it yesterday to stop adding docstrings. It forgot that your project uses Supabase, not Firebase. It forgot that you prefer named exports. It forgot everything.

So you paste the same block of instructions. Again. You re-explain your project structure. Again. And about 45 minutes into the session, context compacting kicks in. Claude starts summarizing your earlier messages to fit within the context window. Your carefully pasted instructions get compressed into a few sentences, and the cycle repeats.

This is what working without memory looks like. And most Claude Code users are stuck here without realizing there is a way out.

The fix is not one thing. It is a system, built in layers. Each tier solves a specific problem, and you can stop at whichever tier matches how much you care.


Tier 0: The Problem

Before we fix anything, let us name what is actually broken.

Context compacting. Claude Code has a finite context window. When your conversation gets long, older messages get compressed into summaries. Your original instructions lose detail. By hour two, Claude is working from a lossy summary of what you told it at the start.

Conversation rot. Every new session starts fresh. Claude does not carry anything forward. That correction you made ("use commas, not em dashes") lasted exactly one conversation.

The paste tax. You compensate by keeping a text file of instructions you paste at the start of every session. This works, but it is manual, fragile, and gets stale. You forget to update it. You forget to paste it. And Claude never learns from it.

The real cost: you are spending 10-15 minutes per session re-establishing context that should already be there. Multiply that by five sessions a week, and you are losing an hour just getting Claude back to where it was yesterday.


Tier 1: Global Memory (5 Minutes)

Create one file. That is it.

~/.claude/CLAUDE.md

This file loads into every Claude Code session, across every project, on every launch. It is your global identity file.

Here is a starter template you can copy right now:

markdown
# Global Preferences

## Who I Am
- Senior developer, primary stack: Next.js, TypeScript, Tailwind
- Comfortable with Docker, Linux, CI/CD
- Do not over-explain things I already know

## Code Style
- Use named exports, not default exports
- Prefer early returns over nested if/else
- No unnecessary comments or docstrings on unchanged code
- Do not add features beyond what was asked

## Communication
- Keep responses short and direct
- Do not summarize what you just did at the end of every response
- Do not use emojis unless I ask for them

Save that file. Start a new Claude Code session. Claude reads it before you type your first message.

You just fixed 60% of the repetition problem. Every session now knows your stack, your style preferences, and how you like to communicate. No pasting required.

What this does not fix: project-specific context. Claude still does not know your repo structure, your deployment setup, or the bug you were debugging yesterday. That is Tier 2.


Tier 2: Project Memory (The Weekend Setup)

Drop a CLAUDE.md file in the root of your project repository:

your-project/CLAUDE.md

This file loads automatically when Claude Code opens that project. It is project-specific, committed to git, and shared with your team.

Here is what a real one looks like (simplified from a production project):

markdown
# Project: SaaS Dashboard

## Stack
- Next.js 14 (App Router), TypeScript, Tailwind CSS
- Supabase (auth + database), Stripe (billing)
- Vercel (hosting, auto-deploys from main branch)

## Architecture
- src/app/ - App Router pages and layouts
- src/lib/ - Shared utilities, API clients, types
- src/components/ - React components (shadcn/ui base)
- supabase/migrations/ - Database migrations (never edit by hand)

## Deployment
- Push to main = auto-deploy to production
- Preview deployments on PRs
- Environment vars in Vercel dashboard (never commit .env files)

## Rules
- All API routes use Zod validation on inputs
- Auth checks go through src/lib/auth.ts, not inline
- Database queries use the Supabase client from src/lib/supabase.ts
- Test with: npm run test (vitest)

Now Claude knows your stack, your file structure, your deployment flow, and your team conventions. It will not suggest Firebase when you use Supabase. It will not try to edit migration files by hand. It will not push directly to main without understanding that triggers a production deploy.

Folder-level overrides. You can add more CLAUDE.md files in subdirectories for module-specific rules:

src/components/CLAUDE.md    # "All components use shadcn/ui. Check ui/ before building custom."
src/api/CLAUDE.md           # "Every endpoint validates with Zod. No untyped request bodies."

Claude loads the nearest CLAUDE.md walking up the directory tree. You get global rules at the root and specific overrides where you need them.

This is where 80% of the magic lives. If you do nothing else, write a project CLAUDE.md. It takes 20 minutes and pays for itself in the first session.


Tier 3: Auto Memory (The Feedback Loop)

Tiers 1 and 2 are files you write. Tier 3 is files Claude writes for you.

Auto Memory shipped in February 2026. It runs silently in the background, watching how you work. When it notices something worth remembering, it saves it to a local memory directory:

~/.claude/projects/<project-hash>/memory/

Get the Weekly IT + AI Roundup

What changed this week in NinjaOne, ServiceNow, CrowdStrike, and AI. One email, every Monday.

No spam, unsubscribe anytime. Privacy Policy

Inside that directory, there are two things:

  • MEMORY.md - An index file. Think of it as a table of contents. Each line links to a topic file.
  • Topic files - Individual markdown files for specific memories (feedback_testing.md, user_role.md, project_deployment.md, etc.)

The first 200 lines of MEMORY.md get injected into every new session automatically.

What triggers a save:

  • You correct Claude. "Do not mock the database in tests." Claude saves that as a feedback memory and applies it to every future session.
  • You confirm something non-obvious. "Yes, the single bundled PR was the right call." Claude notes that as a validated approach.
  • You share context. "We are freezing merges after Thursday for the mobile release." Claude saves the date and the reason.
  • You mention external resources. "Bugs are tracked in the Linear project INGEST." Claude saves the pointer.

What does NOT get saved:

  • Code patterns (Claude can read the code)
  • Git history (that is what git log is for)
  • Debugging solutions (the fix is in the code)
  • Anything in CLAUDE.md already

The 200-line gotcha. MEMORY.md has a hard limit. Lines after 200 get silently truncated. After a few weeks of active development, you will hit this. The fix: keep MEMORY.md as a lean index, one line per entry. Move detailed content into topic files. Prune entries that are no longer relevant.

Here is what a healthy MEMORY.md looks like:

markdown
# Project Memory

## User
- [Role and preferences](user_role.md) - Senior dev, Next.js/TypeScript stack

## Feedback
- [Testing approach](feedback_testing.md) - Integration tests only, no mocks
- [Code style](feedback_style.md) - Named exports, no trailing summaries
- [Don't ask to continue](feedback_batch.md) - Complete batch work without stopping

## Project
- [Deploy freeze](project_deploy_freeze.md) - Merge freeze March 5 for mobile release
- [Auth rewrite](project_auth.md) - Driven by legal compliance, not tech debt

## References
- [Bug tracker](reference_linear.md) - Pipeline bugs in Linear project INGEST

Notice the feedback section. Each of those was a single correction during a conversation. "Why do you keep asking if I want to continue? Just keep going." Claude saved that, and it never asked again. One correction, compounding across dozens of sessions.

Feedback memories are the highest-value type. They are also the easiest. You do not write them. You just correct Claude, and it remembers.


Tier 4: The Full System

When all the layers run together, here is the loading order for every Claude Code session:

1. ~/.claude/CLAUDE.md              (global preferences)
2. ./CLAUDE.md                      (project root)
3. ./src/components/CLAUDE.md       (nearest folder override)
4. ~/.claude/projects/.../MEMORY.md (auto memory index, first 200 lines)
5. .claude/settings.json            (permissions, MCP servers)

On top of this foundation, two more systems plug in:

Skills (.claude/skills/) - Markdown files that teach Claude specialized workflows. A skill for "Stripe integration" might include your webhook patterns, error handling conventions, and testing approach. Skills load on demand when relevant.

Hooks (.claude/settings.json) - Shell commands that run automatically before or after Claude takes specific actions. A pre-commit hook might run your linter. A post-edit hook might auto-format. These are not memory, but they work alongside memory to create a fully configured environment.

What the full system looks like in practice:

You open Claude Code on Monday morning. Before you type anything, Claude already knows:

  • Your name, role, and communication preferences (Tier 1)
  • Your project stack, file structure, and deployment rules (Tier 2)
  • That you corrected it last Thursday about test mocking (Tier 3)
  • That there is a deploy freeze until Wednesday (Tier 3)
  • That your Stripe webhook handler uses a specific error pattern (skill)
  • That every commit runs through your linter automatically (hook)

You type: "Add a new pricing tier to the billing page."

Claude starts working. It knows where the billing code lives. It knows your component library. It knows your Stripe patterns. It knows not to deploy until after Wednesday. It knows to use named exports and skip the docstrings.

No pasting. No re-explaining. No starting from zero.


What Comes Next

The four tiers above are what Claude Code supports today. But the frontier is moving fast.

Tier 5: The Wiki Pattern. Andrej Karpathy published his approach to AI memory: a structured wiki that the AI reads at the start of every session and updates as it learns. Think of it as CLAUDE.md on steroids, a living document that grows and reorganizes itself over time. The current auto memory system is a step in this direction, but future versions will likely get smarter about what to save, when to prune, and how to organize.

Tier 6: Graph RAG. Flat files have limits. When your memory grows past a few hundred entries, you need something that understands relationships between concepts. Graph RAG systems like LightRAG build a knowledge graph from your documents, connecting entities and concepts so you can query them naturally. Instead of scanning a markdown index, Claude could query a graph: "What do I know about this project's authentication system?" and get back connected nodes spanning architecture decisions, security requirements, team conventions, and incident history.

Some teams are already running LightRAG on self-hosted servers, queryable from Claude Code via MCP tools. It is early, but the direction is clear: AI memory is moving from static files to dynamic knowledge graphs.


Where to Start

If you are still pasting instructions every session, here is the fastest path out:

  • Today (5 minutes): Create ~/.claude/CLAUDE.md with your preferences. Copy the template from Tier 1.
  • This weekend (20 minutes): Write a CLAUDE.md in your main project. Cover your stack, file structure, and top 5 rules.
  • Next week: Start correcting Claude when it gets something wrong. Auto Memory will save those corrections automatically.
  • When you are ready: Explore skills and hooks to automate the rest.

You do not need all four tiers to see a difference. Tier 1 alone eliminates most of the repetition. Tier 2 eliminates the rest. Everything after that is compounding returns.

Stop pasting. Start remembering.


*Already running Claude Code on a server? Read our VPS setup guide or learn how Auto Mode and Auto Memory work together.*

*Want to build a full knowledge graph for your AI? Check out our LightRAG setup guide.*

*Not sure which AI tool fits your workflow? Take the free quiz and get matched in 2 minutes.*