一键导入
cherry-pick
// Cherry-pick a commit from origin/main into a release branch using a temporary git worktree
// Cherry-pick a commit from origin/main into a release branch using a temporary git worktree
Use when reviewing AIPerf code for the SEMANTIC qualities that mechanical linters cannot catch — error-message informativeness, type-hint descriptiveness, docstring example usefulness, naming disambiguation, convention explicitness, comment density, and reference-file exemplariness. Invoke after mechanical checks (`make check-ergonomics`, `make check-ruff-baselined`) are green, before shipping a branch or PR. Explicitly out of scope are correctness bugs, style (tabs/quotes), preferences, and anything the guardrails already catch.
Review the current branch against origin/main, capture findings in artifacts/code-review.md as a living document, validate every finding against the actual code, reproduce confirmed issues with the aiperf CLI against the in-repo mock server, and draft inline GitHub PR review comments anchored to specific files and lines. Use when the user asks for a branch or PR code review.
Migrate a plain Markdown docs/ folder to a Fern documentation site from scratch. Use this skill when a project has no existing publishing framework and needs to scaffold Fern config, migrate content, and build navigation.
| name | cherry-pick |
| description | Cherry-pick a commit from origin/main into a release branch using a temporary git worktree |
| disable-model-invocation | true |
| allowed-tools | Bash(git fetch *), Bash(git log *), Bash(git branch *), Bash(git worktree *), Bash(git cherry-pick *), Bash(git -C * status), Bash(git -C * cherry-pick *), Bash(git -C * checkout *), Bash(git -C * push *), Bash(git -C * branch *), Bash(git push *), Bash(git commit *), Bash(git checkout *), Bash(mktemp *), Bash(make *), Bash(gh pr create *), Bash(gh api *), AskUserQuestion |
Cherry-pick a commit from origin/main into a release branch using a temporary git worktree.
Before starting, check if there is an existing cherry-pick worktree from a previous run:
git worktree list | grep cherry-pick/
If there is a worktree on a cherry-pick/* branch, a previous cherry-pick may have stopped due to conflicts. Ask the user if they want to resume it. If yes:
WORKTREE_DIR to the existing worktree path.git -C "$WORKTREE_DIR" status
git -C "$WORKTREE_DIR" cherry-pick --continue to finalize.cherry-pick/<source-sha>-to-<release-branch>):
BRANCH=$(git -C "$WORKTREE_DIR" branch --show-current)
SOURCE_SHA=${BRANCH#cherry-pick/}
SOURCE_SHA=${SOURCE_SHA%-to-*}
Do NOT use the worktree's HEAD SHA — that's the new cherry-pick commit, not the original. Then run step 4 with $SOURCE_SHA to gather the original PR metadata.If the user does not want to resume, clean up the stale worktree first, then start fresh.
Fetch latest from origin:
git fetch origin
Show recent commits on origin/main:
Run git log origin/main --oneline -20 to get the list.
Ask the user which commit to cherry-pick:
Use AskUserQuestion to present the recent commits as options. Let the user select one.
Look up the original PR for the selected commit:
gh pr view does not accept a commit SHA, so query the commits→pulls API directly:
gh api repos/ai-dynamo/aiperf/commits/<source-commit-sha>/pulls \
--jq '.[0] | "\(.number)\t\(.title)"'
Save the PR number and title for use in steps 11 and 13. If the commit message contains a PR number (e.g. (#669)), you can also use that directly.
Find all release branches:
Run git branch -r --list 'origin/release/*' to get all remote release branches matching release/X.X.X.
Ask the user which release branch to target:
Use AskUserQuestion to present the release branches as options. The most recent version (highest semver) should be the first option marked as "(Recommended)".
Create a temporary worktree on a feature branch:
Release branches are protected, so work on a cherry-pick/ feature branch from the start.
This also makes the worktree identifiable for resume if conflicts occur.
WORKTREE_DIR=$(mktemp -d)
git worktree add "$WORKTREE_DIR" origin/<release-branch>
git -C "$WORKTREE_DIR" checkout -b cherry-pick/<commit-hash>-to-<release-branch>
Set up the environment in the worktree (required for pre-commit hooks):
make -C "$WORKTREE_DIR" first-time-setup
Cherry-pick the commit:
git -C "$WORKTREE_DIR" cherry-pick <commit-hash>
If there are conflicts:
$WORKTREE_DIRgit -C "$WORKTREE_DIR" cherry-pick --continuecherry-pick --continue), use git commit -s with a HEREDOC message./cherry-pick to resume (it will detect the existing worktree).Push the feature branch:
git -C "$WORKTREE_DIR" push -u origin HEAD
Create PR (optional — requires gh CLI):
If gh is available and authenticated, create the PR automatically:
gh pr create \
--repo ai-dynamo/aiperf \
--head cherry-pick/<commit-hash>-to-<release-branch> \
--base <release-branch> \
--label cherry-pick \
--title "<original commit title> (cherry-pick to <release-branch>)" \
--body "$(cat <<'EOF'
## Summary
- Cherry-pick of <commit-hash> from `main` into `<release-branch>`
- Original PR: #<original-pr-number> — <original commit title>
## Conflicts
<If conflicts were resolved, list the files and briefly describe the resolution. Otherwise write "None — clean cherry-pick.">
EOF
)"
If gh is not set up or the command fails, skip this step and tell the user to create the PR manually at:
https://github.com/ai-dynamo/aiperf/compare/<release-branch>...cherry-pick/<commit-hash>-to-<release-branch>
Clean up the worktree:
git worktree remove "$WORKTREE_DIR"
Print a summary. Output the following (NOT inside a code block):
Cherry-pick complete: <commit-hash-short> → <release-branch>
PR Main: :git-merged: https://github.com/ai-dynamo/aiperf/pull/ PR Release: :pr-opened: https://github.com/ai-dynamo/aiperf/pull/
If step 11 was skipped (no PR created), omit the PR Release line and instead print the manual comparison URL from step 11's fallback.
Co-Authored-By lineSigned-off-by line — git commit -s handles this automaticallygit commit -s with a HEREDOC message--no-verifygit stash, git reset, git revert, git checkout -- <file>, git restore, or git clean