Need Claude to access multiple repos or directories? The --add-dir flag extends your workspace beyond the current directoryβessential for monorepos, microservices, or any multi-directory workflow.
Run multiple autonomous coding agents simultaneously with Verdent's isolated Git worktrees. Each agent tackles different components while maintaining full context awareness, eliminating manual debugging bottlenecks and accelerating feature delivery. Discover Verdent AI (Free Trial)
What is --add-dirβ
Purpose - Extends Claude Code's workspace beyond your current working directory to include additional directories without changing your primary location.
- CLI argument:
--add-dirwhen starting Claude Code - Slash command:
/add-dirto expand workspace mid-session
How to Use --add-dir at Startupβ
Single Additional Directory - Add one extra directory when launching Claude Code:
claude --add-dir /path/to/other/project
Multiple Directories - Add several directories at once:
claude --add-dir ../backend --add-dir ../shared-utils --add-dir ~/company/configs
Combined with Other Options - Mix with model selection or other flags:
claude --model claude-sonnet-5 --add-dir ../backend-api
claude --add-dir ~/shared/libraries -p "Compare authentication patterns between current and shared directory"
Mid-Session Directory Additionβ
Slash Command Usage - Add directories without restarting your session:
/add-dir /path/to/other/project
/add-dir ../backend-api
/add-dir ~/shared/libraries
Dynamic Workflow Expansion - Start focused, expand as needed:
- Begin working on frontend project
- Realize you need backend API reference:
/add-dir ../backend-api - Need shared utilities:
/add-dir ~/company/shared-utils - Access documentation repo:
/add-dir ../project-docs
Common Use Casesβ
Multi-Repository Development - Work on interconnected projects:
# Frontend project needs backend API reference
claude --add-dir ../backend-api
# Microservices that share common code
claude --add-dir ../user-service --add-dir ../auth-service --add-dir ../shared-models
Shared Resources Access - Reference common configurations or libraries:
# Access company-wide shared configurations
claude --add-dir ~/company/shared-configs
# Reference template repositories
claude --add-dir ~/templates/react-components --add-dir ~/templates/api-patterns
Legacy Code Integration - Work with mixed old and new codebases:
# Modernizing project while referencing legacy system
claude --add-dir ../legacy-system --add-dir ../migration-scripts
Documentation and Examples - Include reference materials:
# Access documentation and example code
claude --add-dir ../project-docs --add-dir ../code-examples
CLAUDE.md Loading from Additional Directoriesβ
Starting in v2.1.20, Claude Code can load CLAUDE.md files from --add-dir directories. Enable this with:
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 claude --add-dir ../other-project
When enabled, Claude reads CLAUDE.md (and .claude/rules/) from each additional directory, applying project-specific instructions from all workspaces in your session.
Run multiple autonomous coding agents simultaneously with Verdent's isolated Git worktrees. Each agent tackles different components while maintaining full context awareness, eliminating manual debugging bottlenecks and accelerating feature delivery. Discover Verdent AI (Free Trial)
See Also: Configuration Guide
