You’ve given Claude Code a task, and now you’re wondering: what exactly does it have access to? Can it see your passwords? Your private keys? Every file on your computer? These are smart questions to ask before you start letting an AI tool poke around your project. The short answer is: Claude Code sees your project files, not your whole computer — and it has sensible defaults that keep sensitive files protected.
This is part of our complete How Claude Code Works — A Beginner’s Deep Dive.
TL;DR
- Claude Code can read and edit files inside your project directory
- It respects
.gitignore— files you’ve excluded from git are excluded from Claude Code too - Your
.envfile (where secrets live) is protected by default - You control what Claude Code can edit through permissions and explicit instructions
- Claude Code always asks before making changes to files — it doesn’t act silently
What Is a “Project Directory”?
A project directory (also called a project folder or working directory) is the root folder of your codebase — the top-level folder that contains all your project files. When you open Claude Code in your terminal, it operates from whichever directory you’re currently in.
Think of it like this: Claude Code can see everything inside the room you’ve put it in. It can’t walk out and explore the rest of your house. If you run Claude Code from your ~/projects/my-app folder, it can see everything inside my-app — but it can’t access files in your ~/Documents folder or anywhere else on your system.
# Example: running Claude Code from your project directory
cd ~/projects/my-app
claude
# Claude Code now operates within my-app/ only
What Files Claude Code Can See
Inside your project directory, Claude Code can read the following types of files by default:
# Files Claude Code can typically read
*.js, *.ts, *.jsx, *.tsx # JavaScript and TypeScript source files
*.py # Python files
*.rb # Ruby files
*.go # Go files
*.css, *.scss, *.sass # Stylesheets
*.html # HTML templates
*.json # Config files like package.json, tsconfig.json
*.yaml, *.yml # Config files like docker-compose.yml
*.md # Markdown files including README.md and CLAUDE.md
*.toml # Config files like Cargo.toml
*.env.example # Environment variable templates (not .env itself)
Basically: your source code, your configuration files, and your documentation. Everything a developer would need to understand and work on your project.
What Files Claude Code Cannot See (By Default)
Some files are protected by default — and for good reason.
Your .env file: This file contains secrets like API keys, database passwords, and authentication tokens. Claude Code does not read .env files by default. This is an important security protection.
# .env — Claude Code will not read this file
DATABASE_URL=postgresql://user:password@localhost/mydb
STRIPE_SECRET_KEY=sk_live_abc123
JWT_SECRET=my-super-secret-key
Files in your .gitignore: Whatever you’ve told git to ignore, Claude Code ignores too. This typically includes:
# Common .gitignore entries — all ignored by Claude Code
node_modules/ # Dependencies (huge, not your code)
.env # Secrets
dist/ # Build output
.DS_Store # Mac system files
*.log # Log files
coverage/ # Test coverage reports
Files outside your project directory: Claude Code cannot access files in other folders on your computer. Your personal documents, other projects, system files — all off limits.
⚠️ Warning: Even though
.envis protected by default, never paste your API keys or passwords directly into a prompt or code comment. Claude Code processes your prompts through Anthropic’s API — treat your prompts as you would any text you’d send over the internet.
What Files Claude Code Can Edit
By default, Claude Code can propose edits to any file it can read. However — and this is important — it always shows you the proposed change before applying it. It never silently edits files behind your back.
When Claude Code wants to edit a file, you’ll see a diff (a side-by-side comparison of old vs. new) and be asked to approve or reject the change. This is covered in detail at How to Accept or Reject Claude Code’s Changes.
You can also explicitly tell Claude Code what it can and can’t touch:
# Telling Claude Code to avoid specific files or directories
In your prompt: "Don't modify anything in the /src/lib/auth/ directory."
# Or in CLAUDE.md for permanent rules:
## Off-Limits Files
- Never modify src/lib/auth/ — this is a vendored library
- Never modify package-lock.json directly
- Don't touch .github/workflows/ without asking first
How to Check What Claude Code Is Reading
Claude Code is transparent about what it accesses. In the terminal, you’ll see it announce each file it opens:
# Claude Code terminal output showing file access
> Reading package.json
> Reading src/components/ProductList.tsx
> Reading src/api/products.js
> Reading src/utils/formatCurrency.js
If you see a file being read that seems odd or irrelevant, you can interrupt and ask Claude Code to explain why it’s looking at that file, or redirect it.
💡 Pro Tip: If Claude Code is reading too many files and seems to be “going broad,” make your prompt more specific. The more focused your request, the more focused its file access will be.
How to Control File Access More Precisely
Beyond the defaults, you have several tools to control what Claude Code can access:
1. Put rules in CLAUDE.md
The CLAUDE.md file in your project root is read at the start of every session. Add a section that tells Claude Code what’s off-limits:
# CLAUDE.md — file access rules section
## File Access Rules
- Read-only: src/lib/ (third-party code — don't modify)
- Off-limits: scripts/deploy/ (ask before touching anything here)
- Never modify: .github/workflows/ (CI/CD config — human review required)
2. State constraints in your prompt
For one-off restrictions, just say it in your message:
# Prompt with explicit file constraints
Refactor the pricing logic in src/utils/pricing.js.
Do not touch src/utils/tax.js — that file is being rewritten by someone else.
3. Use your .gitignore
If you want a whole category of files excluded, add them to .gitignore. Claude Code respects this automatically.
A Note on node_modules
New developers sometimes wonder why Claude Code never seems to look in node_modules/. That folder contains all your installed packages — thousands of files that aren’t your code.
Claude Code ignores node_modules/ by default (it’s in most .gitignore files). This is correct behavior. You want Claude Code working on your code, not wading through thousands of lines of library code that you didn’t write and shouldn’t be editing.
Common Mistakes and How to Fix Them
Mistake 1: Thinking Claude Code Can See Your Whole Computer
Problem: You ask Claude Code to “look at the wireframes in my Downloads folder” — it can’t.
Fix: Move relevant reference files into your project directory, or describe their contents in your prompt instead.
Mistake 2: Storing Secrets in Code Files
Problem: You hardcode an API key in a config file, thinking it’s safe because it’s not in .env.
Fix: .env protection only covers the .env file. Any secret hardcoded in a .js, .json, or other source file is readable by Claude Code and anyone who has access to your repo. Use environment variables properly.
Mistake 3: Not Knowing What’s in .gitignore
Problem: You ask Claude Code about a file and it says it can’t find it — because the file is gitignored.
Fix: Check your .gitignore. If a file you need Claude Code to read is excluded, either remove it from .gitignore (if that’s safe) or paste the relevant content directly into your prompt.
Mistake 4: Letting Claude Code Edit Files You Didn’t Intend
Problem: You ask for a refactor and Claude Code changes more files than you expected.
Fix: Always review the full list of changed files in the diff before accepting. If Claude Code touched something it shouldn’t have, reject that specific change.
Key Takeaways
- Claude Code sees files inside your project directory — not your whole computer
.envfiles and.gitignoreentries are protected by default- Claude Code always shows proposed edits before applying them — no silent changes
- You can add explicit file rules to
CLAUDE.mdor your prompts - Checking what Claude Code is reading in real time helps you catch misunderstandings early
Next Steps
- How Claude Code Reads Your Codebase — understand the full process of how Claude Code navigates your project
- How to Accept or Reject Claude Code’s Changes — review and control every edit Claude Code makes
- CLAUDE.md — The Complete Beginner’s Guide — set permanent rules for file access and behavior
Return to How Claude Code Works — A Beginner’s Deep Dive for the full picture.