[Bug] Context Reset Breaks Mandatory Process Compliance
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?
Bug Report: Context Reset Breaks Mandatory Process Compliance
Severity: High
Component: Claude Code - Context Management & Session Resumption
Affects: All projects with mandatory pre-execution checks and custom skills
Problem Statement
Claude Code has no mechanism to enforce mandatory procedures across context resets, making it impossible to establish reliable operational guardrails. Users create skills and document critical rules to prevent repeated errors, but after a context reset, Claude completely ignores these safeguards and reverts to default behavior.
Reproduction Steps
- Create a mandatory skill (e.g., pre-command-check) that must run before specific tool invocations
- Document this as an ABSOLUTE RULE in global memory (~/.claude/CLAUDE.md or global knowledge files)
- Use it successfully in a session, establishing the pattern
- Trigger context reset (conversation length limit)
- Resume session from summary
- Observe: Claude executes tools without invoking the mandatory skill
Expected: Claude reads critical rules and invokes mandatory skills before tool execution
Actual: Claude ignores all established procedures and executes tools directly
Why This Is a Platform Issue, Not User Error
- No Bootstrap Phase After Context Reset
When a session resumes:
- Summary captures task state ("what we're working on")
- Summary does NOT capture operational procedures ("how we must work")
- No automatic loading of:
- CRITICAL-RULES-AND-PREFERENCES.md
- Mandatory skills list
- Pre-execution checklists
- Environment-specific requirements
Users cannot fix this - there's no way to force Claude Code to read these files before accepting the first user message.
- Skills Have No Enforcement Mechanism
Current skill system:
- ✅ Skills can be created
- ✅ Skills can be invoked manually
- ✅ Skills can be documented as "mandatory"
- ❌ No way to actually enforce invocation
- ❌ No pre/post-hook system for tool calls
What's needed: Skill metadata like:
trigger: before_tool
applies_to: [Bash, Edit, Write, MultiEdit]
enforcement: mandatory
- Global Memory Is Not Automatically Consulted
Users create global memory files like:
- ~/.claude/CLAUDE.md (already in system prompt, but not enforced)
- ~/claude_global_memory/knowledge/CRITICAL-RULES-AND-PREFERENCES.md
- Project-specific CONTEXT_RESET.md
Problem: These files are available but not automatically read after context reset. The summary mechanism doesn't include "read these critical files" as a mandatory first step.
- Tool Call Interception Is Impossible
Users need to enforce checks like:
- "Before any Bash command in WSL, verify if it's running a Windows executable"
- "Before any Edit, confirm file was read first"
- "Before any Write to /mnt/d/, check if directory exists"
Current workaround: Skills that must be manually invoked
What's needed: Pre-tool-call hooks that can intercept and validate
Real-World Impact
Example: WSL/Windows Command Execution
Context: User working in WSL2 accessing Windows filesystem
Critical Rule: Windows executables MUST be wrapped in cmd.exe /c when called from WSL
What should happen:
User requests: "build the project"
→ Pre-command-check skill invokes automatically
→ Detects: building uses dotnet.exe (Windows app)
→ Validates: running from WSL (/mnt/d/ path)
→ Enforces: wraps in cmd.exe /c "dotnet build ..."
What actually happens after context reset:
User requests: "build the project"
→ Claude executes: dotnet build ... directly
→ Command times out or hangs
→ User manually reminds Claude about the rule
→ Claude apologizes and wraps command properly
→ Cycle repeats at next context reset
Result: User babysits the same issue every ~200k tokens despite investing significant effort to create preventive systems.
Proposed Solutions
Solution 1: Mandatory Initialization Routine (Minimum Fix)
After context reset, before processing user message:
- Read ~/.claude/CLAUDE.md (already in system prompt - enforce it)
- Scan for files matching pattern:
- ~/claude_global_memory/knowledge/CRITICAL-*.md
- Project CONTEXT_RESET.md if exists
- Load skills marked as "mandatory" or "auto-invoke"
- Initialize any pre-tool-call validators
- THEN process user message
Solution 2: Tool Call Interception System (Better Fix)
Add hook points to tool execution:
hooks:
pre_tool_call:
- skill: pre-command-check
applies_to: [Bash, Edit, Write, MultiEdit]
enforcement: mandatory
can_block: true
post_tool_call:
- skill: verify-execution
applies_to: [Bash]
enforcement: optional
Skills can return:
- { approved: true } - proceed with tool call
- { approved: false, reason: "...", suggestion: "..." } - block and explain
- { approved: true, modified_params: {...} } - proceed with corrections
Solution 3: Rule Validation in Summary Generation (Complete Fix)
When generating context reset summary:
{
"task_summary": "...",
"critical_rules": [
{
"rule": "ABSOLUTE RULE #1: Windows commands via cmd.exe",
"source": "CRITICAL-RULES-AND-PREFERENCES.md",
"enforcement": "pre-bash-check"
}
],
"mandatory_skills": ["pre-command-check", "wsl-windows-commands"],
"bootstrap_actions": [
"Read CRITICAL-RULES-AND-PREFERENCES.md",
"Initialize mandatory skills",
"Validate environment (WSL2/Windows)"
]
}
Resumed session MUST complete bootstrap_actions before task execution.
Business Impact
For Individual Users:
- Wastes time repeatedly correcting the same errors
- Undermines trust in Claude Code's reliability
- Forces manual intervention that automation should prevent
For Teams:
- Cannot establish consistent operational standards
- Each team member hits the same issues
- Compliance rules cannot be enforced programmatically
For Anthropic:
- Makes Claude Code unsuitable for environments with strict operational requirements
- User frustration leads to reduced usage
- Feature gap vs. competitors with better automation hooks
Minimum Viable Fix
Add to session resumption logic:
def resume_from_context_reset(summary, user_message):
# NEW: Bootstrap phase
critical_files = find_critical_memory_files()
for file in critical_files:
read_and_internalize(file)
mandatory_skills = get_mandatory_skills()
for skill in mandatory_skills:
register_pre_tool_hook(skill)
# THEN proceed with normal flow
process_user_message(user_message)
This is ~20 lines of initialization logic that would solve 90% of the problem.
Test Case
- Create skill: pre-command-check marked as mandatory for Bash
- Create rule: "All Bash commands in WSL must check for Windows executables"
- Use successfully for 5-10 commands
- Trigger context reset
- First Bash command after reset should invoke pre-command-check automatically
- Current result: FAIL - skill not invoked
- Expected result: PASS - skill runs, validates command, proceeds/blocks appropriately
Workaround (Insufficient)
Current workaround: User manually reminds Claude after every context reset
Problems with workaround:
- Defeats purpose of automation
- Scales poorly (user has to remember to remind)
- Error-prone (user may forget)
- Wastes conversational context on repetitive instructions
Additional Context
- Affects all Claude Code users with custom workflows
- Particularly severe for WSL/Windows users (different execution contexts)
- Also impacts users with compliance requirements (security checks, validation gates)
- Skills system exists but is handicapped without enforcement capability
---
Request: Please prioritize this as it fundamentally undermines the reliability of Claude Code's automation features. Users are creating sophisticated guardrail systems that get completely bypassed after context resets, forcing them into a babysitting role that automation should eliminate.
What Should Happen?
- Create skill: pre-command-check marked as mandatory for Bash
- Create rule: "All Bash commands in WSL must check for Windows executables"
- Use successfully for 5-10 commands
- Trigger context reset
- First Bash command after reset should invoke pre-command-check automatically
- Current result: FAIL - skill not invoked
- Expected result: PASS - skill runs, validates command, proceeds/blocks appropriately
Error Messages/Logs
no errors, just "oops, I forgot about this rule" until I tell it.
Steps to Reproduce
- Create a mandatory skill (e.g., pre-command-check) that must run before specific tool invocations
- Document this as an ABSOLUTE RULE in global memory (~/.claude/CLAUDE.md or global knowledge files)
- Use it successfully in a session, establishing the pattern
- Trigger context reset (conversation length limit)
- Resume session from summary
- Observe: Claude executes tools without invoking the mandatory skill
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.0.55
Claude Code Version
2.0.55
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗