[Feature Request] ability to change Working Directory mid-session
Status Fixed / completed
Maintainer reply ✓ Yes — rboyce-ant
Workaround ✓ Mentioned in thread ↓
Activity 12 comments · opened Jun 5, 2025 · closed Jul 12, 2025
💡 Likely answer: A maintainer (rboyce-ant, contributor)
responded on this thread — see the highlighted reply below.
Hi, it would be very useful if we could change the working directory mid-session.
When I use claude code, I usually need to work across multiple repos, and those repos are interconnected closely so sharing the same context helps.
For example, I may ask it to do some code change in repo A (which is a library), then I want it to be able to cd to repo B (which is an application) to update the code to use the new feature in repo A.
This is impossible to do now, as we get
Error: ERROR: cd to '...' was blocked. For security, Claude Code may only change directories to child directories of the original working directory (...) for this session.
Even if I manually use bash mode and
! cd ...(new directory)
I get
Shell cwd was reset to ...(original working directory)
So it would be great if we can explicitly change the working directory.
Thanks.
12 Comments
I'm in monorepo(Turborepo) and sometimes i need this feaature.
It's good to have
cdboundary so that Claude can safelycdto the ancestor directories until the boundary blocks.#1588
claudecan'tcd ..from where you openedclaudeBUT
claudeCANcd fooand thencd ..to where you started.So while not ideal, you may start all your sessions from
~and ask tocdto where you wanna work on while retaining the ability to move from~/*You still miss things like
/tmpwhich was my original request https://github.com/anthropics/claude-code/issues/1588I naturally tried starting session at
/but it didn't work, I could not navigate anywhere.Okay, thanks for the info @adriangalilea
I understand you can indeed do this to mitigate this problem.
However, I also think it would be nice if claude code can offer a feature to allow user to explicitly change the working dir, such as using
/cdcommand. I don't see any obvious reason why such a feature can't be implementedSecurity, this systems are becoming too smart, they can run things behind your back if they go rogue/prompt-injected/hallucinate. Guardrails are mandatory now, but I do agree granular control over these is necessary.
Check the other issue I linked before, it is also a feature request similar to yours.
Just wanted to share a temporary solution with everyone to make the situation less annoying in the meantime.
Yeah, I understand this is a guardrail and a security feature.
What I'm suggesting is, user can intentionally and explicitly run a
/cdcommand (just like they can run/compact) to change the working directory. This new command will be very useful, and it will beun-injectable(since the only way to trigger this behaviour is if the user's input explicitly starts with/cd, user input is not injectable as it only comes directly from the user).Can I add to this suggestion: I came looking for the ability to change working dir to a subdirectory of the project.
Scenario:
/treeto create a worktree for you and cd into itcd'd into - e.g.Write(../../../somefile.ts).Seems like something in the system prompt is prompting it to use the project root rather than the dir it cd'd into.
Hi all, you can now add additional working directories to an existing session. Claude Code can read and edit files and cd to those directories just like with the original working directory.
Because the session settings are loaded from the original working directory, if you need to change the original working directory, the best way to do that is to exit Claude Code and start a new session.
This doesn’t seem to work for me,
When I add:
To my
~/.claude/settings.jsonit still complains:Why?
I feel like some nuance is being lost here. From my reading:
--add-diras well as the other ways to configure it including~/.claude/settings.jsonallow you to read code in that directoryBUT
the cd restriction is still in place after that. We have one monorepo where we have most of our configuration and tooling for Claude lives, and then a couple other repos we still want to be able to work on and read. It seems
add-dirsolves the "bring this folder into context" but not "cd into that folder and run commands"Came here after I wanted exactly the same: to create worktrees on the fly and switch to them.
You can't change it seems, but you can add a working directory using
/add-dir. Hope this helpsThis issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.