[BUG] Only 1 of 3 PRs created in the same session resolves via --from-pr
Bug Description
Three pull requests were created by Claude within a single session. The CLI reference states that "Sessions are linked automatically when Claude creates the pull request", but only one of the three resolves via claude --from-pr. The other two find no linked session.
Steps to Reproduce
In one session, in one repository:
- Ask Claude to create PR A. Claude creates a branch, commits, pushes, and runs
gh pr create. - Same session: ask for PR B. Same flow, different branch.
- Same session: ask for PR C. Same flow, different branch.
claude --from-pr <A>/<B>/<C>
Only PR C resolved to a session. A and B reported no linked session.
What the three PRs have in common
All three were created the same way, by the same session, in the same repository. Their recorded identifiers are identical:
| | PR A | PR B | PR C |
|:--|:--|:--|:--|
| Claude-Session: trailer in every commit | session_XXX | session_XXX (same) | session_XXX (same) |
| claude.ai/code/session_... URL in PR body | present, same id | present, same id | present, same id |
| head branch | distinct | distinct | distinct |
| --from-pr resolves | no | no | yes |
Nothing stored in the PRs distinguishes C from A and B.
Possibly relevant
All three branches were force-pushed after the PR was opened (history rewritten to drop an unrelated commit, and a rebase for a stacked PR). If the session link is keyed on a head commit SHA, a force-push would invalidate it — but that happened to all three, so it does not by itself explain why C survived.
One more detail that may or may not matter: the session's own recorded cwd/gitBranch belong to a different repository than the PRs. The work in the PR repository was done with git -C <other-repo> rather than by changing the session's working directory, so the session's transcript never records the PR repository's branches.
Expected Behavior
Every PR created by Claude during a session is resolvable by --from-pr for the lifetime of that session's transcript, regardless of subsequent force-pushes or of which directory the session was started in.
Actual Behavior
Only one of three linked. There is no user-visible way to tell which PRs are linked, nor to repair or re-establish a broken link.
Suggestions
- Make the link recoverable from data that lives in the PR itself. The
Claude-Session:trailer is already written into every commit, but it carries the bridge session id, which is not unique per conversation — in the environment where this was observed, 91 local sessions shared only 8 distinct bridge ids. Emitting the per-conversation session id (the transcript UUID) alongside it would make the link reconstructible without any server-side state. - Surface the link status, e.g. have
--from-prsay what it matched on when it fails.
Environment
- Claude Code 2.1.223
- macOS (Darwin 25.5.0), Apple Silicon
- CLI, GitHub PRs created via
gh pr create
Related
- #52604, #22035 —
--from-prdocumentation - #31992 — cross-machine session resume