References with @
How @ mentions attach files, folders, selections, and other context to Claude Code prompts across VS Code, Desktop, and MCP.
@ references pull concrete context into a prompt so Claude does not have to guess which file you mean. You can point at files, folders, editor selections, terminals, MCP resources, and (in project memory) imports inside CLAUDE.md. The same @ syntax is used for @AGENTS.md-style imports in project memory and for attachments in ordinary prompts.
Interface details vary by surface; the patterns below are summarized from VS Code, Desktop, and MCP.
Files and folders
In a rich prompt (VS Code extension, Desktop, and similar), type @ then start
typing a path or name. File references include the file contents. Directory
references initially provide a file listing, after which Claude can read the
individual files it needs.
- Fuzzy matching: partial names work (for example
@authcan matchauth.js,AuthService.ts, etc.). - Folders: use a trailing slash to make it clear you mean a directory, for example
@src/components/. - Drag and drop: many UIs let you drop a file into the prompt as an attachment instead of typing the path.
On Desktop, @ file mentions are
unavailable in cloud and WSL sessions. Ordinary file attachments are a
separate feature.
Example prompts
Attach the file or folder with @ (or drag it in), then send something like:
@src/auth/login.ts
Trace every branch in this handler. Where could a user skip or weaken MFA, and what is the smallest fix you would try first? Use file:line references where you can.@src/components/
We are about to add another modal. Summarize how existing modals handle focus, Escape, and aria attributes. No edits, report only.Selections and line ranges (VS Code)
When text is selected in the editor, Claude can often see the highlight without an explicit mention. The prompt footer usually shows how many lines are selected.
To insert a structured reference (file plus line span), use Option+K (macOS) or Alt+K (Windows/Linux) so the prompt gets something like @app.ts#5-10. You can also toggle whether the live selection is visible to Claude (eye / eye-slash in the UI).
Terminal output (VS Code)
Reference a terminal’s output without copy-paste:
@terminal:nameUse the terminal panel title for name so Claude can read logs, errors, or command output from that session.
The build failed. Diagnose from the log, root cause first, then the minimal fix. Do not rerun the command unless you need to confirm.
@terminal:npmCLAUDE.md and slash-command imports
Project memory uses @ to import other files into instructions (see How Claude remembers your project). For a minimal CLAUDE.md that starts with @AGENTS.md, see The /init command.
Custom slash commands can embed @paths in their Markdown body so each run pulls named files into the command’s prompt (same @file convention).
MCP resources
Connected MCP servers can expose resources you pick from the @ menu alongside files. Format is roughly:
@server:protocol://resource/pathExamples appear in the MCP documentation. Autocomplete lists fuzzy-searchable resource paths when @ is opened.
Habits that keep references safe
- Prefer explicit paths for anything security-sensitive; fuzzy pickers can grab the wrong twin file if names collide.
- Do not
@-pull secrets into chat on purpose. Keep.envout of prompts; use explicitRead(...)denies plus sandbox filesystem or credential protections. Claude Code does not recognize a.claudeignorefile; see Secret-file protections. - Large files: for huge assets (PDFs, dumps), check product docs for page ranges or chunking so you do not blow the context budget accidentally.