Claude defaults to training data patterns instead of following CLAUDE.md project guidelines
Claude Code sometimes ignores explicit project documentation (CLAUDE.md) in favor of more prevalent patterns from training data, particularly when projects use modern or emerging web standards that differ from older, more common approaches.
Specific Example
Project requirement (CLAUDE.md): Use modern CSS nesting with explicit & syntax
.block {
& .child { }
&:hover { }
}
What Claude generated: Sass-style BEM syntax (&--expanded) which is invalid in modern CSS nesting
.block {
&--expanded { } // Invalid - this is Sass syntax, not modern CSS
}
Root cause: Claude pattern-matched to Sass/SCSS examples (more prevalent in training data) instead of following the documented modern CSS nesting requirements.
Impact
- Build failures: Generated code violates project standards and breaks builds
- Inconsistent output: AI doesn't reliably follow project-specific guidelines
- Developer friction: Requires manual correction of generated code
- Broader implications: Affects any project using modern standards that differ from older, more common patterns
Why This Matters
This isn't about "non-standard" conventions - it's about Claude prioritising older, more prevalent patterns over:
- Modern web standards (CSS nesting, ES6+, etc.)
- Emerging best practices
- Project-specific architectural decisions
- Explicit documentation requirements
Suggested Improvements
- Prioritise project documentation: CLAUDE.md rules should override training data patterns
- Modern standard recognition: Better recognition of newer standards vs. legacy patterns
- Explicit compliance checking: Validate generated code against documented project requirements
- Context awareness: Consider that projects may intentionally use newer standards
Examples of Where This Could Occur
- Modern CSS features vs. preprocessor syntax
- ES6+ JavaScript vs. older patterns
- New framework conventions vs. legacy approaches
- Modern architectural patterns vs. traditional structures
Expected Behaviour
When CLAUDE.md explicitly documents syntax requirements, Claude should strictly follow those requirements regardless of what's more common in general web development training data.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗