skip to content

In Claude Code, what happens when a prompt says `@src/utils/auth.js` or `@src/components` instead of describing where the code lives?

level: juniorimportance: should knowfreq 21%

answer

  1. content arrives before Claude acts
  2. file versus directory
  3. listing, not contents
  4. nearby CLAUDE.md files come too
  5. Read rules, best-effort

basics

~20 s

An @ file mention puts the file's full content into the conversation with no Read call needed; a directory mention adds a file listing only, and a mention also loads CLAUDE.md files from that directory and its parents.

solid answer

~40 s

Typing `@` opens path autocomplete; `Tab` or `Enter` accepts a path, relative or absolute, and a message can mention several. When you send, a file mention includes the file's full content in the conversation, so Claude starts with the exact code instead of searching for it. A directory mention such as `@src/components` adds a file listing, not every file's contents. Mentioning a file also adds the `CLAUDE.md` files in its directory and parent directories. Claude Code makes a best-effort attempt to apply `Read` deny rules to mentions, and `CLAUDE_CODE_DISABLE_ATTACHMENTS=1` sends mentions as plain text. An `@path` import inside a `CLAUDE.md` is a different mechanism that runs at launch.

go deeper

for a junior

Recall that @ references a file or folder: a file arrives as full content, a folder as a listing, and you can mention several in one message.

for a middle

Explain the side effect: the mention also brings CLAUDE.md files from that directory and its parents, which is how a package's own instructions enter the session.

for a senior

Show judgement about context size and secrets: mention only what the task needs, and rely on Read deny rules, which apply to mentions on a best-effort basis, rather than on discipline.

for a principal

Decide how far a team should lean on explicit mentions versus letting Claude search, weighing deterministic context against window budget and the best-effort nature of rule enforcement on mentions.

## What an `@` mention is In the Claude Code prompt, typing `@` opens a **path suggestion menu**. You type part of a path, press `Tab` or `Enter` to accept the highlighted entry, and press `Enter` again to send. The result is a reference such as `@src/utils/auth.js` embedded in your sentence: ``` Explain the logic in @src/utils/auth.js What's the structure of @src/components? ``` Paths can be **relative or absolute**, and one message can carry **several** mentions ("compare @a.js and @b.js"). ## What it puts into the conversation The useful part is what happens at send time, before the model does anything: - **A file mention** includes the **full content of the file** in the conversation. Claude does not have to spend a turn deciding to call its Read tool and then reading; the content is already there with your question. - **A directory mention** shows a **file listing, not the contents** of every file. It tells Claude what exists so it can choose what to open next. - **Instruction files come along:** an `@` file reference also adds the `CLAUDE.md` files in that file's **directory and its parent directories** to context. Mentioning a file deep in a monorepo package can therefore bring that package's own instructions into the session. That is why the guidance is to reference files with `@` instead of describing where code lives: a description makes Claude search; a mention hands it the exact bytes. ## The limits worth knowing | Situation | What happens | | :- | :- | | A `Read` deny rule matches the mentioned file | Claude Code makes a **best-effort** attempt to apply `Read` rules to `@` mentions as well as to its tools | | `CLAUDE_CODE_DISABLE_ATTACHMENTS=1` is set | Mentions are sent as **plain text** instead of being expanded into file content | | A very large file | Its full content still enters the context window, so it competes with everything else in the session | | A directory | Only names arrive; Claude must still read the files it needs | The phrase "best-effort" matters for anyone locking a repository down: the permission rules, not the habit of not mentioning a file, are what keep secrets out, and how those rules are written is its own subject. ## Same symbol, different mechanisms The `@` sign does several jobs in Claude Code, and confusing them leads to wrong answers: 1. **`@path` in your prompt:** the file mention described here, expanded when you send the message. 2. **`@path` inside a `CLAUDE.md`:** an **import**, expanded at launch when the instruction file loads. That belongs to how instruction files are organised, not to the prompt line. 3. **`@server:resource`:** a resource exposed by a connected MCP server, offered in the same autocomplete menu. 4. **Agents and sessions:** the same menu can also offer subagents and, with cross-session messaging, your other live sessions. ## Using it well - Mention the **one or two files** the task is about, and let Claude find the rest; mentioning a dozen files front-loads context you may not need. - Mention a **directory** to orient Claude in an unfamiliar area, then ask it to read selectively. - When a mentioned file sits in a subdirectory with its own `CLAUDE.md`, expect those instructions to start shaping the answer, which is usually what you want.

  • Can a `Read` deny rule on `.env` stop someone pulling that file in with an `@` mention?
    The docs say Claude Code makes a best-effort attempt to apply `Read` rules to `@` file mentions, as it does for tools such as Grep and Glob. Treat it as best-effort coverage rather than a guarantee, and keep secrets out of the working tree where you can.

  • An @ directory mention pastes the contents of every file inside it.
  • An @ mention is only autocomplete; Claude still has to read the file afterwards.
  • Mentioning a deep file never changes which CLAUDE.md files are in context.
  • An @ mention in a prompt and an @path import in CLAUDE.md work the same way.
  • Permission rules play no part in what an @ mention can pull in.