Interactive `claude` launched in a subfolder is filed under a parent dir — shared daemon / bg-spare pool appears anchored to the wrong cwd

Status Fixed / completed
Maintainer reply None cached
Activity 3 comments · opened Jun 14, 2026 · closed Jun 18, 2026

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

  1. cd ~/Apps/spec-kit (a git repo that is a subfolder of ~/Apps).
  2. Run claude (interactive).
  3. The conversation is stored under ~/.claude/projects/<encoded ~/Apps> with recorded cwd = ~/Apps — not ~/Apps/spec-kit.
  4. Contrast: claude -p "..." from the same directory is correctly stored under <encoded ~/Apps/spec-kit> with cwd = ~/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 claude processes with cwd = ~/Apps/spec-kit.
  • There is a single shared claude daemon run process, plus a pool of pre-spawned --bg-spare worker 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 ~/Apps project with cwd = ~/Apps. The only session correctly filed under the subfolder project was a headless -p run.

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

  1. Root interactive sessions at the front-end's launch cwd (match -p behavior); the daemon should not bind a session to a spare worker whose cwd differs from the launch directory.
  2. Provide a documented setting/env to disable the shared background daemon / spare-worker pool, so each claude is 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.

View original on GitHub ↗

3 Comments

github-actions[bot] · 4 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/63675
  2. https://github.com/anthropics/claude-code/issues/5768
  3. https://github.com/anthropics/claude-code/issues/65536

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

kairin · 4 months ago

Additional evidence — claude daemon status

The daemon's own status output corroborates the diagnosis:

  • Origin: transient — started on-demand by claude … in ~ (home directory).
  • Workers: 10 bg workers running.
  • Clients holding it open include front-ends the daemon correctly knows are in the subfolder:
  • claude agents (pid …) in ~/Apps/spec-kit
  • claude agents (pid …) in ~/Apps/spec-kit

So 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.json has defaultToAgentsView: true, and the front-ends register as claude agents — i.e. claude opens 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.

github-actions[bot] · 1 month ago

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.