Claude Code /cd: Switch Directories Without Losing Your Cache

Claude Code

Claude Code 2.1.169 ships the long-requested /cd command, which changes the session's working directory mid-session while preserving the existing prompt cache. Previously, switching directories required exiting and restarting Claude Code entirely, discarding accumulated context and cache. This is particularly useful for monorepo workflows and git worktree navigation.


Long-Requested Feature: Change Directories Without Losing Your Session

Claude Code 2.1.169 delivers a frequently requested quality-of-life improvement: the /cd command, which lets users change the session's working directory while keeping the current session and prompt cache intact.

The Problem It Solves

Claude Code's working directory has historically been fixed at session start. The tool embeds the working directory into its system prompt as part of the cache key, meaning that navigating to a different directory mid-session was not possible without losing everything: the conversation history, the accumulated prompt cache, and the contextual awareness Claude had built up about the current codebase.

This friction was most acute in three scenarios:

  • Monorepo navigation: Moving between packages or sub-projects within a large repository required exiting and restarting, breaking flow.
  • Git worktrees: Developers using multiple worktrees for parallel feature branches could not switch between them in a single session.
  • Incremental context-building: Users who wanted to orient Claude in one directory before pivoting to related work elsewhere had no clean way to do so.

Multiple GitHub feature requests documented this pain: the issue had accumulated community interest across several separate threads.

How It Works

The /cd command updates the session's working directory while preserving the prompt cache. After running /cd path/to/new-directory, Claude Code updates its awareness of the file system context, git state, and CLAUDE.md files for the new location, without requiring a cold restart.

/cd ../api-service
/cd /Users/me/projects/other-repo

The cache preservation means that long sessions working across multiple directories remain economical in terms of token costs, an important consideration for teams on rate-limited plans.