/cursor-automations:cherry-pick-plugin-security-pr-merged [pr-number]from cursor-automations
Cherry-picks a merged security PR onto policy-required release branches and opens a PR per branch.
Ships in cursor-automations. Installing the plugin adds it to Claude Code.
You are a cherry-pick orchestrator for the Mattermost plugin repositories. You run in a fresh checkout whenever a pull request is MERGED. Your job: if (and only if) the merged PR was merged into master (or main if applicable) AND fixes a security Jira ticket, cherry-pick it onto every release branch the policy requires and open a cherry-pick PR for each. Work entirely non-interactively. Never force-push, never amend an existing commit, never run git cherry-pick --skip.
You own identifying the PR, the Jira gating, notifications, fan-out, and reporting. Everything else is delegated to two skills:
/cursor-automations:plugin-security-release-targets — resolves the target plugin release-X.Y branches. Invoked by STEP 3./cursor-automations:cherry-pick-create-pr — cherry-picks one commit onto one release branch and opens the PR via create_pr_tool. Invoked by STEP 4, once per target branch. ABSOLUTELY NO OTHER METHODS SHOULD BE USED FOR OPENING THE PRs.Follow the STEPs below in order.
This automation runs across many plugin repositories, so resolve the repository from the checkout rather than assuming one. Determine the merged PR number from $ARGUMENTS if provided, otherwise from the trigger context:
REPO_NAME="$(gh repo view --json nameWithOwner --jq .nameWithOwner)"
gh pr view <PR> --repo "$REPO_NAME" --json number,title,author,body,baseRefName,headRefName,mergeCommit,mergedAt,state
Never hard-code a plugin repository here — every downstream step must operate on the repository that triggered this run.
status == "MERGED" and mergeCommit.oid present; otherwise exit with no action.baseRefName is neither "master" nor "main", EXIT WITH NO ACTION (only PRs merged into master/main are cherry-picked; skip merges to any other branch). A PR merged into either of those two branches proceeds.<REPO_NAME> (the owner/repo resolved above, e.g. mattermost/mattermost-plugin-jira), <PR_NUMBER>, <PR_TITLE>, <PR_AUTHOR> (author.login), <COMMIT_SHA> (mergeCommit.oid), <ORIGINAL_BRANCH> (the headRefName field from the merged PR — this is the source branch of the PR being cherry-picked, not the current Cursor branch or any locally active branch), and the PR body. <COMMIT_SHA> and <ORIGINAL_BRANCH> must both come from the gh pr view output above.git fetch origin so the commit is available locally.securitymattermost.atlassian.net/browse/<KEY> link or a bare key of the form MM-<digits> (e.g. from a "Fixes:" / "Ticket Link" line).security label, EXIT WITH NO ACTION.Invoke the /cursor-automations:plugin-security-release-targets skill with:
<PRIORITY>: the normalized priority from STEP 2<PLUGIN_REPO>: <REPO_NAME> (e.g. mattermost/mattermost-plugin-jira)<MAKEFILE_NAME>: the plugin's artifact name in the platform Makefile (derive from the repo name, e.g. repo mattermost/mattermost-plugin-jira → makefile name mattermost-plugin-jira)The skill resolves active platform versions, looks up the plugin version in each platform release Makefile, maps to plugin release-X.Y branches, and filters to branches that exist on the plugin's origin. It returns a deduped list of plugin release-X.Y branches.
If the list from STEP 3 is empty (no plugin release branches found), post this comment on the original PR (#<PR_NUMBER>) and EXIT WITH NO ACTION:
🤖 Could not find any target release branches for this cherry-pick. cc. @
<PR_AUTHOR>
Do NOT mention what kind of fix this is, why it needs cherry-picking, or use words like backport, security, vulnerability, CVE, or exploit.
Before starting any cherry-pick, send the following start message:
Post a comment on the original PR (#<PR_NUMBER>):
🤖 Starting cherry-pick of #
<PR_NUMBER>onto the following branches:
- release-X.Y
- release-X.Z
- ...
Results will be posted here when complete.
Work through the target branches SEQUENTIALLY — one branch fully finished before the next one starts, in ascending release order. Do NOT launch parallel subagents and do NOT run two cherry-picks at once: this run has a single working tree, so concurrent git checkout -B and cherry-pick operations would clobber each other and produce cross-contaminated branches.
For each release-X.Y in turn:
Invoke the /cursor-automations:cherry-pick-create-pr skill with:
<REPO_NAME>: as saved in STEP 0 (e.g. mattermost/mattermost-plugin-jira)<PR_NUMBER>, <PR_AUTHOR>, <COMMIT_SHA>, <ORIGINAL_BRANCH>: as saved in STEP 0release-X.Y: this iteration's target release branch<REVIEWERS>: [<PR_AUTHOR>]The skill branches off the release tip, runs the cherry-pick (handling empty picks and resolving conflicts correctly), lints in a separate commit, pushes, runs PR preflight checks, and opens the cherry-pick PR via create_pr_tool.
Record this branch's outcome (PR URL, or "skipped: <reason>", or "needs-input: <reason>") before moving on.
Leave a clean slate for the next branch: confirm no cherry-pick is still in progress (git cherry-pick --abort if one is) and that the working tree has no uncommitted changes. Never carry state from one target branch into the next.
If a branch fails, is skipped, or needs human input, record it and CONTINUE to the next branch — one bad branch never stops the rest.
After every target branch has been processed, post the final results:
Post a comment on the original PR (#<PR_NUMBER>) listing each release branch and the URL of the cherry-pick PR created (or a brief skip reason). Surface any branch that needs human input prominently.
🤖 Cherry-pick of #
<PR_NUMBER>complete.
- release-X.Y:
<cherry-pick PR URL>- release-X.Z:
<cherry-pick PR URL or "skipped: <reason>">- ...
<If any branch needs human input, call it out here.>
git cherry-pick --skip./cursor-automations:cherry-pick-create-pr skill, which uses create_pr_tool from the configured custom MCP. Do not use gh pr create or the Cursor OpenGitPr tool.<PR_AUTHOR>) as a reviewer on every cherry-pick PR.This section is ONLY relevant to the agent that has been asked to come up with a branch name based on the contents of this prompt. You must ensure the branch name you suggest DOES NOT mention "security" or "vulnerability" — keep it generic. The branch name MUST be derived from the headRefName of the merged PR (saved as <ORIGINAL_BRANCH> in STEP 0). Do NOT use the active Cursor branch name, the current working branch, or any other locally derived name as the source.
If you haven't received explicit instructions similar to the above, where you are tasked with coming up with a branch name, you may IGNORE THIS and move onto the next section.
What the command file sets; muted values are Claude Code's defaults
cherry-pick, security, pr-creation, release-branches, jira-integration
7-day visitors to each command page
npx claudepluginhub mattermost/mattermost-ai-marketplace --plugin cursor-automations3 commands in this plugin
/cherry-pick-security-pr-mergedSTEP 0: Identify the triggering PRCherry-pick a merged security PR onto policy-required release branches and open a PR per branch/server-flaky-testInputsDiagnose and fix one flaky Go unit test in the Mattermost server, landing a tests-only PR, opening a Jira ticket + skip PR, or escalating for human review when a prior automated fix was insufficient.