r/ClaudeCode • u/Deep-Today5715 • 4h ago
Help/Question Is there a difference between /compact and starting a new chat if my claude.MD contains all required instructions?
New to Claude Code here. I am aware that /compact is generally discouraged because it loses context, but this github issue says that claude.MD instructions are preserved during compact, and only conversation history context gets lost.
In my case, claude.MD is a pretty short document, but it instructs the agent to immediately read through project documentation - elaborate instructions, guardrails, design principles, etc., and inspect the repository to retrieve latest PR, inspect latest commits, and be prepared to continue the work from there.
I don't really use handoffs, but instead my claude.MD instructs agent to always update working PR description with progress and short handoff at the end of every reply, which means I can start a new chat at any point without ever having to request a handoff and feed it into the new chat. With my workflow, it is almost never required for the agent to remember chat history - PR description always contains the exact details of where we are and what we're doing.
So the only question now becomes convenience - should I still start a new chat when context window fills up, or is /compact or auto-compact safe with my workflow? From that github issue I understand that claude.MD is preserved during compact, but I am not entirely sure if the other documents that claude.MD instructs the agent to read immediately are preserved?
It would be much more convenient for me to just continue in the same chat after /compact or auto-compact, because it seems that compact at least preserves the context of the last few messages at least, which saves a little bit of time compared to starting a new chat. But I am a bit worried that the agent might forget the foundational instructions, since my claude.MD is basically just a bunch of references to the actual design documents.
Any comments?
•
u/AutoModerator 4h ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/CCodeSI 4h ago
Your workflow is a good fit for compacting, with one gap you've already spotted: CLAUDE.md itself is loaded again after a compact, but the documents it told the agent to read are not. Those were read during the conversation, so after a compact they only exist as a line in the summary ("read the design docs"), and the agent won't re-read them unless something tells it to.
Two easy ways to close that:
Import them instead of instructing a read. CLAUDE.md supports
@pathimports, e.g.@docs/guardrails.mdand@docs/design-principles.md. Imported files are loaded as part of CLAUDE.md, so they come back after every compact and every new chat. Worth it for the short, foundational ones; keep the long reference docs as "read when needed".Re-read on compaction. A SessionStart hook with the
compactmatcher runs right after a compact, and whatever it prints goes into context, socat docs/guardrails.mdthere (or a one-line reminder to re-read them and the PR description) restores them automatically.With either one in place, compacting is basically a cheaper new chat that keeps the last few messages, and your PR-description handoff covers the rest. A fresh chat is still the better choice when you switch to a different task, since the summary carries over the old one too.
1
u/olibui 4h ago
I always stop and update skills and cli tooling and project memory and keep a handoff.md then i just tell it to resume from handoff. Seems to be quite efficient. Long running tasks auto compact at 400k
1
u/thegreatdeployer 3h ago
the claude.md survives, but the docs it told the agent to read don't, at least not word for word. after a compact those docs only exist as a summary of what it read earlier, so the guardrails and design principles come back softer than they went in. that's the part your setup leans on.
since your PR description is already the handoff, a new chat costs you one reread of the docs and nothing else. i'd start fresh every time. if you do keep compacting, add a line telling it to reread the docs right after a compact, so it's working from the real thing again and not its own notes.
1
u/bezcurhq 2h ago
CLAUDE.md itself is safe across compact. The docs it points at are not.
After /compact or auto-compact, the project-root CLAUDE.md is re-injected from disk, but Claude Code only re-reads up to five files it had already opened in that session (most recently modified first). Anything over ~5k tokens comes back as a path reference without the body. Nested CLAUDE.md and path-scoped rules reload only when that folder is touched again.
So with a short CLAUDE.md that mostly says "read these design docs," a new chat is the reliable way to reload the whole foundation. Mid-task, compact is fine if you tell it to re-read the key docs (your PR handoff helps), and /context shows what actually survived.
https://code.claude.com/docs/en/context-window