RPDI
Back to Blog

Why Claude Code Doesn't Know What Files You're Working On (And the Architectural Fix)

TL;DR

Claude Code ships with a 200,000-token context window — and still can't reliably track which files you're actively editing. The root cause isn't window size. It's architectural: Claude Code treats your project as a stateless retrieval problem, re-discovering your codebase from scratch on every turn. CLAUDE.md files and @file references are manual band-aids that break under real multi-file workflows. The permanent fix is deterministic context injection — a system that continuously tracks your exact IDE state and feeds it to Claude before every generation.

The 200K Window That Can't See Your Tabs

Claude Code is Anthropic's answer to Cursor and Copilot — a terminal-native AI coding assistant that can read files, run commands, and refactor entire modules. It ships with a 200,000-token context window. Some beta builds push to 1 million tokens.

And yet, 15 minutes into a real coding session, it forgets which files you're working on.

You're refactoring a payment module. You've been discussing payment.service.ts, stripe.config.ts, and payment.types.ts for the last 10 turns. You ask Claude to update the error handling. It generates code that imports from utils/errors.ts — a file that doesn't exist. It references PaymentError — a class you never defined. It has lost the thread.

The context window is large enough to hold your entire project. The problem is that Claude doesn't know which parts of your project matter right now.

This isn't a Claude-specific bug. It's the same architectural constraint that plagues every AI coding tool. But Claude Code's terminal-first design makes it worse — because it has no native integration with your editor's tab state, focus tracking, or file change events.

How Claude Code Actually Processes Your Project

Understanding Claude Code's architecture reveals why it loses file awareness. Unlike IDE-integrated tools like Cursor, Claude Code operates as a terminal process. It doesn't hook into VS Code's extension API. It doesn't watch your editor tabs. It interacts with your codebase through explicit file reads and command execution.

When you start a session, Claude Code performs three operations:

1. CLAUDE.md Ingestion: It reads any CLAUDE.md file in your project root and injects it as system-level context. This is your only persistent configuration — and it's static. It doesn't know what you're working on today.

2. On-Demand File Reads: Claude only reads files when you explicitly mention them or when it decides to explore your filesystem. There is no background daemon tracking your edits. If you modified types.ts 30 seconds ago but didn't mention it, Claude's internal representation is stale.

3. Automatic Compaction: As conversations grow, Claude's context management system summarizes older messages to free up tokens. Your detailed architectural discussion from 20 messages ago gets compressed into a one-line summary — losing the specific file paths, type names, and function signatures you established.

The result: Claude Code has a massive context window but fills it with conversation history and compressed summaries instead of your actual working state. It knows what you talked about, not what you're doing.

The Three Failure Modes of Claude Code Context Loss

After analyzing developer reports across GitHub Issues, Reddit, and production engineering teams, we've identified three distinct failure modes specific to Claude Code:

Analysis

01. Session Amnesia

Claude starts strong — correctly identifying all files in your feature. By turn 15, automatic compaction has summarized your early messages. Claude can no longer recall the exact type definitions you established in turn 3. It falls back on training data patterns, generating plausible but wrong code that references types and functions from popular open-source projects instead of your project.

Analysis

02. The @File Dependency Trap

Claude Code supports @file references to explicitly pull files into context. But this creates a manual dependency graph that you must maintain every single turn. Miss one @file reference and Claude loses that file entirely. Rename a file and every previous @reference is broken. The cognitive overhead of maintaining manual context defeats the purpose of an AI assistant.

Analysis

03. Cross-Session Wipe

Claude Code is fundamentally stateless between sessions. Close your terminal, and every piece of context — your architectural decisions, your file ownership graph, your naming conventions — is gone. CLAUDE.md persists, but it's a static document that can't capture the dynamic state of an active coding session. You start from zero every time.

A Real-World Claude Code Failure Trace

Here's a scenario we've replicated across multiple Claude Code sessions:

// Session start — Claude reads CLAUDE.md, has full awareness

Turn 1: "Read src/services/auth.service.ts and src/types/user.ts"

→ Claude reads both files, understands SessionUser type ✓

→ Correctly generates JWT validation using SessionUser ✓

// 12 turns later — discussing database queries...

Turn 13: "Update the auth middleware to check token expiration"

→ Claude generates code using AuthUser (doesn't exist) ⚠

// 20 turns later — compaction has kicked in

Turn 21: "Add rate limiting to the auth endpoint"

→ Imports from 'express-rate-limit' (not installed)

→ Uses req.session (you're using JWTs, not sessions)

→ Claude has forgotten the entire auth architecture ✗

By turn 21, Claude's automatic compaction has compressed the original file reads from turn 1 into a summary like "discussed auth service implementation." The specific type names, import paths, and architectural patterns have been evicted. Claude falls back on its training data, where express-rate-limit and req.session are statistically dominant patterns.

The developer now has to re-read the files, re-explain the architecture, and re-establish the context — burning another 10-15 minutes of flow state.

The Context Re-Education Tax

Every time Claude Code loses your file context, you enter a re-education cycle. You re-read the files. You re-explain the architecture. You re-correct the hallucinated imports. This cycle consumes tokens (making compaction happen faster) and shatters flow state (23 minutes to recover per interruption, per UC Irvine research).

We measured the cost across development teams using Claude Code as their primary AI assistant:

Metric$1,950MONTHLY CONTEXT RE-EDUCATION TAX PER DEVELOPER

Derived from an average of 26 hours/month lost to re-reading files into context, re-explaining architectural patterns, undoing hallucinated imports, and recovering from broken flow state. Includes: manual @file management (8.2 hrs), re-education cycles after compaction (9.1 hrs), hallucinated import debugging (5.4 hrs), and cross-session context rebuilding (3.3 hrs). For a 5-person team: $9,750/month or $117,000/year in invisible waste.

Why CLAUDE.md and @File References Don't Scale

Anthropic provides two official mechanisms for context management. Both fail under real-world multi-file coding:

CLAUDE.md: A static configuration file loaded at session start. It can define coding standards, architectural patterns, and project rules. But it's static. It doesn't know which feature you're working on today. It doesn't know you renamed UserService to AuthService yesterday. It doesn't track your open files. You'd need to manually update it before every session — and even then, it competes for the same context window budget as your actual conversation.

@file references: Manually tagging files with @src/types/user.ts forces Claude to read them. But this creates an unsustainable manual overhead. Every prompt requires you to remember which files are relevant. Miss one file and Claude hallucinates. Include too many and you waste tokens. The cognitive load of maintaining a manual context graph defeats the purpose of having an AI assistant.

Both mechanisms ask the developer to do the AI's job: decide what context is relevant. This is backwards. The AI should adapt to the developer's focus — not the other way around.

The /compact command is even worse — it's a controlled demolition of your context. You're deliberately destroying the conversation history that contains your architectural decisions, hoping that Claude's summary captures the important parts. It usually doesn't.

The Deterministic Fix: 5 Steps to Give Claude Permanent Memory

Stop managing context manually. Here's the engineering protocol that eliminates file awareness failures in Claude Code:

Step 01

Keep Sessions Under 15 Turns

Automatic compaction accelerates after ~20 turns. Break multi-file tasks into focused sessions: one session per module, one objective per session. Use /clear between logical task boundaries to reset the context window before compaction destroys your architectural context.

Step 02

Front-Load Your Architecture in Turn 1

Your first message in every session should explicitly read the 3-5 critical files for the current task. Don't rely on CLAUDE.md alone — it's too general. The first-turn reads enter the context at maximum priority and survive longest before compaction.

Step 03

Use Deterministic Context Injection

Tools like Context Snipe bypass Claude's manual @file system entirely. They continuously track your actual IDE state — which files are open, which has focus, what imports are resolved — and inject this as a structured, non-evictable context block before every generation. Claude receives ground truth, not a stale summary.

Step 04

Create an ARCHITECTURE.md for Active Context

Separate from CLAUDE.md (which handles style rules), maintain an ARCHITECTURE.md that documents your current feature's file ownership, type definitions, and dependency graph. Keep it under 100 lines. Re-inject it when starting sessions on that feature.

Step 05

Watch for Compaction Signals

The first sign of context loss: Claude uses a variable name you didn't define, or suggests an import path that doesn't match your project structure. The moment you see this, don't try to correct Claude in the same session — start fresh. Re-education messages consume tokens and accelerate the compaction spiral.

The Bottom Line: Context Is Infrastructure, Not Configuration

Claude Code is one of the most capable AI coding assistants available. Its ability to read files, execute commands, and reason about complex codebases is genuinely impressive. But capability without context is just sophisticated hallucination.

The developers who get the best results from Claude Code aren't the ones who write the best prompts. They're the ones who control exactly what Claude sees before it generates a single token.

CLAUDE.md and @file references are the equivalent of leaving Post-it notes on your monitor hoping your coworker reads them. Deterministic context injection is the equivalent of sitting them down, pointing at the screen, and saying 'this is what we're working on right now.' The difference in output quality is not incremental — it's categorical.

🔧 Give Claude Code the context it actually needs — automatically.

Context Snipe tracks your exact IDE state and injects deterministic file context into every AI session — so Claude stops guessing which files matter and starts reading the ones you're actually working on. See how it works →