Skip to content

chore: claude-review - add stacked PR context#2325

Merged
graphite-app[bot] merged 1 commit intomainfrom
03-05-chore_claude-review_-_add_stacked_pr_context
Mar 5, 2026
Merged

chore: claude-review - add stacked PR context#2325
graphite-app[bot] merged 1 commit intomainfrom
03-05-chore_claude-review_-_add_stacked_pr_context

Conversation

@kristina-solovyova
Copy link
Collaborator

@kristina-solovyova kristina-solovyova commented Mar 5, 2026

When review runs vs. skips

Job 1: optimize_ci — stack position check

Runs first on every PR event. Decides should_review:

Condition Result
PR has claude-review label run (forced override)
No open child PR targeting this branch run (top of stack)
Another open PR is stacked on top of this one skip (intermediate PR)

Goal: avoid running Claude review on every PR in a stack — only the top PR gets reviewed.

Job 2: claude-review — actual review

Only runs when:

  1. should_review == true (from above)
  2. PR is not from a fork
  3. Author is OWNER, MEMBER, or COLLABORATOR

Additionally guarded by the targets_main check inside the job:

  • If the PR (directly or via its stack chain) eventually targets mainrun review
  • Otherwise → print skip notice and stop

Build PR stack context (step)

When a PR does not directly target main, this step walks the stack upward to find all parent PRs.

Algorithm:

  1. Start at base_ref of the current PR
  2. For each base branch, query gh pr list --head <branch> to find the PR whose head is that branch
  3. Collect PR #N: <title> for each parent
  4. Walk up until reaching main or hitting a missing PR or the 20-iteration safety limit
  5. Set targets_main=true if the walk reaches main

Output:

  • targets_main — gates whether the review step runs at all
  • stack_section — a formatted markdown block injected into the Claude prompt

How Claude uses stack context:

The stack_section is appended to the review prompt with instructions to:

  1. Compare each parent PR title to the current PR topic
  2. For related parent PRs, fetch their diff via gh pr diff <number>
  3. Use parent diffs as background context (not re-review targets)
  4. Skip unrelated parent PRs

This gives Claude enough context to understand what code is new in the current PR vs. inherited from parent stack PRs.

Copy link
Collaborator Author

kristina-solovyova commented Mar 5, 2026

@kristina-solovyova kristina-solovyova marked this pull request as ready for review March 5, 2026 11:22
@kristina-solovyova kristina-solovyova requested a review from a team as a code owner March 5, 2026 11:22
Copilot AI review requested due to automatic review settings March 5, 2026 11:22
@graphite-app graphite-app bot requested review from assafgi and tigrawap March 5, 2026 11:22
@graphite-app
Copy link

graphite-app bot commented Mar 5, 2026

Graphite Automations

"Add anton/matt/sergey/kristina as reviwers on operator PRs" took an action on this PR • (03/05/26)

2 reviewers were added to this PR based on Anton Bykov's automation.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Claude Code Review GitHub Actions workflow to include stacked-PR ancestry context in the prompt so the reviewer can optionally pull parent diffs for background.

Changes:

  • Fetch full git history in checkout (fetch-depth: 0).
  • Add a step that uses gh pr list + jq to build a “Stacked PR Context” section and exports it via GITHUB_ENV.
  • Extend the Claude prompt and allowed tools to support stacked-context lookup and editing an empty PR description.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@kristina-solovyova kristina-solovyova force-pushed the 03-05-chore_claude-review_-_add_stacked_pr_context branch from bc30d30 to 6c8fdf0 Compare March 5, 2026 11:27
Copilot AI review requested due to automatic review settings March 5, 2026 11:29
@kristina-solovyova kristina-solovyova force-pushed the 03-05-chore_claude-review_-_add_stacked_pr_context branch from 6c8fdf0 to 521a274 Compare March 5, 2026 11:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@kristina-solovyova kristina-solovyova force-pushed the 03-05-chore_claude-review_-_add_stacked_pr_context branch from 5b1f862 to 06c2f21 Compare March 5, 2026 12:05
Copilot AI review requested due to automatic review settings March 5, 2026 12:14
@kristina-solovyova kristina-solovyova force-pushed the 03-05-chore_claude-review_-_add_stacked_pr_context branch from 06c2f21 to be7e761 Compare March 5, 2026 12:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@kristina-solovyova kristina-solovyova force-pushed the 03-05-chore_claude-review_-_add_stacked_pr_context branch from be7e761 to 6559818 Compare March 5, 2026 12:23
@graphite-app
Copy link

graphite-app bot commented Mar 5, 2026

Merge activity

  • Mar 5, 12:30 PM UTC: kristina-solovyova added this pull request to the Graphite merge queue.
  • Mar 5, 12:31 PM UTC: CI is running for this pull request on a draft pull request (#2326) due to your merge queue CI optimization settings.
  • Mar 5, 12:32 PM UTC: Merged by the Graphite merge queue via draft PR: #2326.

@graphite-app graphite-app bot merged commit 6559818 into main Mar 5, 2026
40 checks passed
@graphite-app graphite-app bot deleted the 03-05-chore_claude-review_-_add_stacked_pr_context branch March 5, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants