Detailed Analysis
A user working in a Windows Subsystem for Linux (WSL) development environment has identified and documented a significant bug in Claude Code, Anthropic's agentic coding tool, wherein line-ending discrepancies between Windows (CRLF) and Unix/Linux (LF) formats trigger runaway token consumption and session degradation. The issue arises when Claude Code executes `git diff` against a repository that has mixed or inconsistent line-ending configurations — a common condition in shared codebases used across both Windows and Linux environments. Rather than filtering or truncating whitespace-only changes, Claude Code ingests the entire diff output into its context window, treating pure formatting noise as substantive content. In the case documented, approximately 84% of the context window was consumed within roughly one minute, driven by a single `git diff` operation across 69 files exhibiting CRLF-to-LF churn.
The second and arguably more damaging consequence is what the reporter terms "context pollution." Once the inflated diff output populates the context window, Claude Code persistently references it in all subsequent interactions within the same session — including trivial informational requests that have no legitimate need to reference file diffs at all. This effectively renders the session unusable without manual intervention, as the context cannot be selectively cleared. The reporter confirmed this behavior by prompting Claude Code to analyze its own token usage, demonstrating a degree of self-diagnostic capability in the tool while simultaneously highlighting the absence of internal safeguards that would have prevented the context saturation in the first place.
The practical workaround identified involves adding a `.gitattributes` file to the repository root with the directive `* text=auto`, followed by running `git add --renormalize .` to force Git to normalize all line endings. This eliminates the phantom modifications that Git was surfacing and removes the trigger for Claude Code's problematic diff ingestion behavior. While effective, this solution places the remediation burden entirely on the user and requires knowledge of Git's line-ending normalization mechanisms — a reasonable expectation for experienced developers but a potentially opaque fix for others. The reporter explicitly frames this as a tool-side failure requiring Anthropic to implement diff truncation logic for whitespace-only changes, rather than a user misconfiguration.
This bug sits at the intersection of two well-understood but persistently difficult problems in software development: cross-platform line-ending compatibility and context window management in large language model (LLM)-powered development tools. The CRLF/LF mismatch issue has plagued mixed Windows/Linux development workflows for decades, and the growing adoption of WSL has made hybrid environments increasingly common rather than exceptional. For agentic coding tools like Claude Code, which rely on Git integration and repository-state awareness as core functionality, the failure to filter semantically meaningless diffs represents a meaningful gap in robustness. Other AI coding assistants face analogous challenges, but the severity here is amplified by Claude Code's apparent lack of size-aware diff ingestion or whitespace-change filtering at the tool level.
The broader implication for Anthropic concerns the reliability expectations of agentic AI tools operating in real-world, messy development environments. Unlike chat-based interactions where context is largely user-controlled, agentic tools autonomously execute operations — like `git diff` — that can produce unbounded output. Without guardrails such as output truncation, whitespace-diff detection, or context budget alerts, the tool can degrade from a productivity asset to a session-breaking liability within minutes of normal use. The reporter's frustration with support responses framing the issue as user behavior rather than tool malfunction points to a gap in how Anthropic is categorizing and triaging environment-dependent bugs, a challenge that will only grow as Claude Code expands across more diverse development configurations.
Read original article →