Claude Code /add-dir: The Monorepo Command You Miss
What is /add-dir
When using Claude Code, you might run into situations like these:
- You’re working in Project A but need to reference code from Project B
- You started Claude Code in a monorepo sub-package but need to check another sub-package’s implementation
- You want Claude Code to understand both your frontend and backend repos to help with integration
By default, Claude Code can only see files under your current working directory. Whichever directory you launch it from, that’s all it knows.
This is where the /add-dir command comes in.
/add-dir is a Claude Code slash command that lets you add extra directories to Claude Code’s workspace during a conversation, allowing it to read and operate on files in those directories.
In short: break down directory walls and let Claude Code see more code.
Two Ways to Use It
/add-dir comes in two flavors: add directories on the fly during a conversation, or specify them upfront at launch.
Option 1: Add in Interactive Mode (/add-dir)
In Claude Code’s interactive mode, type:
/add-dir /path/to/another/project
Once executed, Claude Code gains access to all files in that directory. You can ask it to read, search, and even edit code there.
Each /add-dir call adds one directory. To add multiple, run it multiple times:
/add-dir /path/to/frontend
/add-dir /path/to/backend
/add-dir /path/to/shared-libs
Option 2: Specify at Launch (—add-dir)
If you already know which extra directories you’ll need before starting Claude Code, use the --add-dir flag to specify them all at once:
claude --add-dir ../apps ../lib
Note the difference from interactive mode — --add-dir lets you specify multiple directories at once, separated by spaces. Each path is validated to ensure it exists and is a directory.
This approach works great when you have a fixed set of projects you always work with together.
Using Relative Paths
Both methods support relative paths:
# Interactive mode
/add-dir ../another-project
# At launch
claude --add-dir ../apps ../../shared/components
Paths are resolved relative to the current working directory.
When You Need It
Scenario 1: Cross-Package Work in a Monorepo
This is the most common scenario. Say you have a monorepo structured like this:
my-monorepo/
├── packages/
│ ├── frontend/
│ ├── backend/
│ └── shared/
You started Claude Code in packages/frontend/. Now you want it to check a utility function in the shared package and use it in the frontend project.
/add-dir ../shared
Now Claude Code can see both the frontend and shared package code, helping you write correct import paths and function calls.
Scenario 2: Frontend-Backend Integration
You’re working in a frontend project but need to know the backend API’s request and response formats:
/add-dir /Users/me/projects/my-backend
Now you can ask Claude Code: “What format does the /api/users endpoint return? Generate a matching TypeScript type definition.”
It will find the API definition in the backend directory, then generate the type file in your frontend project.
Scenario 3: Referencing Open Source Projects
Want to reference how an open source project implements something? Add it in:
/add-dir ~/projects/reference-project
Then you can say: “Look at how this project implements routing, and let’s follow the same approach in ours.”
Scenario 4: Shared Configs and Documentation
Many teams keep shared configs, design specs, and API docs in separate repos:
/add-dir ~/team/design-system
/add-dir ~/team/api-docs
Once added, Claude Code can write code based on these specs, ensuring consistency.
Practical Tips
Tip 1: Only Add What You Need
Don’t add your entire disk. The more directories you add, the larger the search scope for Claude Code, which can affect efficiency. Only add directories that your current task actually needs.
Tip 2: Be Specific About Sources
When working with multiple directories, specify which project you’re referring to:
Look at the formatDate function in the shared package, then call it in the frontend project
Instead of vaguely saying “check formatDate” — there might be identically named files or functions across directories, and being specific avoids confusion.
Tip 3: Monorepo Best Practices
If you frequently work in a monorepo, the best approach is to start Claude Code from the monorepo root rather than inside a sub-package. This way Claude Code naturally sees all sub-packages without extra /add-dir calls.
But if your monorepo is massive — dozens or hundreds of packages — launching from the root might be too noisy. In that case, starting in a sub-package and selectively /add-dir-ing other packages is more efficient.
Tip 4: Create Aliases with —add-dir
If you switch between the same set of projects every day, create a shell alias:
alias claude-fullstack="claude --add-dir ../backend ../shared"
Now just type claude-fullstack in your frontend directory, and it automatically includes the backend and shared libs. Much easier than manually /add-dir-ing every time.
Tip 5: Pair with CLAUDE.md
If you frequently need to add a specific external directory, mention its purpose and path in your CLAUDE.md. While CLAUDE.md can’t automatically add directories, it helps Claude Code better understand what the added directories are for.
/add-dir vs —add-dir vs Launching from Root
| /add-dir (Interactive) | —add-dir (CLI Flag) | Launch from Root | |
|---|---|---|---|
| Timing | Add anytime during conversation | Specify all at launch | No extra action needed |
| Multiple dirs | One at a time, run multiple times | Specify multiple at once | Naturally includes all subdirs |
| Flexibility | Highest, add on demand | Medium, requires planning | Fixed workspace |
| Best for | Ad-hoc cross-project needs | Fixed multi-project setups | Small to medium monorepos |
My recommendations:
- Small to medium monorepos → Launch from root, keep it simple
- Large monorepos → Launch in a sub-package, use
claude --add-dirfor the packages you need - Cross-repo work → Launch in the main repo,
/add-dirother repos as needed - Fixed project combos → Create a shell alias with
--add-dir, one command and done
Final Thoughts
/add-dir is an unassuming command that can be a lifesaver when you need it. The problem it solves is straightforward: freeing Claude Code’s vision from a single directory.
Real-world development rarely stays in one directory. Frontend-backend separation, monorepo multi-package setups, shared library dependencies — in these scenarios, Claude Code seeing only one directory is far from enough.
Next time you find yourself thinking “if only Claude Code could see that other project,” give /add-dir a try. Open another window for it.
More Articles
- I Built a Bot That Runs Claude Code From Chat
- Claude Code /fast: Same Opus, 2x Speed — Worth It?
- Claude Code /init: Generate CLAUDE.md in 10 Seconds
- Claude Code MCP: Give Your AI Access to Any Tool
- Claude Code /model: Opus vs Sonnet vs Haiku Guide
- Claude Code in 2026: The Only Setup Guide You Need
- The Complete Guide to Claude: From Chat to Code to Automation
- CCBot - 24x Development Efficiency Boost
- Shocking! This Tool Lets Programmers Finish 95 Minutes of Work in 4 Minutes! 24x Efficiency Boost
- Claude Code /compact: Free Up Context, Keep Progress
- Claude Code /btw Command Explained: Quick Side Questions Without Breaking Flow
- Claude Code /stats: See How Much AI Does For You
- Claude Code /status Command Explained: Your Session Dashboard
- Why AI-First Startups Only Need One Programming Language
- Best Practice for External Knowledge in Claude Code: GitHub MCP + Context7
- Claude Code Token-Saving Tip: The Power of the Exclamation Mark
- Claude Code /resume Command Explained: Don't Let Your Conversations Go to Waste
- Claude Code /usage Command Explained: Know Your Remaining Quota
- Claude Code /tasks Command Explained: Master Your Background Tasks
- Claude Code Skills Explained: Build Your Custom Command Library
- Claude Code /plan Explained: Think Before You Code
- Claude Code /memory Explained: Make AI Truly Remember Your Project
- cc-ping: Ping All Your Claude Code Configs in One Command