Skip to content

Feature request: /cd command to change working directory mid-session #19903

Description

@Zycroft

Feature Request

Add a built-in /cd command that changes Claude Code's working directory mid-session.

Problem

Currently, Claude Code's working directory (workspace.current_dir) is set at session start and cannot be changed during a session. This is problematic when:

  1. Working with git worktrees - Users create a worktree and want to switch to it without restarting Claude
  2. Navigating monorepos - Moving between packages/services in a large codebase
  3. Context switching - Moving to a different project directory during a session

The shell's cd command resets after each Bash invocation, so it doesn't persist. Custom commands can't modify the internal workspace state.

Current Workaround

Users must exit and restart Claude Code in the new directory:

cd /path/to/new/dir && claude

This loses conversation context and is disruptive to workflow.

Proposed Solution

Add a built-in /cd <path> command that:

  1. Validates the target directory exists
  2. Updates workspace.current_dir internally
  3. Updates the statusline to reflect the new directory
  4. Persists the new directory for all subsequent tool calls

Example Usage

/cd ../my-worktree
/cd ~/projects/other-repo
/cd ..

Additional Context

  • The statusline hook reads from data.workspace.current_dir, so updating this internal state would automatically fix statusline display
  • This would make Claude Code much more flexible for users who work across multiple directories in a session

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions