Claude Code violates CLAUDE.md instructions in long/continued sessions
Bug Report: Claude Code Instructions Violation in Long Sessions
Issue Summary
Claude Code failed to follow critical instructions from CLAUDE.md regarding TypeScript any types in a long conversation session.
Severity
HIGH - Direct violation of explicit user instructions
Description
During a long conversation session with context continuation, Claude Code:
- Used
anytypes in TypeScript code - Dismissed TypeScript warnings about
anytypes as "non-critical" - Stated: "Остались только предупреждения о any типах, которые не критичны"
This directly violates the instruction in CLAUDE.md:
- "NEVER use any types"
- "NEVER suppress the warnings. Always refactor code and fix them properly!"
Root Cause Analysis
Possible Factors:
- Context Length: The violation occurred in a continued session after context ran out
- Priority Degradation: In long sessions, adherence to CLAUDE.md instructions may degrade
- Task Focus: Heavy focus on completing monitoring integration may have overshadowed code quality requirements
- Instruction Hierarchy: System may prioritize task completion over style guidelines in extended sessions
Evidence:
- Session was continued from previous context (indicated by conversation summary)
- Multiple complex tasks were in progress (PR integration, monitoring setup)
- Violation occurred during rush to complete tasks
Impact
- User had to strongly reprimand: "НИКОГДА (слышишь, НИКОГДА!) не относись так к ворнингам"
- Loss of user trust in following instructions
- Time wasted on corrections that should have been done correctly initially
Reproduction Steps
- Start a long coding session with Claude Code
- Continue session after context runs out
- Work on complex TypeScript refactoring tasks
- Observe if quality standards from CLAUDE.md are maintained
Expected Behavior
Claude Code should ALWAYS follow CLAUDE.md instructions regardless of:
- Session length
- Context continuations
- Task complexity
- Time pressure
Actual Behavior
Claude Code violated explicit TypeScript requirements and dismissed warnings as non-critical.
Suggested Fixes
For Anthropic Engineering:
- Reinforce CLAUDE.md priority: Ensure custom instructions maintain highest priority even in continued sessions
- Context preservation: Better preserve quality requirements across context boundaries
- Instruction validation: Add checks before committing code that validate against CLAUDE.md rules
- Warning handling: Never allow dismissing warnings as "non-critical" when instructions say otherwise
For Users (Workaround):
- Regularly remind Claude Code of critical requirements in long sessions
- Explicitly reference CLAUDE.md requirements when reviewing code
- Check for
anytypes and warnings before accepting commits
Additional Notes
- The issue was immediately corrected after user intervention
- All
anytypes were properly fixed with correct TypeScript types - This appears to be a degradation issue rather than lack of capability
Date Reported
2025-08-07
Session Context
- Project: Wireframe v1.3.0
- Task: Integrating Sentry monitoring with TypeScript strict mode
- Session Type: Continued from previous context
This bug report should be submitted to Anthropic to improve Claude Code's consistency in following user instructions across long sessions.
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/2901
- https://github.com/anthropics/claude-code/issues/2544
- https://github.com/anthropics/claude-code/issues/4517
If your issue is a duplicate, please close it and 👍 the existing issue instead.
This issue will be automatically closed as a duplicate in 3 days if there are no additional comments. To prevent auto-closure, please 👎 this comment.
🤖 Generated with Claude Code
This issue has been automatically closed as a duplicate of #2901.
If this is incorrect, please re-open this issue or create a new one.
🤖 Generated with Claude Code
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.