Skip to content

About

One shot cherry pick instantly

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Remote Cherry-Pick Skill

Create a cherry-pick pull request entirely via the GitHub REST API — no local branch changes, no git checkout, no git pull, no temp clones.

Setup

Run install.sh from your project directory or anywhere to setup for user level or project level setup.

What It Does

Given a PR number, this skill:

  1. Auto-detects the repository from the local git remote (origin), parsing both HTTPS and SSH URL formats to extract owner/repo. If no git remote is found, it asks the user to provide the repository.
  2. Disables the gh pager (GH_PAGER=cat) so all commands run non-interactively — no need to press q to dismiss output.
  3. Fetches the PR's title, body, assignee(s), head branch name, base branch, and commit list
  4. Auto-detects direction based on the source PR's base branch:
    • If base is master/main → cherry-pick to the production branch
    • If base starts with production/ → cherry-pick to master
  5. For each commit, applies it to the target branch as a real 3-way merge via the GitHub Merge API — not a whole-file copy, so previously-diverged target content survives and genuine conflicts stop the run
  6. Creates a remote branch named <original_branch>_cherry
  7. Creates a new PR with:
    • Base: target branch (production or master)
    • Title: 🍒 <original_PR_title>
    • Body: Copied from the original PR
    • Assignee: Same as the original PR

No local repository changes occur at any point. All orchestration lives in scripts/cherry_pick.py, run non-interactively — see Architecture.

Usage

Basic Invocation

Create production cherry pick for 1111

If the direction is master → production, the skill will ask which production branch to target:

Which production branch should I cherry-pick to? (e.g., 1.0)

With Explicit Production Branch

Create production cherry pick for 1111 to 1.0

The skill normalizes the branch name:

  • 1.0 → production/1.0
  • production/1.0 → production/1.0 (used as-is)

Reverse Direction (production → master)

If the source PR's base branch is production/1.0, the skill automatically cherry-picks to master — no production branch prompt needed.

Example

User: Create production cherry pick for 1111 to 1.0

Skill:
0. Detects repo from git remote → owner/repo
1. Fetches PR #1111 → baseRefName: "master" → target: production/1.0
2. Gets commit f58e68d... → modifies README.md
3. Gets production/1.0 HEAD → 856cff9... → tree: 3bf4d4c...
4. Creates new tree with blob c920af9... at the file path (via Git Data API)
5. Creates commit on top of 856cff9... (via Git Data API)
6. Creates remote branch production-update_cherry (via Git Data API)
7. Creates PR: 🍒 [CRASH]... → production/1.0, assigned to user

Result: New PR created at https://github.example.com/owner/repo/pull/XXXXX

Prerequisites

  • gh CLI installed and authenticated (gh auth login)
  • Push access to the repository
  • No clean working tree required — the skill never touches the local repo
  • Git remote — the skill auto-detects owner/repo from git remote get-url origin. If no remote is found, it will ask the user to provide the repository.

How It Works (Technical)

Architecture

SKILL.md only covers what the agent needs to decide (target branch, how to read a result) and how to invoke the script — matching Anthropic's Skill guidance of keeping SKILL.md itself short and pushing deterministic work into bundled scripts, whose code never enters the model's context, only their output does.

File Loaded when
SKILL.md Every time the skill triggers
scripts/cherry_pick.py Never read — only executed; its output is what enters context
references/ALGORITHM.md Only if someone asks how the merge itself works

How it differs from git cherry-pick

It doesn't, anymore, in the ways that matter: each commit is applied as a real 3-way merge (GitHub Merge API, with the same conflict detection git cherry-pick has locally), not a whole-file blob copy. See references/ALGORITHM.md for the mechanics.

Non-interactive output

All gh commands run with GH_PAGER=cat (set in Step 0) so output is never piped through a pager like less. This ensures commands complete without requiring the user to press q.

Compatibility

This skill works with:

Agent How to Use
Claude (Claude Code) Reference .claude/skills/remote-cherry-pick/SKILL.md and follow the steps
Codex (OpenAI) Reference .claude/skills/remote-cherry-pick/SKILL.md and follow the steps
Cline SR Say "Create production cherry pick for <PR_number>" — the skill auto-activates
GitHub Copilot Reference .claude/skills/remote-cherry-pick/SKILL.md in your prompt

For Claude Code

Read .claude/skills/remote-cherry-pick/SKILL.md and execute the workflow for PR #<PR_number>

For Codex

Follow the instructions in .claude/skills/remote-cherry-pick/SKILL.md to create a cherry-pick PR for PR #<PR_number>

Error Handling

Scenario Action
Branch already exists Ask user to delete or rename
Target branch not found Verify branch name via API
Not authenticated Remind user to run gh auth login
No git remote detected Ask user to provide owner/repo
API rate limited Retry with backoff

Files

File Description
SKILL.md Trigger conditions and how to run/read the script
scripts/cherry_pick.py All API orchestration — the actual cherry-pick engine
references/ALGORITHM.md How the merge-based cherry-pick works, endpoints, known limitations
README.md This file

Comparison: git cherry-pick vs remote-cherry-pick

Feature git cherry-pick remote-cherry-pick
Local branch changes Yes (checkout, pull, cherry-pick) No — fully remote
Temp clone No No
Conflict resolution Yes (manual via git cherry-pick) Yes — real 3-way merge via GitHub's Merge API, genuine conflicts reported and left for manual resolution
GHES compatibility Yes (uses local git) Yes (uses Git Data API)
Direction detection No (hardcoded to production) Yes (auto-detect)
Production branch prompt No (hardcoded) Yes (asks user)
Repo auto-detection No Yes (from git remote)
Non-interactive output No Yes (GH_PAGER=cat)
Multi-commit support Yes Yes

Recommendation: Use remote-cherry-pick for most scenarios. Use git cherry-pick when you need manual conflict resolution.

About

One shot cherry pick instantly

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages