Stop Claude forgetting you: CLAUDE.md and /compact
Six hours in, Claude forgot your name. What to put in CLAUDE.md so it never forgets, and when to compact or clear the chat.
The fix: put it in CLAUDE.md
What must survive goes in a file, not in the chat. Claude Code reads CLAUDE.md at the start of every session. After /compact it reads the project-root file again from disk. Create it in the project root, or run /init to generate a first version. Run /memory to open and edit it later.
# CLAUDE.md (project root)
## About me
- My name is Tommaso. Call me Tommaso.
## Rules
- Run npm test before you say done.
- Never edit files in /dist.When the chat gets long
Same task, too much history: /compact, with a focus so the summary keeps what you choose. New, unrelated task: /clear, which starts with empty context. Give /clear a name and you can return to the old chat with /resume.
/compact keep the open TODOs and the API decisions
/clear button-fix
/resume button-fixCheck it worked
Run /context. Under Memory files you should see your CLAUDE.md. Then run /clear and ask Claude what your name is. It should answer from the file.
/contextPro tip: steer every summary
Add a Compact instructions section to the same CLAUDE.md. Claude Code uses it to decide what to keep when it compacts.
# Compact instructions
When you are using compact, please focus on
test output and code changesPro tip: compact part of a chat, or earlier
Run /rewind, pick a message, and choose Summarize from here or Summarize up to here to compact only part of the conversation. To compact before the window is nearly full, set the threshold (100K to 1M tokens).
/autocompact 500kCommon mistake
Telling Claude a rule once, early in the chat. Compaction keeps your requests and key code, but detailed instructions from early on may be lost. Anything that must last goes in CLAUDE.md. Rules in nested CLAUDE.md files or with paths: frontmatter are summarized away too; keep the important ones in the project-root file. More on keeping CLAUDE.md in git: comment NOTES under our reel, or open the NOTES guide.
Official docs
One fix of twenty: the whole Claude Code survival kit.
Follow @whyshouldaicareA new disaster and its fix every day. Comment the word under a reel to get its guide.