fix(skill): Detect stacked PR context from branch#5223
fix(skill): Detect stacked PR context from branch#5223
Conversation
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]>
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
Sentry Build Distribution
|
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]>
| - 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). | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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). |
There was a problem hiding this comment.
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.


📜 Description
Improve the local
create-java-prskill 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 againstmainand 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?
./gradlew spotlessApply apiDumpsuccessfully (using JDK 17 locally)📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
#skip-changelog