← Presentation home · Part 7 of 12

Claude.Md - Project Memory

Part 7 · Claude.Md - Project Memory

No slide image for this part. Notes below.

← Previous Next →

Deep dive

Claude.Md - Project Memory

Every conversation starts fresh. The model doesn't remember yesterday. But you can give it memory through CLAUDE.md files.

What Is CLAUDE.md?

It's a markdown file that Claude Code reads at the start of every session. Think of it as a briefing document:

"Here's what you need to know about this project..."

Claude Code loads it automatically. No special command needed.

Where CLAUDE.md Lives

Two locations:

~/.claude/CLAUDE.md        Global - applies to ALL projects

./CLAUDE.md                Project - applies to current directory

Both are loaded if both exist. Project-specific adds to global.

Creating Project Memory

The easy way - let Claude Code do it:

cd ~/my-project

claude

Then run:

/init

This scans your codebase and generates a CLAUDE.md with:

- Build/test commands it found
- Key directories and files

Review what it creates. It's a starting point, not gospel.

Manual CLAUDE.md

You can write it yourself. Here's a template:

Project: My Web App

Tech Stack

- HTML/CSS frontend (no JavaScript frameworks)

Directory Structure

- lib/           Perl modules
- templates/     HTML templates
- public/        Static files
- script/        CLI scripts
- t/             Tests

Common Commands

- Run server: morbo script/my_app
- Run tests: prove -lv t/
- Database: sqlite3 data/app.db

Coding Standards

Things To Know

- Auth tokens are in config/secrets.conf (gitignored)
- User uploads go to public/uploads/
- The cron job in scripts/cleanup.pl runs nightly

Be specific. The more context you give, the better Claude understands your project.

Global CLAUDE.md

~/.claude/CLAUDE.md applies everywhere. Good for:

Example:

Global Preferences

Coding Style

Explanations

Environment

The # Shortcut

During a session, you can add notes to CLAUDE.md without opening it:

Always use prepared statements for database queries

This gets appended to CLAUDE.md. Quick way to teach Claude mid-session.

Hierarchical Loading

Claude Code loads CLAUDE.md files in order:

1. ~/.claude/CLAUDE.md (global)
2. ./CLAUDE.md (project root)
3. ./subdir/CLAUDE.md (nested directories)

Nested files add to or override earlier ones. You can have a general project CLAUDE.md and more specific ones in subdirectories.

What To Put In CLAUDE.md

GOOD things to include:

- Build/run/test commands

BAD things to include:

CLAUDE.md is loaded every session. Keep it focused on stable knowledge.

Token Cost

Everything in CLAUDE.md uses context tokens. A 500-word CLAUDE.md is roughly 400 tokens. That's context you can't use for conversation.

Keep CLAUDE.md concise. Bullet points over paragraphs. Key facts over comprehensive documentation.

Viewing What's Loaded

Check what CLAUDE.md files are active:

/context

This shows which files Claude Code loaded and their token cost.

Ignoring CLAUDE.md

If a CLAUDE.md is causing problems:

claude --ignore-memory

Starts without loading CLAUDE.md files. Useful for debugging.

Example: Perl Web Project

Here's a real CLAUDE.md for a Perl Mojolicious project:

techalicious-academy

Pay-per-tutorial platform built with Perl/Mojolicious.

Stack

Running

- Dev: morbo script/academy
- Prod: hypnotoad script/academy
- URL: http://localhost:3000

Structure

- lib/TechaliciousAcademy.pm - main app, routes
- lib/TechaliciousAcademy/Controller/* - route handlers
- lib/TechaliciousAcademy/Model/* - database access
- templates/* - HTML templates
- tutorials/* - tutorial content (text files)

Key Files

- config/academy.conf - all configuration
- data/academy.db - SQLite database (gitignored)

Style

- Test::More for tests

Auth

Under 200 words. Gives Claude Code everything it needs.

Summary

CLAUDE.md = project memory that persists across sessions

Locations:
  ~/.claude/CLAUDE.md     Global preferences
  ./CLAUDE.md             Project-specific

Create it:
  /init                   Auto-generate from codebase

note Add quick notes during session

Keep it:

Next chapter: Using Claude Code effectively.