[FEATURE] Inject current PR info into the gitStatus system context
[FEATURE] Inject current PR info into the gitStatus system context
Summary
The prompt footer already fetches and displays the current branch's PR state (review
status, merge state) as a colored dot since v2.1.20. The LLM does not receive any of
that information. As a result, when a user says "comment on the current PR", the model
has to run a gh command to discover the PR number - even though the harness already
knows it.
Current behavior
The gitStatus block injected into the system context looks like this:
Current branch: feature/fix-ampersand-search
Main branch (you will usually use this for PRs): main
Git user: digitalby
Status: M src/search.ts
Recent commits:
abc1234 Fix search normalization for ampersand
PR number, URL, title, and review state are absent, even when the footer is actively
showing a colored PR indicator for the same branch.
Expected behavior
When the current branch has an associated PR, the gitStatus block should include the
PR context:
Current branch: feature/fix-ampersand-search
Main branch (you will usually use this for PRs): main
Git user: digitalby
Current PR: #1234 "Fix search normalization for ampersand" [open, approved]
PR URL: https://github.com/anthropics/claude-code/pull/1234
Status: M src/search.ts
Recent commits:
abc1234 Fix search normalization for ampersand
When there is no PR for the current branch, no PR fields are added (no change from
current behavior).
Why this matters
The information is already available: the status line fetches it from GitHub on session
start. The LLM is just not handed that result. Without it, any PR-related instruction
("comment on the current PR", "update the PR description", "check the PR review status")
requires a redundant gh pr list or gh pr view call to resolve "current PR" to a
concrete number. That call costs tokens and a subprocess round-trip on every fresh
session.
This is also deterministic context (the branch either has a PR or it does not) rather
than heuristic inference, which reduces the chance of the model picking the wrong PR
when multiple PRs are open.
Related
- v2.1.20: Added PR review status indicator to the prompt footer
- v2.1.27: Added
--from-prflag and auto-linking of sessions created viagh pr create
The session-linking work in v2.1.27 covers the case where a session is resumed from a
known PR. This request covers the complementary case: sessions started interactively on
a branch that already has a PR open, where the PR number should be inferred from the
branch automatically.
Proposed implementation sketch
The gitStatus context builder already reads the current branch name. After that:
- Run
gh pr view --json number,title,state,url(no--headneeded;ghdefaults to
the current branch's PR).
- If the command succeeds, append
Current PRandPR URLlines beforeStatus. - If the command fails or returns nothing (no PR for this branch), skip silently.
The status line already performs an equivalent query for the footer indicator. If that
result is cached in-process, step 1 can reuse it at zero cost.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗