claude-code - 💡(How to fix) Fix Feature request: --cwd CLI flag to set working directory at launch [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47017Fetched 2026-04-13 05:43:42
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
commented ×2renamed ×1

Fix Action

Fix / Workaround

current workaround

cd ~/projects/api && claude


The workaround changes the shell's directory and doesn't compose well in scripts, aliases, or launcher tools. A `--cwd` flag would make it a proper one-liner.

Code Example

# desired
claude --cwd ~/projects/api

# current workaround
cd ~/projects/api && claude
RAW_BUFFERClick to expand / collapse

Feature Request

Add a --cwd <path> CLI flag so the working directory can be set at launch time.

Proposed flag

  • --cwd <path> — set the primary working directory (equivalent to cd <path> && claude)

Use case

When launching multiple Claude Code sessions (e.g., in separate terminal windows or via scripts), there's no way to set the working directory as a single command:

# desired
claude --cwd ~/projects/api

# current workaround
cd ~/projects/api && claude

The workaround changes the shell's directory and doesn't compose well in scripts, aliases, or launcher tools. A --cwd flag would make it a proper one-liner.

Notes

  • --cwd would set the primary working directory (distinct from existing --add-dir which adds supplemental directories without changing the primary)
  • --color was originally part of this request but is already covered by #40393, #35788, and #45387

extent analysis

TL;DR

Implementing a --cwd <path> CLI flag to set the working directory at launch time is the most likely fix.

Guidance

  • Review the proposed flag syntax and use case to understand the required functionality.
  • Consider the distinction between the primary working directory and supplemental directories added by --add-dir.
  • Evaluate how the new flag would interact with existing commands and scripts.
  • Investigate how to properly handle errors, such as invalid or non-existent directory paths.

Example

# Example usage of the proposed flag
claude --cwd ~/projects/api

Notes

The implementation details, such as parsing the flag and updating the working directory, are not specified in the issue. Additionally, the issue does not provide information about the current implementation of the claude command or its internal workings.

Recommendation

Apply workaround: until the --cwd flag is implemented, use the current workaround cd <path> && claude to set the working directory. This is because the issue is a feature request, and implementing the new flag may take time.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Feature request: --cwd CLI flag to set working directory at launch [2 comments, 2 participants]