claude-code·Published 2026.06.01
Claude Code /add-dir: Work With Files Outside Your Project Folder
A beginner-friendly walkthrough of the /add-dir command, which lets you handle a shared library or another module outside your working folder within one se
When you start Claude Code, you usually end up working within one folder. But there are times you think, "I also need to look at the shared code in the folder next door." For that, /add-dir is the command that slots in one more folder.
Definition (what it is)
/add-dir is the command that adds another folder to read and write in the currently open session (one unit of work in which Claude Code is running).
By default, Claude Code can only see the folder it was launched in (the working folder) and its subfolders. So it can't touch files outside the working folder. Add a folder with /add-dir and that folder comes into the working scope too, so Claude can read and modify it.
How to use it (by difficulty)
Basic — Adding one folder
/add-dir ../shared-lib
../shared-lib means "go up one level from the current folder (..) and the shared-lib folder." Here .. is path notation pointing to the parent folder. Type this and Claude can access the shared library folder.
Intermediate — Several folders at once
/add-dir ../apps ../lib
List folder paths side by side separated by spaces and you can add several folders at once. It's handy when you need to look at an app folder and a library folder together.
On Windows you can also use an absolute path (the full address starting from the drive). For example, something like C:\projects\shared-lib. On Mac or Linux you use ~ (the home folder, which on Windows would be C:\Users\yourname) like ~/projects/shared-lib.
Common pitfalls
- Get the path wrong and it can't find the folder. Before typing the command, check where that folder actually is. Copying the folder path from the Windows Explorer address bar reduces mistakes.
- An added folder is only kept for the current session. Restart Claude Code and you have to add it again.
Real-world example
While working in your main app folder, situations often come up where you also need to fix the shared library code that app uses. In that case, instead of shutting down Claude Code and reopening it in the library folder, just add the library folder with /add-dir and you can go back and forth between the two folders in one session.
Taking it further
Being able to add several folders means you can handle work spanning multiple modules in one session. In a project where the frontend and backend folders are separate, add both folders and you can run tasks like "how does the backend receive the data the frontend sends" without interruption.
Summary
/add-dir is the command that adds a folder outside your working folder to the current session's scope. Use it when handling code that doesn't fit in one folder, like a shared library or another module.
Based on: Claude Code v2.1.154 (2026.05)
Comments
Comments 0
Checking sign-in status…
Loading comments…