Skip to content

File References

Reference files and directories to give Claude specific context. Use @filename or @dir/ to bring specific parts of your codebase into the conversation.

Referencing Files

Single File

bash
@src/auth.js
Can you explain what this authentication module does?

Multiple Files

bash
@src/auth.js @src/middleware/auth.js @tests/auth.test.js
Review these authentication files for security issues

Directories

bash
@src/components/
Refactor these React components to use hooks

With Wildcards

bash
@src/**/*.test.js
Run all test files and fix any failures

What Claude Actually Reads

When you reference a single file (@src/auth.js), Claude reads the entire file into context. When you reference a directory (@src/components/), Claude loads the file listing but doesn't read file contents until you ask or Claude opens specific files. This means directory references are fast for scoping but don't include code until needed — Claude will ask for or fetch specific files as the conversation proceeds.

Common Patterns

Code review: @src/payment.js + description of concern
Debugging: @logs/error.log @src/api/endpoint.js + description of the error
Refactoring: @src/utils/ + refactoring goal
Documenting: @src/api/ @README.md + what needs updating

Tips

Use @ followed by Tab to autocomplete paths. Reference only the files you need to avoid clutter. Combine with commands like /compact to focus context: /compact focus on dependencies @package.json.

Built with VitePress and powered by Claude Code