I build everything in my homelab with Claude Code. At the start of every session it reads its rules file, its memory index and (in my setup) a todo list, before any work happens. Mine had grown into one big pile for every project, so every task paid for all of it. This post is how I split it up per project and put it all in git. It works on Windows, Mac and Linux, and every command has a Copy button.
Why bother
Claude Code loads CLAUDE.md (your rules) and MEMORY.md (the index of its memory notes) at the start of every session. Many people also tell it to read a todo.md first. When those files cover every project at once, you pay for all of them on every task.
| Loaded per session | |
|---|---|
| Before: one rules file, one memory index, one todo list for everything | about 35 KB |
| After: split per project (measured 2026-10-23) | about 5 KB |
It does not make Claude think faster. It cuts wasted reading, and git makes mistakes cheap to undo.
Where to run each command
- Terminal: on Windows, Start menu → PowerShell; on Mac, Terminal. All commands below work in both, run inside the folder named above each block.
- Claude Code: the CLI, the desktop app or the IDE extension; all of them read the same files.
The setup, step by step
1. One folder per project, all under one parent folder
For example Projects\GameOne, Projects\BillTracker, Projects\HomeServer. Loose notes that belong to no project sit in Projects\ itself.
2. Start each session in the project’s own folder
Claude Code keeps a separate memory for each starting folder, in ~/.claude/projects/<folder name>/memory/ (Windows: C:\Users\<you>\.claude\projects\...). The folder name is the full path with the slashes, colon and underscores turned into dashes. A session started in Projects\GameOne loads only GameOne’s notes.
Moving to this layout? Old notes all live in the parent folder’s memory. Ask Claude to move each project’s notes into that project’s memory folder, and to keep only shared notes (about you, your computer, backups) in the parent’s.
3. Split the rules file in two
Claude Code also reads CLAUDE.md files in parent folders, so a short shared file in Projects\ reaches every project. Put only what applies everywhere in it. A starting point, saved as Projects/CLAUDE.md:
# My projects
Keep responses concise. Each sub-folder is its own project and git repo;
project details live in that folder's CLAUDE.md / todo.md / memory.
## About me
- How I like answers (short, plain text, full-path commands, ...)
- My computer, my accessibility needs, who uses what I build
## Rules for every project
- Connection / deploy rules that apply everywhere
- Ask before anything that costs money or touches real accounts
- End every work session: test it, then git commit + push
Everything project-specific goes in that project’s own CLAUDE.md: what it is, where the live code is, how to deploy and test, and rules that only apply there.
My own shared file holds how I like answers and commands, the SSH and Caddy rules that bit me before, and the git routine. It went from about 8 KB to 3.4 KB; the rest moved into the one project it was about.
4. Keep the memory index short
MEMORY.md is the memory’s table of contents and loads every session. Keep it to one short line per note. The details stay in the note files, which Claude opens only when needed. Every so often, ask Claude to tidy its memory: merge duplicates, delete stale notes, shorten long lines. One of my notes had grown into a 44 KB diary. Trimmed to the facts still true, it was about 4 KB. My shared index went from 8 KB to 1.4 KB.
5. Todo lists: open items only
Keep one short todo.md per project with what is still open and the how-to steps you reuse. Move finished items and change logs out; git keeps the old version. Mine went from 18.6 KB to 4.3 KB.
6. Put every project in git, with a private remote
Run git init in each project folder and push it to a private repo: a private GitHub repo, or your own server (mine is Forgejo, home-only). What it buys you when working with Claude:
- Undo: a broken change goes back with one command instead of Claude rebuilding the old version by hand.
- What changed:
git logandgit diffshow it in a few lines, so the notes can stay short. - Safe cleanup: old scratch and copy files can be deleted, because git keeps them. Stale copies confuse every search Claude does. I deleted 43 of them from one project.
- App features: the diff view, code review and side-by-side sessions in Claude Code need a git repo.
Give each repo a .gitignore so big generated files and real secrets stay out. A starting point:
# build output and generated files
/dist/
/out/
__pycache__/
*.log
# local databases
*.db
*.sqlite
# secrets: keep these in a password manager
.env
secrets.env
*.jks
*.keystore
Before the first push, check what git is about to upload (run in the project folder):
git ls-files
Gotcha: a rule like source/*.pdf only matches a source folder at the top of the repo. Use **/source/**/*.pdf to match one anywhere. An 8 MB scanned PDF slipped into my first commit that way.
7. Back up Claude’s memory too
The memory folder lives outside your projects, so a dead computer takes it with it. Make ~/.claude/projects its own private repo that tracks only the memory sub-folders. That folder also holds chat transcripts and pasted images (mine: about 950 MB), which stay out. Save this as .gitignore inside ~/.claude/projects:
# Only the memory folders go in git
/*
!/.gitignore
!/*/
/*/*
!/*/memory/
Then, in that folder:
git init -b main
git add -A
git commit -m "Claude memory snapshot"
Add your private remote and push it like any other repo. On a new computer, put it back with (run in ~/.claude/projects, replace the address with your repo):
git init -b main
git remote add origin https://your-git-server/you/claude-memory.git
git fetch origin
git checkout -f -B main origin/main
8. End every session the same way
Ask Claude to test the change, update the project’s notes if something new was learned, then commit and push. Put that in the shared CLAUDE.md (step 3) so it happens without asking.
Easiest way: let Claude do it
Open Claude Code in your parent folder and paste this. It plans first and shows you before changing anything:
Help me make my Claude Code setup lean. Plan first and show me before changing anything:
1. Split CLAUDE.md into a short shared file here and one CLAUDE.md per project folder.
2. Move each project's memory notes into that project's memory folder; keep shared notes here; shorten the MEMORY.md index to one short line per note.
3. Cut todo.md down to open items, per project.
4. Put each project folder in its own git repo with a .gitignore (no secrets, no big generated files), and show me which old scratch files could be deleted.
5. Make my memory folder a git repo that tracks only the memory sub-folders.
Troubleshooting
A session in a project folder doesn’t remember the project
- Where:
~/.claude/projects/(Windows:C:\Users\<you>\.claude\projects\). - Open: a terminal. List the folders Claude Code has made:
ls ~/.claude/projects
- Look for: a folder named after the project’s full path. If the one Claude Code created is spelled differently from the one you moved the notes into, move the
memoryfolder into the one it actually uses.
git push asks for a password or fails
- Where: the terminal where you ran it (git has no log file).
- Look for:
terminal prompts disabledmeans it ran from a shell that can’t show the sign-in window, so run it in a normal terminal window.repository not foundmeans the remote repo doesn’t exist yet; create it on the server first.Authentication failedmeans a wrong saved password; on Windows remove it under Control Panel → Credential Manager → Windows Credentials and push again.
Notes
- These loading rules (parent
CLAUDE.mdfiles, one memory folder per starting folder) are what I saw in Claude Code in October 2026. If something looks different, check the current Claude Code docs. - Real passwords and keys don’t belong in git or in Claude’s notes. Keep them in a password manager.
- Big generated files (audio, builds, downloaded installers) stay out of git through
.gitignore. They are rebuilt from the scripts in the repo.