Include Project File Tree in CLAUDE.md
Including your project's file tree in your CLAUDE.md
file helps Claude Code navigate files faster and understand your codebase structure at a glance.
Why This Helpsβ
- Faster Navigation: Claude can quickly understand your project structure without searching
- Better Context: Reduces the back-and-forth needed to clarify file locations
- Improved Code Suggestions: Claude provides more accurate, context-aware suggestions
- Large Codebase Support: Essential for projects with 100+ files where Claude might get lost
How to Generate File Treeβ
Basic Commandβ
tree .
Exclude Specific Foldersβ
Use the -I
argument to exclude folders like node_modules
, dist
, .git
, etc.:
tree . -I "node_modules|dist|.git|build|coverage"
Example CLAUDE.md Structureβ
# Project Overview
Brief description of your project.
## File Structure
```
your-project/
βββ src/
β βββ components/
β β βββ Header.tsx
β β βββ Footer.tsx
β βββ pages/
β β βββ Home.tsx
β β βββ About.tsx
β βββ utils/
β βββ helpers.ts
βββ tests/
β βββ components/
βββ package.json
βββ README.md
```
## Key Components
- `src/components/` - Reusable UI components
- `src/pages/` - Application pages
- `src/utils/` - Helper functions and utilities
Best Practicesβ
- Keep It Updated: Update the tree when you add/remove significant files or folders
- Be Selective: Use exclusion patterns to avoid cluttering with temporary or generated files
- Add Context: Include brief descriptions of what each major directory contains
- Consider Size: For very large projects (12,000+ files), consider showing only top-level structure or key directories
Token Considerationsβ
For large projects, be mindful of token usage. You can:
- Show only directory structure without individual files
- Focus on the most important parts of your codebase
- Use abbreviated trees for different sections
π‘ Pro tip: Even an outdated tree is better than no tree at all. Claude can still use it as a general guide to your project structure.
Sourceβ
This tip comes from the Reddit community discussion: Quick tip for Claude Code: include your project's file tree in CLAUDE.md