VS Code extension: let a new session start in a chosen directory (per-tab cwd)

Status Open
Reported on v2.1.220
Maintainer reply None cached
Activity 0 comments · opened Jul 30, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single feature request
  • [x] I am using the latest version of Claude Code

Type: Feature request
Surface: VS Code extension (anthropic.claude-code), observed on 2.1.220, linux-x64, Remote-WSL

Problem

A session's working directory is decided by the window. When a panel is created, the extension
resolves cwd from the first workspace folder, falling back to the home directory. Every tab in a
window therefore shares one cwd, and there is no way to open a tab rooted anywhere else.

That is inconvenient for parallel work, but the bigger cost is attribution. Transcripts are
stored per working directory under ~/.claude/projects/<slug>/, so cwd decides how usage and
cost data can later be grouped. On my machine, 226 MB of 227 MB of transcripts sit in a single
home-directory bucket — every session ever started without a folder open, with nothing to
distinguish which project each belonged to. Rooting sessions per project fixes the reporting,
but only if several projects can be open at once, which one-cwd-per-window prevents.

Concretely: I routinely work four unrelated projects at the same time and would like four tabs,
four directories, one window.

Parity note

The desktop app already lets a directory be chosen when creating a session (see the repro steps
in #49888, which select a directory during session creation). The VS Code extension has no
equivalent. So this is a gap between surfaces rather than a new concept.

Related but distinct, both desktop-surface: #49888 (closed, not planned) and #72452 (directory
bar pinning).

Why the existing workarounds don't cover it

One window per directory. Works, but it means four windows for four tabs, discards the
multi-tab workflow, and multiplies extension hosts.

Rewriting the workspace file's folders array between tabs. The natural idea, since cwd is
read per panel: point folders[0] at project A, open a tab, repoint at B, open another. It
fails, because VS Code restarts the extension host whenever the first workspace folder
changes — documented behavior, since the deprecated workspace.rootPath must be updated:

If the first workspace folder is added, removed or changed, the currently executing extensions (including the one that called this method) will be terminated and restarted so that the (deprecated) rootPath property is updated to point to the first workspace folder.

The reload closes every Claude tab in that window mid-conversation. I confirmed this by
observation. Related VS Code issues:
microsoft/vscode#46048,
#66936,
#69335.

Terminal sessions (cd <dir> && claude) do give per-tab cwd in one window. But they trade
away the editor-pane UI — model switcher, Auto mode, image paste — which is the reason to use
the extension.

Multi-root workspace. Doesn't help: folders 2..n become additional directories, not cwd.

Proposed solution

Any way to specify the directory when creating a session would resolve this:

  1. Claude Code: New Session in Directory… — prompts for a folder (workspace folders plus a

browse option) and opens a tab rooted there.

  1. An argument on the existing command — let claude-vscode.editor.open accept an optional

cwd, so it can be driven from a keybinding or task:
``json
{ "key": "ctrl+alt+1", "command": "claude-vscode.editor.open",
"args": { "cwd": "~/projects/project-a" } }
``

  1. A directory picker in the new-tab UI, mirroring what the desktop app already offers.

Option 2 is the most composable; option 1 the most discoverable. Either is sufficient.

Why this may be inexpensive

From the shipped bundle, the plumbing appears to exist already. The internal spawnClaude
takes a cwd parameter and only falls back to the panel's captured value:

async spawnClaude(e, t, r, n, i, o, s, a, c = {}, l, u) {
  …
  let f = { cwd: i || this.cwd, resume: t, model: n, additionalDirectories: p, … }

and the main conversation path already passes a value for it. What seems missing is a way for
the user to influence that value, since the panel's cwd is computed once at creation from
workspaceFolders[0] || homedir().

If that reading is right, this needs no change to the workspace-folder model and does not depend
on the VS Code rootPath behavior being fixed. Caveat: I'm reading minified output from the
outside and may be misreading the call graph.

Impact

  • Per-project transcripts, so usage and cost tooling can attribute and trend by project instead

of collapsing into one home-directory bucket.

  • Parallel work across projects in one window, without terminal sessions or N windows.
  • Fewer sessions accidentally rooted at $HOME via the homedir() fallback.

Environment

  • Extension 2.1.220, linux-x64
  • VS Code Remote-WSL (Ubuntu 24.04, WSL2 on Windows)
  • Projects and toolchain live inside WSL

View original on GitHub ↗