Add /remove-dir command to remove session-added working directories
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When I add a directory to my session using /add-dir, there's no way to remove it without ending the entire session and starting over. This becomes problematic during long sessions where I might:
- Accidentally add the wrong directory path (typo or incorrect folder)
- Need to temporarily access another project or repository
- Want to correct a mistake without losing conversation context
For example, if I accidentally run /add-dir /home/user/wrong-path or intentionally add /home/user/temp-project to help with a specific question, there's no way to remove it once I'm done. I'm forced to either:
- Keep the unwanted directory loaded, which can:
- Increase the scope of what Claude can access (potential security/privacy concern)
- Cause cross-project context pollution
- Reduce focus on my actual working directories
- Impact performance with unnecessary directory indexing
- Restart the entire session, which means:
- Losing all conversation history and context
Currently, the only solution is to restart the entire session, losing all valuable conversation history and context built up during the session.
Proposed Solution
Add a /remove-dir command that works as the inverse of /add-dir:
Option A: Direct command
/remove-dir /path/to/directory
Removes the specified directory from the current session's working directories.
Option B: Interactive management
Running /add-dir without arguments could show:
- List of currently added directories (both from config and session)
- Interactive checkboxes to add/remove directories
- Clear indication of which are persistent (from settings) vs session-only
Option C: Enhanced /permissions command
Extend the existing /permissions command to show and manage added directories:
/permissions
View current directories
Remove session-added directories
Toggle directory access
The command should:
- Only remove directories added via
/add-dirin the current session - Not modify persistent directories from
settings.json - Provide confirmation of what was removed
- Show updated list of active directories after removal
Alternative Solutions
Workarounds I'm currently using:
- Restarting Claude Code sessions (loses all context and history)
- Being very careful about when I use
/add-dir(limits flexibility) - Manually editing
settings.jsonif I accidentally persist it (error-prone)
What other tools do:
- VS Code: Workspaces can have folders added/removed dynamically
- IDEs like IntelliJ: Project structure can be modified without restart
- Git:
git rm --cachedremoves files from tracking without deletion
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
Scenario 1: Correcting a mistake
- I'm working on a project and want to add a related directory
- I accidentally run
/add-dir /home/user/wrong-folder(typo or incorrect path) - I realize the mistake immediately but the wrong directory is now added
- With this feature: I run
/remove-dir /home/user/wrong-folder, then/add-dir /home/user/correct-folderto fix it - Without this feature: I either:
- Keep the wrong directory loaded (clutters my workspace, potential security/privacy concern)
- Restart the entire session to correct the mistake (lose all conversation history and context)
Scenario 2: Temporary directory access
- I'm working on my main project in
/home/user/my-app - A colleague asks about code in a different repository at
/home/user/other-project - I run
/add-dir /home/user/other-projectto help answer their question - After answering, I want to continue working on my main project without that extra context
- With this feature: I run
/remove-dir /home/user/other-projectand continue my session cleanly - Without this feature: I either:
- Keep the extra directory loaded (performance hit, potential confusion, broader context scope)
- Restart the entire session (lose all conversation history and context)
Time saved: This would save 5-10 minutes per occurrence when correcting mistakes or temporarily adding directories for specific questions, plus preserve valuable conversation context that would otherwise be lost in a restart.
Additional Context
- Currently,
/add-dironly adds directories; there's no corresponding removal command - The
/permissionscommand exists but doesn't show or manage added directories - Session-added directories are not persisted in
settings.json(they're session-only), but there's no way to remove them mid-session - This would complement the existing
/add-dirfunctionality and make directory management more flexible - Related to broader directory/workspace management patterns in modern development tools
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗