[FEATURE] --cwd <path> flag to set working directory at startup

Resolved 💬 3 comments Opened Feb 17, 2026 by jbro Closed Mar 18, 2026

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

There's no way to start Claude Code in a specific working directory without first cd-ing there in the shell. This makes it harder to script, alias, or integrate Claude Code into workflows where the shell's CWD shouldn't change.

For example, launching Claude inside a git worktree from a parent directory currently requires:

cd .worktrees/my-feature && claude

This changes the shell's state as a side effect. A --cwd flag would avoid that.

Proposed Solution

A --cwd <path> CLI flag that sets the working directory before the session starts.

claude --cwd .worktrees/my-feature
claude --cwd /absolute/path/to/project

Behavior

If the path exists and is a directory, start the session with that as the CWD
If the path does not exist or is not a directory, exit with a non-zero status and a clear error
Should compose with other flags (e.g. claude --cwd ../other-repo --add-dir ../lib)
Alternative Solutions
cd <path> && claude — works but changes the shell's CWD as a side effect
--add-dir — grants access to additional directories but doesn't change the primary working directory; tools still anchor to the launch directory

Alternative Solutions

_No response_

Priority

Low - Nice to have

Feature Category

CLI commands and flags

Use Case Example

Launch Claude in a worktree without leaving the current directory

claude --cwd .worktrees/my-feature

Scriptable — e.g. in a wrapper or alias

alias claude-wt='claude --cwd .worktrees/"$1"'

Additional Context

Related: #19903 (requesting /cd to change working directory mid-session). This proposal covers only the startup flag, which is a simpler, lower-risk addition.

View original on GitHub ↗

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