# How to Give Claude Code Memory From Your Notes Repo

> Give Claude Code memory from a notes repo: a CLAUDE.md under 200 lines, a folder map, frontmatter on every note, and path rules that load only when needed.

Updated 20 Nov 2026 by Atharva Shah. Canonical page: https://brainfeed.atharvashah.com/blog/claude-code-memory-from-notes-repo/

## The Short Version

- Claude Code loads a CLAUDE.md file at the repo root at the start of every session.
- Keep the CLAUDE.md file under 200 lines, imports included.
- Split notes into an inbox and a library so Claude knows which notes to trust.
- Give one folder its own rule file so those rules load only when Claude works there.
- Test the repo monthly with one real task in a fresh session.

Every day you explain yourself to Claude Code again. A Claude MD file fixes that. It is one file named CLAUDE.md at the top of your notes repo, and Claude reads it at the start of every session. Keep it under 200 lines.

You tell it who you are, what the project is, and how you like things done. Your notes already hold all of it, but Claude starts every session knowing none of it. Put a folder map in CLAUDE.md, the files to read first, and the rules for adding notes. Give every note a short header, and give folder-specific rules their own file.

This guide covers the file, what goes in it, and a monthly test that shows what is missing. Every rule on how Claude loads files comes from the [Claude Code memory documentation](https://code.claude.com/docs/en/memory). For the wider picture of agents over your notes, read the guide to the [AI second brain](https://brainfeed.atharvashah.com/blog/ai-second-brain/).

## Claude Code Reads CLAUDE.md Files in a Fixed Order

Claude Code reads instructions from three places when it starts. These files are the instruction part of [context engineering](https://brainfeed.atharvashah.com/blog/context-engineering/), the work of giving a model the right information for each step.

| File | Covers | Shared with others |
|---|---|---|
| Your personal CLAUDE.md | Every project on your computer | No |
| CLAUDE.md in the repo | This repo | Yes |
| CLAUDE.local.md in the repo | This repo, only you | No |

It reads the files in the folder you open and every folder above it. The file closest to where you started Claude is read last.

Files in subfolders wait. A CLAUDE.md inside one project folder loads only when Claude opens a file in that folder. So you can put folder notes where they apply, at no cost to other sessions.

Your personal file holds how you like to work. The repo file holds what the notes are. Keep each fact in one of them, never both.

## The Main CLAUDE.md Says What the Folder Is and How It Works

The main file answers four questions for a reader with no history:

- what the folder is for
- where each kind of note lives
- which files to read before a task
- the rules for adding to it

The template I hand out in my second brain workshop has four short sections:

- **How the folder is organized:** an inbox for new material that stays a week at most, an about folder with your bio, goals and preferences, one folder per project with a status note, a library of reviewed notes with one idea each, and an archive.
- **Read these first:** your about-me note, your preferences note, and the status note of the current project.
- **Rules for adding:** new material goes to the inbox first, every library note keeps its source, an AI summary never replaces the source, and each note holds one idea.
- **Rules for answering:** answer from my notes first and name the note, say when my notes lack the answer, and flag a note that looks out of date.

The template sets one test for a finished file. A stranger opens the folder, reads this file, and keeps the system running for two weeks without asking you a question.

Claude can draft the file for you. Its built-in setup command reads the repo and suggests a CLAUDE.md, and it suggests changes when one exists. On a notes repo the draft needs editing, because it looks for software build steps a notes folder does not have. The free [AGENTS.md generator](https://brainfeed.atharvashah.com/tools/agents-md-generator/) also outputs a CLAUDE.md for a notes repo from a short form.

## Folders Tell Claude Which Notes to Trust

A folder name is the cheapest signal you can give an assistant. Claude sees where every file lives.

Split the repo by trust level. The inbox holds material nobody reviewed. The library holds notes you checked. Then write the rule into CLAUDE.md: answer from the library first, and treat the inbox as unverified.

Without that split, Claude weighs a pasted newsletter issue and a note you rewrote three times as equals. Both look the same to a search.

## A Short Header Gives Each Note a Type, a Source and a Date

Folders sort notes into groups. A header at the top of each note, called frontmatter, describes the note itself. Four fields cover most of what an assistant needs:

- **Type:** what the note is, such as a claim or a project.
- **Source:** where the idea came from.
- **Status:** whether you checked it.
- **Updated:** the date, so Claude can flag a stale note instead of trusting it.

The header loads with the note whenever Claude opens it. One search also finds every note still marked as a draft. The guide to [Markdown frontmatter for AI agents](https://brainfeed.atharvashah.com/blog/markdown-frontmatter-for-ai-agents/) covers more fields.

## Folder Rules Load Only for the Folder They Govern

Some rules apply to one folder. "Every library note names its source" means nothing while Claude edits a project status note. Loading it in every session wastes room.

Claude Code lets you put such rules in a separate rule file tied to one folder. The file names the folder it covers, then lists the rules, for example: one idea per note, a first line that states the idea, and a source on every note. Claude loads it only when it opens a file in that folder. The [Claude Code memory documentation](https://code.claude.com/docs/en/memory) shows where the file goes and how to name the folder.

## Imports Tidy a Long File but Cost the Same Room

CLAUDE.md can pull in another file with one import line, up to four hops deep. Use it to point at a note you already keep, such as your preferences. Then the preferences live in one place.

An import does not save room. The documentation says imported files load together with the CLAUDE.md that imports them. So the 200-line target applies to the whole bundle. A folder rule cuts what loads. An import only moves text around.

## Claude Follows Rules It Can Check and Treats the Rest as Advice

The memory docs say Claude treats CLAUDE.md as context, not enforced configuration. So a vague rule gets a vague result. The docs give the fix: write rules concrete enough to verify, such as "Use 2-space indentation" over "Format code properly".

My rule of thumb for a notes repo is the one-file test. If you cannot check a rule by opening one note, rewrite it until you can.

**Example.** Three rules from a notes repo, before and after the one-file test.

| Vague rule | Rule you can check in one file |
|---|---|
| Keep notes tidy | Every library note starts with one sentence that states its claim |
| Cite your sources | Every library note has a source field with a link or a book title |
| Be careful with old notes | Treat any note with an updated date older than 12 months as possibly stale, and say so |

Some rules must hold every time, such as "never edit a note in the library". Text cannot promise that. The docs point to a hook, a script Claude Code runs before a tool call, to block an action whatever Claude decides. I learned this in my own vault. A writing rule in CLAUDE.md got skipped on some drafts. A hook that runs a scorer after each save and blocks a bad draft never skips.

The same holds for the agent prompt I wrote for Brainfeed. It carries the line "Never accept or reject ideas yourself. Only I swipe." That line is advice. The real lock is the token: Brainfeed tokens come in three scopes, read, notes and full, so an agent gets the smallest one it needs.

## Two Rules That Disagree Make Claude Pick Either One

The docs warn that when two instructions contradict each other, Claude may pick one arbitrarily. In a notes repo this happens slowly. You write "keep notes short" in January and "add a full summary to every note" in June.

The fix takes two steps:

1. **Keep each rule in one file.** A rule in your personal file and a different rule in the repo file look like a conflict to Claude.
2. **Run the built-in audit every quarter.** The prompt audit command in Claude Code checks your instruction files for outdated rules, missing files and contradictions. It proposes edits and changes nothing until you approve.

## Each Kind of Fact Has One Right Home

Most memory problems come from a fact in the wrong file. Use this table to place each one.

| The fact | Where it goes | Why |
|---|---|---|
| How you like answers written | Your personal CLAUDE.md | It holds across every project |
| What the folders hold and which notes to read first | CLAUDE.md in the repo | Anyone who clones the repo needs it |
| A rule for one folder only | A folder rule file | It loads only when Claude works there |
| A rule that must never break | A hook | Text is advice, and a hook blocks the action |
| A decision, a client fact, a lesson | A note in the library | It is knowledge, not an instruction |
| A correction Claude picked up | Auto memory first, then a note once it proves useful twice | Auto memory stays on one computer |

## One File Serves Claude Code and Codex Both

People switch tools when one hits a limit. One builder [wrote on X](https://x.com/i/status/2123401016666140776) that when Claude Code hits its limit he moves to Codex and explains his whole project again from zero.

A notes repo removes that restart. Codex reads AGENTS.md. Claude Code reads AGENTS.md when no CLAUDE.md exists, and a CLAUDE.md can import AGENTS.md with one line. So put the shared folder map and rules in AGENTS.md, and keep CLAUDE.md for rules only Claude needs. The guide to [what AGENTS.md is and which agents read it](https://brainfeed.atharvashah.com/blog/agents-md/) shows the split.

## Move Lasting Facts From Auto Memory Into the Repo

Claude Code also writes notes on its own, called auto memory. It stays on your computer, outside your repo. Claude reads the first 200 lines or 25KB of it each session, and you can turn it off.

Auto memory catches corrections you forget to write down. A new laptop or a teammate never sees it, though.

So promote what matters. When a fact in auto memory proves useful twice, move it into CLAUDE.md or a note in the repo. My own rule is short: if I type the same correction twice, it goes in a file.

## A Fresh Session Shows You Which Files Are Missing

A new hire who gets stuck asks a colleague. A fresh Claude session has nobody to ask. So it guesses, and the guess sounds confident. That makes it the strictest reader of your notes.

Run this test once a month:

1. Open a fresh session in the repo.
2. Give it one real task with no explanation, such as "plan my week".
3. Write down every question it asks and every wrong guess it makes.
4. Write the note that answers each question.
5. Run the same task in another fresh session.

Each question names a note you lack. After two or three rounds the questions stop, and the task runs from the notes alone.

## Feed the Repo New Notes You Checked

CLAUDE.md tells Claude how to read your notes. The notes still decide what Claude knows. A repo that stops growing gives the same answers next month.

Brainfeed adds checked notes to the same repo. Agents read the newsletters you follow and compare each idea to your notes. Ideas you accept land in a brainfeed folder as one pull request you merge. Add one sentence to CLAUDE.md that says the folder holds ideas you accepted from newsletters, each with its source.

## A CLAUDE.md File Is the Wrong Fix in Two Cases

The file helps only when Claude Code works inside the notes folder. Skip it in these cases.

- **Your notes live in a hosted app with no local folder.** Claude Code reads files on your computer. It cannot load a note it never sees.
- **You use only other assistants.** Codex and Cursor read AGENTS.md, so [an AGENTS.md file](https://brainfeed.atharvashah.com/blog/agents-md-for-second-brain/) serves them better.

## Example: One Accepted Idea Lands in the Repo

**Example.** This is demo content, not a real run.

- **Input:** an Import AI issue reports a new method for long-context recall.
- **Card:** labeled **new**, because no library note covers it.
- **You swipe:** accept.
- **Result:** a new note on the method, with the source issue in its header, added in one pull request you merge.

## Write Your CLAUDE.md Today

Create CLAUDE.md at the top of your notes repo. Add the folder map, the files to read first, and the rules for adding notes. Keep it under 200 lines. Then run the fresh session test.

To see which newsletters fit the notes you already have, run the [free Brainfeed scan](https://brainfeed.atharvashah.com/#try) on your repo.

When the matches fit, let Brainfeed read those newsletters every week. Each idea arrives as a card labeled new, builds on or conflicts, and conflict cards quote your own note as evidence. Your first pull request is free. Paid plans start at $9 for your first month, then $19, at [brainfeed.atharvashah.com/#join](https://brainfeed.atharvashah.com/#join).

## Questions and Answers

### Where does Claude Code look for CLAUDE.md files?

At launch it loads your personal CLAUDE.md, plus every CLAUDE.md and CLAUDE.local.md in the folder you open and each folder above it. Files in subfolders load later, when Claude reads or edits a file in that subfolder. The Claude Code memory docs list every location.

### How long should a CLAUDE.md file be?

The Claude Code documentation sets a target of under 200 lines per CLAUDE.md file. Longer files use more context and Claude follows them less consistently. Move rules that apply to one folder into a separate rule file tied to that folder. It loads only when Claude works with matching files.

### Can a CLAUDE.md file include other files?

Yes. One import line pulls another file in, and the Claude Code memory docs show the format. Imports can nest up to four hops deep. An import organizes a long file but does not save context, because the imported file loads with the CLAUDE.md that imports it.

### What is the difference between CLAUDE.md and Claude Code auto memory?

You write CLAUDE.md, and it holds instructions and rules. Claude writes auto memory from your corrections, and it stays on your own computer. Claude loads the first 200 lines or 25KB of auto memory each session. Keep facts you want in git inside the repo.

### Does CLAUDE.md survive /compact in Claude Code?

Yes, the CLAUDE.md at the project root survives. After /compact, Claude Code reads it again from disk and adds it back to the session. CLAUDE.md files in subfolders and folder rules load again when Claude next opens a matching file. An instruction you gave only in the chat is lost, so put it in a file.

### How do I test whether my notes repo gives Claude enough context?

Open a fresh session in the repo and give it one task with no explanation. Write down every question it asks. Each question names a file your notes lack. Write those files, then run the same task again in another fresh session.

## Read Next

- [AGENTS.md for a Second Brain: What to Put in It](https://brainfeed.atharvashah.com/blog/agents-md-for-second-brain/)
- [Second Brain in a GitHub Repo: Setup and Trade-Offs](https://brainfeed.atharvashah.com/blog/second-brain-in-github-repo/)
- [Markdown Frontmatter That Agents Can Use](https://brainfeed.atharvashah.com/blog/markdown-frontmatter-for-ai-agents/)
- [Give Claude Code Memory From the Newsletters You Read](https://brainfeed.atharvashah.com/use-cases/claude-code-memory-from-newsletters/)
- [Context Engineering Starts With the Notes You Keep](https://brainfeed.atharvashah.com/blog/context-engineering/)

## Try Brainfeed

Scan your notes free at https://brainfeed.atharvashah.com/#try. Your first pull request is free, and plans start at $9 for your first month, then $19, at https://brainfeed.atharvashah.com/#join.
