By default Claude Code works within the directory you start it in. Sometimes the code you care about lives in more than one place. The --add-dir flag lets you widen that scope.
The problem it solves
Imagine you are working in one repo but need Claude to read a shared library that sits in a sibling folder. Without extra access, Claude cannot see it. With --add-dir, you point at that folder and it becomes part of the working set.
claude --add-dir ../shared-lib
Now Claude can read and reason about files in both your current project and the extra directory you named.
Adding more than one
You can bring in several folders at once. This is handy when a change spans a few related projects, such as a frontend, a backend, and a shared package.
claude --add-dir ../api --add-dir ../design-system
Doing it mid-session
If you are already inside an interactive session and realize you need another folder, you do not have to restart. The /add-dir <path> command adds one on the fly:
/add-dir ../shared-lib
When to reach for it
Use --add-dir whenever the task crosses directory lines: comparing two projects, moving code between them, or letting Claude reference a library it would otherwise never see. Keep the extra directories to what the task actually needs. The more focused the working set, the more focused Claude's attention stays on the files that matter.
Comments
Be the first to comment.