[BUG] Claude Skills context completely lost after auto-compaction, causing repeated errors and massive productivity loss
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
After auto-compaction occurs, Claude completely loses awareness of Claude Skills that were actively being used. Specifically:
- Claude forgets which skills were being used during the session
- Claude forgets the procedures/methodologies from those skills
- Claude does NOT proactively re-read the skill files after compaction
- Claude repeats errors that the skills were specifically designed to prevent
- Even explicit instructions in ~/.claude/CLAUDE.md telling Claude to reload skills after compaction are ignored
This causes simple coding tasks that should take ~1 hour to take 5-6+ hours, with constant circling back to repeat mistakes the skills were designed to prevent.
What Should Happen?
- Compaction summary should record which skill files were actively loaded/referenced during the session
- After compaction, Claude should automatically re-read those skill files before continuing work
- Or: Critical skill procedures should be preserved in the compaction summary itself
- At minimum: Claude should follow the post-compaction recovery instructions specified in ~/.claude/CLAUDE.md
Error Messages/Logs
No error messages - the issue is silent context loss. The only observable symptom is Claude suddenly not following skill procedures it was following moments before, and repeating previously-fixed mistakes. Once I realized what was happening, I asked Claude (Opus 4.5) why it wasn't using the Skills I had it invoke earlier ... and Claude had no idea what I was talking about, or any memory of having had used Skills earlier.
Steps to Reproduce
- Create a skill file at ~/.claude/skills/test-skill/SKILL.md with specific procedures:
name: test-skill description: Test skill for reproduction
Test Skill
Required Procedure
When working on any task, ALWAYS:
-
Say "SKILL ACTIVE" at the start of each response
-
Follow the XYZ methodology
-
Never do ABC (common mistake)
-
Add post-compaction recovery instructions to ~/.claude/CLAUDE.md:
POST-COMPACTION PROTOCOL
After compaction, IMMEDIATELY:
- Re-read this file
- Re-read any skills that were in use
- Ask user which skills were being used
3.Start Claude Code in VS Code and begin a task that uses the skill 4. Verify Claude says "SKILL ACTIVE" and follows the procedures 5. Continue working until auto-compaction triggers (~55K tokens in VS Code extension) 6. Observe after compaction: Claude no longer says "SKILL ACTIVE" 7. Observe: Claude starts doing "ABC" (the thing the skill said never to do) 8. Observe: Claude does not re-read the skill file or ask about skills, despite CLAUDE.md instructions
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
No response
Claude Code Version
2.0.69 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
Environment:
OS: Windows 10 Editor: VS Code Insiders with Claude Code Chat extension Model: Claude Opus 4.5 Platform: Claude Pro Max ($200/mo subscription)
Impact:
| Without Skills Loss | With Skills Loss |
|---------------------|------------------|
| Task completed in ~1 hour | Task takes 5-6+ hours |
| Errors caught by skill procedures | Same errors repeated multiple times |
| Linear progress | Going in circles |
| Single compaction cycle | 4-6 compaction cycles, each losing more context |
Workaround attempted:
Added explicit post-compaction instructions to ~/.claude/CLAUDE.md (shown above in reproduction steps). Result: These instructions are also lost/ignored after compaction.
Related issues:
#1534 - Memory Loss After Auto-compact (closed, but issue persists) #3021 - Forgets to Refresh Memory After Compaction #8209 - Procedural Memory vs Episodic Memory #10960 - Repository Path Changes Forgotten After Compaction #11819 - Premature compaction threshold compounds this problem
Suggested solutions:
- Preserve skill references in compaction summary - Record file paths of skills that were read during the session
- Auto-reload skills post-compaction - After compaction completes, automatically re-read skill files that were in use
- Skills as protected context - Allow marking certain content (like skills) as "protected" from compaction summarization
- Honor CLAUDE.md post-compaction instructions - Ensure the recovery protocol in CLAUDE.md is followed
This bug makes Claude Skills essentially unusable for any task that exceeds the premature compaction threshold (~55K tokens), which severely limits the value of this powerful feature.
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/6354
- https://github.com/anthropics/claude-code/issues/9796
- https://github.com/anthropics/claude-code/issues/3021
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
It's none of those ... this issue is specific to the complete loss of use & memory, of any Claude Skills invoked/in-use before compaction.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
wtf this is still a very annoying bug - pls open again
Yes, this is a big issue. What I do as a workaround (which is very annoying) is to stop any work in progress when compacting is executed, and then force Claude to reload all the skills before continuing.
agent confidently misattributing its own changes as someone else's work
@jaslrobinson i think that is a separate issue, but i noticed this too..
Hey — saw your issue. The 1-hour tasks expanding to 5-6+ hours after compaction is the specific failure mode I keep seeing — and in your case it's happening with Skills invocations, which makes it even harder because the agent doesn't just forget rules, it forgets entire working procedures.
I'm testing a narrow fix: a memory layer that keeps exact project constraints and procedures outside the compaction path so they're available in fresh sessions without re-teaching them. The discipline matters — it only works with concretely-named constraints, not vague context.
I'm looking for a couple of people to run a quick before/after test on a real workflow. ~20 minutes, you run your normal task, I compare what the agent does with and without the layer. Either it works or it doesn't — either way I get honest data.
Would you be up for that?
Skills being forgotten post-compaction was a big pain point for us too. The issue is that compaction fires before you have a chance to intercept and save what matters.
We built Cozempic to solve this — it hooks into PreCompact and prunes the session file aggressively beforehand (collapses progress bars, strips tool output noise, deduplicates reads), so compaction gets deferred and when it does fire the context is already lean.
pip install cozempic && cozempic guard
We use this internally on all long sessions. Open-sourced it after this kind of skills-amnesia kept costing us hours of rework.
Would love to know if it makes a dent for you — and whether there are skill types that are still getting lost even with pre-compaction pruning.
Skills context is lost after compaction because it lives in the conversation context. A UserPromptSubmit hook can re-inject skill awareness:
SKILLS_DIR=".claude/skills"
if [ -d "$SKILLS_DIR" ]; then
SKILL_LIST=$(ls "$SKILLS_DIR"/*.md 2>/dev/null | xargs -I{} basename {} .md | tr '\n' ', ' | sed 's/,$//')
if [ -n "$SKILL_LIST" ]; then
echo "{\"hookSpecificOutput\":{\"additionalContext\":\"Available skills (re-injected by hook): $SKILL_LIST. Use /skill-name to invoke. Skills are in $SKILLS_DIR/\"}}"
fi
fi
exit 0
INPUT=$(cat)
SKILL=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
if [ -n "$SKILL" ]; then
echo "$SKILL" > "$HOME/.claude/.active-skill"
fi
exit 0
ACTIVE_SKILL="$HOME/.claude/.active-skill"
if [ -f "$ACTIVE_SKILL" ]; then
SKILL=$(cat "$ACTIVE_SKILL")
SKILL_FILE=".claude/skills/$SKILL.md"
if [ -f "$SKILL_FILE" ]; then
CONTEXT=$(head -20 "$SKILL_FILE")
echo "{\"hookSpecificOutput\":{\"additionalContext\":\"Active skill: $SKILL. Key procedures:\\n$CONTEXT\"}}"
fi
fi
exit 0
{
"hooks": {
"UserPromptSubmit": [
{"hooks": [{"type": "command", "command": "bash ~/.claude/hooks/skill-reinject.sh"}]},
{"hooks": [{"type": "command", "command": "bash ~/.claude/hooks/skill-restore.sh"}]}
]
}
}
The hooks re-inject skill context on every prompt — this survives compaction because the hooks read from the filesystem (which isn't affected by context compression), not from the conversation history.
@yurukusa the filesystem-backed hook approach is exactly right — if the hook reads from disk, compaction can't touch it. That's the core insight.
One thing worth noting on UserPromptSubmit: it fires on every prompt submission, not just after compaction. That's overhead on every user message, and it means you're re-injecting context that's already present for the first N turns of a session. The hook that fires exactly when re-injection is needed is InstructionsLoaded with reason: compact — that event only fires post-compaction, so the injection is surgical.
Threadbase packages this as a working tool:
pip install threadbase
cd your-project && threadbase init
Three hooks: SessionStart injects rules at session open, InstructionsLoaded (reason: compact) re-injects after compaction, PreToolUse blocks protected path edits before they land. Everything's logged — you can see exactly when rules were re-injected and why.
If skills loss after compaction is your specific pain, happy to do a concierge test on your setup. What skills are dropping?
Quick correction on install — until we're on PyPI, the install is from the repo directly:
pip install git+https://github.com/lipcool8-ship-it/threadbase.git
cd your-project && threadbase init
PyPI publish is coming. For now the git install works identically.
Quick update: Threadbase is now on PyPI. The git URL in my earlier comment works but the clean install is:
pip install threadbase
cd your-project
threadbase init
Apologies for the extra step before.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.