Session starts in parent directory instead of the git repo the CLI was launched from

Status Fixed / completed
Reported on v2.1.220
Maintainer reply None cached
Activity 0 comments · opened Jul 27, 2026 · closed Jul 27, 2026

Summary

Claude Code did not start the session in the directory it was launched from. The CLI was started inside a git repository, but the session's working directory was resolved to the parent folder, and the environment context reported "Is a git repository: false".

Environment

  • Claude Code version: 2.1.220
  • Platform: macOS (Darwin 25.5.0), zsh
  • Model: claude-fable-5

What happened

  1. Created a fresh, empty git repository (git init, no commits yet, worktree contained only .git/), e.g. ~/code/<repo> inside a parent folder that contains many other repos but is not itself a repo.
  2. Launched claude from inside ~/code/<repo> (repo created ~35 min before the session).
  3. The session's environment context showed:
  • Primary working directory: ~/code (the parent folder)
  • Is a git repository: false
  1. Throughout the session, the Bash tool's working directory also kept resetting to the parent folder ("Shell cwd was reset to ~/code").

Expected

The session should start in the launch directory (~/code/<repo>) and detect it as a git repository.

Actual

The session ran against the parent directory. As a consequence the agent scaffolded a new project as a sibling directory of the repo instead of inside it, while the user was looking at their (empty-looking) repo — considerable confusion until the mismatch was found.

Repro hints

  • The launch directory was a freshly-initialized repo with an empty worktree and no commits at launch time — possibly the directory-resolution logic falls back to a parent/previous directory in that case.
  • The parent folder had been used as a Claude Code working directory in earlier sessions (project history exists for it), so a stale project-association fallback could also explain it.

---
🤖 Generated with Claude Code

View original on GitHub ↗