If you are scripting Claude Code with claude -p --resume, watch out for a silent context killer. A new deep-dive analysis published on DEV.to on October 5, 2026, reveals that while the root CLAUDE.md file reliably survives compaction 8 out of 8 times, invoked skill bodies vanish when the compaction happens in a different process than the skill invocation. The study, conducted on Claude Code version 2.1.285, exposes a critical gap between documentation and behavior for headless, resumed sessions.
The Resume Gap
The core finding hinges on how compaction is triggered. In six out of eight tests where /compact was run inside a single streaming process, the invoked skill body was correctly re-attached to the context. However, in the two tests where /compact was sent via claude -p --resume (simulating a session restart or script handoff), the skill body was completely missing. The transcript showed only a summary sentence about the skill, not the actual instructions. This contradicts the official docs, which state that invoked skill bodies are re-injected after compaction, capped at 5,000 tokens per skill.
Root Files Persist, Nested Rules Flicker
While skills are fragile, the root configuration is rock-solid. The CLAUDE.md file at the project root and any files imported via @ were re-read from disk in all 8 tests, even after the files were edited mid-session. This confirms that prompt caching does not prevent fresh reads after a compaction boundary. However, nested CLAUDE.md files and path-scoped rules are far less reliable. They only survived in 4 of 8 compactions, and only when they happened to be among the five most recently modified files that the process remembered reading. If you have a complex directory structure, your sub-directory rules are essentially gambling on file modification timestamps.
The Double-Marker Problem
Another quirk discovered in the lab involves editing CLAUDE.md before compacting. The tests showed that after compaction, the model often sees two versions of the root file: the new version re-read from disk, and the old version preserved in the compaction summary. In all six edit tests, the model noticed this discrepancy, with one instance stating, "Either the files changed, or the summary is wrong." This creates a confusing state where instructions conflict, and the model has no clear directive on which version takes precedence unless a explicit "replaces earlier copy" note is present, which only appeared during --resume startups, not standard compaction.
Key Takeaways
- Avoid
claude -p --resumefor workflows that depend on previously invoked skills; the skill body is dropped during cross-process compaction. - Keep critical global instructions in the root
CLAUDE.mdor unscoped rules, as these are re-read from disk in every tested scenario. - Do not rely on nested
CLAUDE.mdfiles for persistent rules across compactions; they only return if they are among the five most recently modified files. - If you edit
SKILL.mdmid-session, you must re-invoke the skill after compacting to ensure the latest version is in context.
The Bottom Line
Documentation is great, but transcripts don't lie. If your automation breaks after a session resume, itβs likely because your skill context evaporated while the docs promised it would stay. Move critical logic to the root file or re-invoke skills manually post-compaction.