Claude Code ignores .clang-format and formatting memory across conversations

Resolved 💬 4 comments Opened Mar 30, 2026 by jkj Closed May 3, 2026

Bug

Claude Code repeatedly ignores .clang-format configuration and user formatting preferences stored in persistent memory, despite being corrected multiple times across conversations.

Specific violations

  • Cramming multiple statements onto one line (e.g. if (x) { runtime_error("..."); return; })
  • Not placing return types on their own line
  • Not following K&R brace style
  • Ignoring column limits

Context

  • The user has a .clang-format file in the repository root
  • The user has a persistent memory entry (feedback_code_formatting.md) that explicitly states: "MUST follow .clang-format: return type on own line, 2-space indent, 150 col limit, K&R braces"
  • The user has corrected this behavior multiple times across separate conversations
  • Claude acknowledges the rules each time, then ignores them again in the very next code generation

Expected behavior

When writing or editing C/C++ code, Claude Code should:

  1. Read and respect the project's .clang-format file
  2. Respect formatting preferences stored in memory/CLAUDE.md
  3. Actually apply these rules consistently, not just acknowledge them

Impact

Every code generation session requires a manual reformatting pass (e.g. via IDE tooling), which defeats the purpose of AI-assisted coding. This is a recurring source of friction.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗