Submodule project path derived from .git/modules/ instead of working directory

Resolved 💬 4 comments Opened Mar 25, 2026 by mhonsel Closed Mar 25, 2026

Summary

When Claude Code runs inside a git submodule, the project path (used for ~/.claude/projects/<key>/) is derived from the git metadata path (.git/modules/...) instead of the actual working directory.

Reproduction

  1. Have a repo with a git submodule (e.g., parent-repo/submodule/)
  2. Launch Claude Code from the submodule directory

Expected: Project dir key derived from the working directory:

~/.claude/projects/-Users-me-Dev-parent-repo-submodule/

Actual: Project dir key derived from git metadata path:

~/.claude/projects/-Users-me-Dev-parent-repo--git-modules-submodule/

Root cause

Likely using git worktree list --porcelain to determine the working directory. For submodules, the main worktree entry returns the bare git metadata directory:

$ cd parent-repo/submodule
$ git worktree list --porcelain
worktree /Users/me/Dev/parent-repo/.git/modules/submodule
HEAD abc123
branch refs/heads/main

git rev-parse --show-toplevel returns the correct path:

$ git rev-parse --show-toplevel
/Users/me/Dev/parent-repo/submodule

Impact

The submodule gets an unexpected project key, so project-scoped state (memory, settings) is stored under a path that doesn't correspond to the actual working directory.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗