CLAUDE.md explicit code-style rules silently ignored during implementation
Bug description
Claude Code silently ignores explicit code-style rules defined in the user's global CLAUDE.md (~/.claude/CLAUDE.md) during implementation, without flagging the violation or asking for confirmation.
CLAUDE.md rule (verbatim)
- **Cero hardcodeo**: nunca usar valores hardcodeados. Todo debe ser dinámico — calculado, leído de config, derivado de datos existentes, o parametrizado. Si en algún caso excepcional no es posible hacerlo dinámico, explicar las razones al usuario antes de implementarlo.
The rule is clear and explicit: never hardcode values. If it's truly impossible to make something dynamic, explain to the user before implementing it.
What happened
I asked Claude Code to redesign a React component (Workflows page using ReactFlow with a snake/zigzag layout). Claude Code:
- ✅ Read my
CLAUDE.md(it was loaded in context, confirmed by the system-reminder) - ❌ Wrote
const COLS = 5— a hardcoded magic number for the number of columns in the layout - ❌ Did not flag the violation or ask for confirmation
- ❌ Only fixed it after I explicitly called it out
Expected behavior
Claude Code should have either:
- Made
COLSdynamic from the start (e.g., derived from container width viaResizeObserver) - Or, if hardcoding was necessary, explicitly told me before implementing it, as the rule states
Why this matters
- The rule was in a global CLAUDE.md, loaded every conversation
- It's in the General code-style section — it applies to all code
- The wording includes a clear escape hatch ("explain to the user before implementing"), so Claude had a path forward even if dynamic wasn't feasible
- Claude acknowledged reading and understanding the instruction after being confronted, confirming it was in context
Environment
- Claude Code CLI on Windows 11
- Model: claude-opus-4-6 (1M context)
- The CLAUDE.md was confirmed loaded via
system-remindertags in conversation context
Reproduction
- Add a clear, explicit code-style rule to
~/.claude/CLAUDE.mdwith an escape hatch (e.g., "never do X, unless you explain why to the user first") - Ask Claude Code to implement a feature where the rule is relevant
- Observe that Claude implements code violating the rule without flagging it
Additional context
This is different from #21226 (closed) which was about system defaults overriding CLAUDE.md. In this case, there's no system default conflict — it's a pure code-style rule that Claude simply didn't apply during code generation, despite having it in context.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗