claude-code - 💡(How to fix) Fix [BUG] /ultraplan attaches to ancestor git repository, ignoring nested repo in CWD [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46302Fetched 2026-04-11 06:23:53
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×2

Error Message

Error Messages/Logs

When the ancestor is clean, there is no error — the cloud session silently proceeds with the wrong codebase.

Root Cause

Possibly related, different root cause:

Code Example

There are uncommitted changes in the repository. Please commit and push these changes to the remote branch. Do not create a pull request unless the user has explicitly asked for one.

---

mkdir ~/parent && cd ~/parent && git init
   echo "parent" > a.txt && git add . && git commit -m "init"

---

mkdir ~/parent/child && cd ~/parent/child
   git init && gh repo create child --private --source=. --push

---

$ git rev-parse --show-toplevel
   /Users/<you>/parent/child
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • Searched existing issues
  • Single bug report
  • Using latest version

What's Wrong?

When invoking /ultraplan from inside a nested git repository, Claude Code uploads an ancestor repository to the cloud session instead of the repository in the current working directory. Git itself resolves the CWD repo correctly (git rev-parse --show-toplevel returns the nested repo), but ultraplan's repo detection disagrees and picks an ancestor.

This is silent and deterministic. The user has no indication that a different repo has been attached — the cloud plan is generated against an entirely unrelated codebase from the first invocation onward, with no prior ultraplan session required.

What Should Happen?

Ultraplan should upload the repository reported by git rev-parse --show-toplevel — the nested repo in the current working directory — not an ancestor repository further up the tree.

Error Messages/Logs

When the ancestor happens to have uncommitted changes, the cloud session errors with:

There are uncommitted changes in the repository. Please commit and push these changes to the remote branch. Do not create a pull request unless the user has explicitly asked for one.

This message is misleading — the child repo in CWD is clean; the dirty state belongs to an ancestor the user did not intend to attach.

When the ancestor is clean, there is no error — the cloud session silently proceeds with the wrong codebase.

Steps to Reproduce

  1. Create a parent git repository:

    mkdir ~/parent && cd ~/parent && git init
    echo "parent" > a.txt && git add . && git commit -m "init"
  2. Inside it, create a nested git repository with its own GitHub remote:

    mkdir ~/parent/child && cd ~/parent/child
    git init && gh repo create child --private --source=. --push
  3. Confirm git resolves the child correctly:

    $ git rev-parse --show-toplevel
    /Users/<you>/parent/child
  4. From ~/parent/child, run claude and invoke /ultraplan <any prompt>.

Observed: ultraplan attaches to ~/parent (the ancestor) instead of ~/parent/child (the CWD repo).

Claude Model

Opus

Is this a regression?

I don't know

Claude Code Version

2.1.100 (Claude Code)

Platform

Anthropic API

Operating System

macOS 26.4

Terminal/Shell

Terminal.app

Additional Information

Subscribed via Claude Max.

git rev-parse --show-toplevel is git's canonical way to resolve the enclosing repository and is what any CLI tool operating on "the current repo" should use. Ultraplan appears to use separate resolution logic that walks further up the tree than git does, even when the nested repo has its own .git directory and its own remote.

Possibly related, different root cause:

  • #44643 — "Remote session receives wrong project context." That report describes cross-session state leakage (a previous ultraplan session's project context bleeding into a new invocation for a different project). This issue is distinct: the wrong repo is attached on the first invocation with no prior session, and the wrong repo is specifically the git ancestor of the CWD.
  • #44815 — "Always routes to wrong workspace." Closed as duplicate of #44643, but the reporter describes deterministic first-call failure, which matches this issue's symptom more closely than #44643's stale-session diagnosis. Possibly a misfiled dedupe.

Both bugs likely live in the same workspace-resolution module, but the symptoms, repros, and fix directions differ.

extent analysis

TL;DR

Ultraplan should use git rev-parse --show-toplevel to resolve the current repository, ensuring it attaches to the correct nested repository instead of an ancestor.

Guidance

  • Verify that the git rev-parse --show-toplevel command returns the expected nested repository path when run from the current working directory.
  • Investigate the repository resolution logic in Ultraplan to determine why it is walking further up the tree than Git does, and consider updating it to use the same logic as git rev-parse --show-toplevel.
  • Compare the implementation of Ultraplan's repository resolution with the possibly related issues (#44643 and #44815) to identify potential similarities or differences in the root cause.
  • Test the fix by running the steps to reproduce and verifying that Ultraplan attaches to the correct nested repository.

Example

No code snippet is provided as the issue does not contain sufficient information to create a specific example.

Notes

The issue may be related to other bugs in the workspace-resolution module, but the symptoms and repro steps are distinct. The fix should focus on updating Ultraplan's repository resolution logic to match Git's behavior.

Recommendation

Apply a workaround by modifying Ultraplan's repository resolution logic to use git rev-parse --show-toplevel, as this is the canonical way to resolve the enclosing repository in Git. This change should ensure that Ultraplan attaches to the correct nested repository instead of an ancestor.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING