---
title: "Why AI agents re-read the same files, and how to stop it · Cork"
description: "Why Claude Code, Codex and Cursor agents keep re-reading the same files, and how to stop it: specific prompts, lean context, symbol lookups and briefings."
canonical: "https://corkcli.com/blog/why-ai-agents-reread-same-files"
last_updated: "2026-10-03"
published: "2026-10-03"
author: "Kevin Vera"
---

# Why AI agents re-read the same files, and how to stop it

Why Claude Code, Codex and Cursor agents keep re-reading the same files, and how to stop it: specific prompts, lean context, symbol lookups and briefings.

By Kevin Vera · October 3, 2026 · [Guides](https://corkcli.com/blog/c/guides) · 5 min read

AI coding agents re-read the same files because they have no memory outside their context window: a new session, a `/clear`, a compaction, a subagent or a second agent all start without the file contents the last one saw, and even within one session an agent rereads a file after an edit to be sure of its current state. To stop it, give agents the facts they would read files to learn (signatures, callers, structure) before they ask, keep prompts specific, use symbol lookups instead of whole-file reads, and share what one agent learned with the next instead of letting each rediscover it.

## Why it happens

**Fresh context per session.** Claude Code's docs say it plainly: each session begins with a fresh context window. Only instruction files and memory carry over. Everything the agent learned by reading code last session is gone.

**Compaction drops details.** When a long conversation is summarized to free space, specific file contents are among the first things to go. Anthropic's hooks guide notes that compaction "can lose important details", which is why it offers a `SessionStart` hook with a `compact` matcher to re-inject context afterward.

**Subagents and parallel agents start empty.** A subagent runs in its own context window and returns only a summary. A second Claude Code, Codex or Cursor session on the same repo has no access to the first one's reads at all. Two agents working on the billing module will each read the billing module.

**Verification after edits.** Agents reread files after they or something else may have changed them. That is often correct behavior: an agent that writes from a stale copy can overwrite someone else's change.

**Search is file-shaped.** To answer "what calls `charge()`?", an agent typically greps, gets a list of matches, and opens several files to read the surrounding code. The question was about one symbol; the cost is several files.

## How to tell if it is costing you

In Claude Code, `/usage` attributes plan usage and flags behaviors such as long context, and `/context` shows what fills the window. If most of your context is tool results from `Read` and `Grep` on the same handful of files across sessions, rereading is your problem.

## Fixes inside one session

- **Be specific.** Anthropic's cost guide contrasts "improve this codebase" (broad scanning) with "add input validation to the login function in auth.ts" (minimal reads). Name the file and the function.
- **Avoid needless resets.** `/clear` is right between unrelated tasks; between steps of one task, it forces a reread.
- **Re-inject after compaction.** A `SessionStart` hook with matcher `compact` can print the module map or the key signatures you always need.
- **Use code intelligence.** Claude Code's code intelligence plugins provide "go to definition", which the docs describe as replacing a grep followed by reading multiple candidate files.

## Fixes across sessions

- **Write the map down once.** A short architecture section in `AGENTS.md` or `CLAUDE.md` (key directories, entry points, naming conventions) stops each session from mapping the repo again. Keep it under the recommended 200 lines.
- **Use a skill for deep context.** A "codebase-overview" skill, as Anthropic's docs suggest, loads only when relevant and saves exploration.
- **Use auto memory.** Claude Code keeps per-repository notes it writes itself, shared across worktrees, loaded at session start.

## Fixes across agents

This is the hard part, because agents do not share context by default.

- **Have subagents return what they found, not just a verdict.** A summary like "`charge()` is in `billing/core.py:41`, called from `api/orders.py` and `jobs/retry.py`" saves the parent from reading those files.
- **Give agents a shared place to look facts up** instead of reading files: an index of symbols and callers that any agent can query, often through an MCP server.
- **Push facts to agents before they ask.** A hook at session start or on each prompt can hand the agent the signatures and callers of the code it is about to touch.

## When rereading is the right call

Do not eliminate rereads that protect correctness. If another agent or person may have changed a file since your agent last read it, the reread is what keeps your agent from writing over their work. The goal is to stop rereads for facts that have not changed, and to replace "reread just in case" with "be told when it changes".

## How Cork helps

Cork targets the cross-session and cross-agent rereads. Cork is the [coordination layer](https://corkcli.com/blog/coordination-layer-ai-coding-agents) for multiplayer coding agents: it keeps Claude Code, Codex and Cursor agents, on one machine or across a team's machines, from overwriting each other on one codebase, and hands each agent what the others already learned.

- **Briefing**: when an agent starts or gets a prompt, it is handed the exact signatures, callers and recent changes of the code it is about to touch, so it searches less.
- **Live awareness**: when another agent changes code yours depends on, your agent hears it on its next step, so it does not have to reread defensively.
- **MCP tools** `get_symbol` and `blast_radius` answer symbol-shaped questions without reading whole files.
- **remember and recall** keep durable notes anchored to code, available to every agent.

In Cork's published benchmark (12 Claude Code agents at once on one repository, hard tasks), agents with Cork used 53% fewer tokens than the same agents without it. Install:

```bash
curl -fsSL https://corkcli.com/install.sh | sh
```

## Frequently asked questions

### Why does Claude Code keep reading the same file?

Its context resets between sessions and after compaction, subagents start empty, and it rereads files after edits to confirm their state.

### Does Claude Code cache file contents between sessions?

No. Prompt caching reduces the cost of resending the same conversation within its lifetime, but a new session does not contain earlier file reads.

### How do I stop multiple agents from reading the same files?

Give them a shared source of facts: a written map in the instruction file, a symbol index they can query, or a briefing delivered at session start.

## Sources

- <https://code.claude.com/docs/en/memory>
- <https://code.claude.com/docs/en/costs>
- <https://code.claude.com/docs/en/hooks-guide>
- <https://code.claude.com/docs/en/sub-agents>
- <https://corkcli.com/benchmarks/study-5-twelve-agents-53-percent>

## Related reading

- [How to stop an agent editing a file someone else is changing](https://corkcli.com/blog/stop-agent-editing-file-someone-else-is-changing): Block an AI coding agent from editing a file another session is changing: a tested Claude Code PreToolUse lock hook, Cursor and Codex equivalents, and limits.
- [How to share context between Codex and Claude Code](https://corkcli.com/blog/share-context-codex-claude-code): Make Codex and Claude Code work from the same context: one AGENTS.md, shared MCP servers, handoff files, and live awareness when both edit the same repo.
- [Getting started with Cork's MCP tools: get_symbol, blast_radius, recap, remember](https://corkcli.com/blog/cork-mcp-tools-get-symbol-blast-radius-recap-remember): Use Cork's MCP tools in Claude Code, Codex and Cursor: get_symbol, blast_radius, recap, remember and recall, with when to call each and example prompts.
- [How to reduce token usage when running several coding agents at once](https://corkcli.com/blog/reduce-token-usage-multiple-coding-agents): Several Claude Code, Codex or Cursor agents at once multiply token spend. Cut it with lean shared context, cheaper models, less rediscovery and less rework.

[All articles](https://corkcli.com/blog.md) · [Cork in Markdown](https://corkcli.com/index.md) · [llms.txt](https://corkcli.com/llms.txt)

This page in HTML: https://corkcli.com/blog/why-ai-agents-reread-same-files
