Skip to content

fix(skill): Detect stacked PR context from branch#5223

Open
adinauer wants to merge 3 commits intomainfrom
feat/create-java-pr-stack-detection
Open

fix(skill): Detect stacked PR context from branch#5223
adinauer wants to merge 3 commits intomainfrom
feat/create-java-pr-stack-detection

Conversation

@adinauer
Copy link
Member

📜 Description

Improve the local create-java-pr skill so it determines whether to run in standalone or stacked PR mode from git context.

The skill now checks the current branch and existing PR relationships to infer stack context, instead of relying on manual prompting.

💡 Motivation and Context

When the workflow starts on main, it should default to a normal PR against main and not accidentally assume stacked PR behavior.

This change makes that default explicit and still allows stacked mode when the user asks for it.

💚 How did you test it?

  • Ran ./gradlew spotlessApply apiDump successfully (using JDK 17 locally)
  • Verified the updated skill content and git diff

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

  • Use the updated skill in future PR prep flows and refine heuristics if new branch patterns appear.

#skip-changelog

Update the create-java-pr skill to infer standalone vs stacked PR mode\nfrom git branch and existing PR relationships.\n\nWhen running on main/master, default to standalone PR mode and only\nenter stack mode when explicitly requested by the user.\n\nCo-Authored-By: Claude <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 23, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@sentry
Copy link

sentry bot commented Mar 23, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
SDK Size io.sentry.tests.size 8.36.0 (1) release Install Build

@adinauer adinauer marked this pull request as ready for review March 23, 2026 15:23
adinauer and others added 2 commits March 25, 2026 06:38
Check for downstream PRs even when the current branch already has a PR targeting main/master.

This prevents collection branches in a stacked PR flow from being misclassified as standalone PR context.

Co-Authored-By: Claude <[email protected]>
When downstream PRs are found for a branch, classify the result as an existing stack flow instead of an undefined "stack base context".

Clarify that the next PR in an existing stack can target either the previous stack PR branch or the collection branch, so all detection outcomes map to actionable PR types.

Co-Authored-By: Claude <[email protected]>
Comment on lines +39 to +44
- If no PR exists for the current branch, check whether other PRs target it:
```bash
gh pr list --base "$(git branch --show-current)" --json number,headRefName,title
```
If there are downstream PRs, treat this as **next PR in an existing stack** with the current branch as the stack base (collection branch).

Copy link

Choose a reason for hiding this comment

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

Bug: The decision tree for inferring PR type has a missing case for a non-main branch with no existing PR and no downstream PRs, forcing a fallback to user prompting.
Severity: MEDIUM

Suggested Fix

Update the decision tree in SKILL.md to explicitly handle the missing case. When on a non-main branch with no PR and no downstream PRs, the skill should default to treating it as a 'standalone PR context' instead of falling back to asking the user.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: .claude/skills/create-java-pr/SKILL.md#L39-L44

Potential issue: The decision tree in the skill instructions for inferring PR context is
incomplete. It fails to specify an outcome for a common scenario: when the current
branch is not `main` or `master`, has no existing PR, and has no downstream PRs. In this
case, the logic falls back to prompting the user for clarification. This contradicts the
stated goal of the PR, which is to infer context automatically and reduce manual
prompting. The sensible default in this situation would be to assume a 'standalone PR
context', similar to other defined cases.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

```bash
gh pr list --base "$(git branch --show-current)" --json number,headRefName,title
```
If there are downstream PRs, treat this as **next PR in an existing stack** with the current branch as the stack base (collection branch).
Copy link

Choose a reason for hiding this comment

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

Missing decision branch for fresh feature branches

Medium Severity

The decision tree for non-main branches has a missing case: when no PR exists for the current branch and no downstream PRs target it. This is the most common scenario (a fresh feature branch before any PR is created). The "If no PR exists" block only handles the sub-case where downstream PRs exist but never specifies a fallback (e.g., defaulting to standalone PR) when no downstream PRs are found either. The catch-all "mixed or ambiguous" clause at step 3 doesn't naturally apply here since the signals aren't ambiguous — they're just absent.

Fix in Cursor Fix in Web

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.

1 participant