[Feature Request] Add ability to change session working directory with `/cd` command and `--cwd` resume flag

Resolved 💬 3 comments Opened Mar 21, 2026 by jordan-of Closed Mar 24, 2026

Bug Description
Feature Request: Ability to Change Session Working Directory

From: Jordan Dea-Mattson
GitHub: @jordan-of (OrdinaryFolk), @jordandm (personal)
Email: jordan-of@users.noreply.github.com
Related: #36909 (Session naming and state indicators), #5768 (Resume only works from original directory), #35226 (my duplicate of #5768, auto-closed)

Problem

A Claude Code session's working directory is fixed at launch and cannot be changed. If the directory is deleted, moved, or becomes invalid during the session's lifetime, every shell command fails
unless manually prefixed with cd <valid-path> &&.

Real-world scenario that triggers this: A session is launched from a git worktree (e.g., .worktrees/transcript-analysis/). During the session, the worktree is deleted as part of normal branch
cleanup — performed by Claude Code itself. The session continues (conversation context intact), but the cwd now points to a non-existent directory. Every Bash command silently fails or requires a
manual cd prefix for the remainder of the session.

This is particularly insidious because the session can successfully delete its own worktree directory. Git commands still work (they resolve the repo root from .git), but the cwd is a ghost path.
The user doesn't notice until commands start failing unpredictably.

The resume problem compounds this. Per #5768 (open since v1.0.80), sessions can only be resumed from the same directory where they were launched. If that directory no longer exists, the session
cannot be resumed at all. Starting a new session fixes the cwd but loses all conversation context — the entire working memory of what was built, decided, and planned.

Claude Code itself is confused about this. When asked how to work around the cwd issue, Claude Code suggests using claude --cwd <path> — but this flag does not exist. The model believes it's a
valid option, which leads users down a dead end.

Requested Behavior

  1. Change cwd within a session: A command (e.g., /cd <path>) that updates the session's working directory. This should:
  • Update the cwd for all subsequent Bash, Read, Write, Edit, Glob, Grep tool calls
  • Update the terminal title and statusline to reflect the new path
  • Persist across the session (survive context compression)
  1. Change cwd on resume: claude --resume <id> --cwd <path> to override the stored cwd when resuming an existing session. This would also resolve #5768/#35226.
  2. Detect invalid cwd: On session start or resume, check if the cwd exists. If it doesn't:
  • Warn the user: "Session was started in <path> which no longer exists."
  • Prompt for a new path or default to the git repo root
  • Do not silently proceed with a broken directory

Why This Matters

Git worktrees are ephemeral by design — created for a task, removed when done. Claude Code sessions that span worktree lifetimes (common when the session manages the cleanup itself) end up
stranded with an invalid cwd and two bad options: lose context (new session) or fight the cwd (prefix every command).

This directly affects the multi-session workflow described in #36909. When running 4-5 sessions across worktrees, worktree lifecycle management is routine. The inability to update a session's cwd
after the fact turns a normal git operation into a session-ending event.

The non-existent --cwd flag suggests this is a known gap in the design — the model has been trained to expect the feature exists, but it was never implemented.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.81
  • Feedback ID: 6c2051f5-b17c-4dcd-9d48-8e49408f2791

Errors

[{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/jordan_of/.local/share/claude/versions/2.1.81 (expected in multi-process scenarios)\n    at TET (/$bunfs/root/src/entrypoints/cli.js:2724:2174)\n    at fgq (/$bunfs/root/src/entrypoints/cli.js:2724:1318)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-03-21T03:43:37.846Z"}]

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗