Interactive `claude` launched in a subfolder is filed under a parent dir — shared daemon / bg-spare pool appears anchored to the wrong cwd
Summary
When claude is launched interactively from a project subdirectory, the session is recorded and stored under a different (parent/umbrella) directory than where it was launched. The launch directory is effectively ignored. Headless claude -p from the same folder roots correctly, so the bug is specific to the interactive (daemon-backed) path.
Net effect: every interactive chat started in any subfolder pools into one umbrella project, silently. Project isolation is broken.
Environment
- Claude Code v2.1.177, Linux (aarch64), shell zsh. Reproduces with and without tmux.
Steps to reproduce
cd ~/Apps/spec-kit(a git repo that is a subfolder of~/Apps).- Run
claude(interactive). - The conversation is stored under
~/.claude/projects/<encoded ~/Apps>with recordedcwd = ~/Apps— not~/Apps/spec-kit. - Contrast:
claude -p "..."from the same directory is correctly stored under<encoded ~/Apps/spec-kit>withcwd = ~/Apps/spec-kit.
Expected
Interactive claude should root the session at its launch directory (the cwd of the front-end), identical to headless -p. Launching in ~/Apps/spec-kit should create/append a ~/Apps/spec-kit project.
Actual
The session's recorded cwd and project bucket is the parent umbrella dir (~/Apps), regardless of the actual launch directory.
Evidence (live /proc/<pid>/cwd + cmdline)
- The interactive front-end processes are correctly in the subfolder: multiple
claudeprocesses withcwd = ~/Apps/spec-kit. - There is a single shared
claude daemon runprocess, plus a pool of pre-spawned--bg-spareworker processes. The majority of those spares are anchored to~/Apps(the umbrella), with only a couple at the actual subfolder. - Filesystem ground truth: every interactive session created from the subfolder was filed under the
~/Appsproject withcwd = ~/Apps. The only session correctly filed under the subfolder project was a headless-prun.
This points to the daemon binding sessions to a pre-warmed worker's anchored cwd rather than the front-end's actual launch cwd.
Impact
- Conversations started in different project subfolders all collapse into one parent project — confusing and, for users who organize work per-subfolder, effectively makes per-project sessions impossible via the normal interactive flow. (User report: "I can only have 1 instance" / "everything just falls into ~/Apps.")
Requests
- Root interactive sessions at the front-end's launch cwd (match
-pbehavior); the daemon should not bind a session to a spare worker whose cwd differs from the launch directory. - Provide a documented setting/env to disable the shared background daemon / spare-worker pool, so each
claudeis an independent process rooted where it is launched.
Related
#68373 — covers the (separate) issue of how this same bug report was mishandled in-session. This issue is the underlying product defect.
3 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Additional evidence —
claude daemon statusThe daemon's own status output corroborates the diagnosis:
transient — started on-demand by claude … in ~(home directory).10 bg workers running.claude agents (pid …) in ~/Apps/spec-kitclaude agents (pid …) in ~/Apps/spec-kitSo the daemon does track that those clients are in
~/Apps/spec-kit, yet their sessions are still recorded/filed under~/Apps. This points to the session's working directory being taken from a pre-warmed worker (anchored to~/Apps) rather than from the client's known launch cwd.Relevant context
~/.claude.jsonhasdefaultToAgentsView: true, and the front-ends register asclaude agents— i.e.claudeopens the agents dashboard (which displays the umbrella~/Apps), not a plain directory-rooted chat. This may be central to the misrooting.Candidate mitigations found in the v2.1.177 binary (not yet confirmed to fix the behavior)
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1— disables the background-tasks/daemon system.defaultToAgentsView: false/CLAUDE_CODE_DISABLE_AGENT_VIEW=1— opens a plain chat rooted in the launch dir instead of the dashboard.claude daemon stop— clears the anchored worker pool (note: also ends running background sessions).Suggested fix direction: when a client connects with a known launch cwd, the session should be rooted at that cwd, not at a reused worker's anchored directory.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.