branch-port
Skill3 starsChanged 3 months agoMITView on GitHub
Use when a feature must move between branches that have diverged too far for rebase or merge to be practical.
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agentfolio-operatorSkill
- code-commentsSkill
- code-namingSkill
- cognitive-refactorSkill
- memory-palaceSkill
- natural-copy-editingSkill
- testing-business-rulesSkill
- thorough-pr-reviewSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 11 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Use this skill for long-lived divergence, major target refactors, or features that mix code the target still needs with code the target has …
- Very specific: line 21
Never run git checkout <source-branch> -- <file>.
- Very specific: line 22
Never run git diff <source> | git apply across diverged branches.
- Distinctive: line 24
If a conflict is ambiguous, stop and ask.
- Distinctive: line 25
Verify schema and migration changes against the target's schema state.
- Distinctive: line 26
If Phase 5 discovery invalidates the Port Plan, stop and re-plan.
- Very specific: line 27
Do not mark failing ported tests @skip or xfail to get green.
- Distinctive: line 28
Keep the port as one reviewable commit or a small focused series.
- Distinctive: line 38
Ask the user only for missing information (source, target, scope).
- Distinctive: line 79
Write a plan that covers:
- Distinctive: line 81
Commit grouping of the source (core, tests, config, migrations, fixups)
- Distinctive: line 89
Wait for user confirmation before you write code.
- Distinctive: line 97
If discovery here invalidates Phase 4, stop and re-plan with the user.
- Distinctive: line 101
Run the feature's tests on the target.
- Very specific: line 114
If preserving the original author matters for your team, see references/git-commands.md for --author= and Co-Authored-By: patterns.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Branch Port
Port a feature from a source branch to a target branch when rebase or merge will not apply cleanly. Understand the feature first, then re-implement it. Never paste source files over the target.
When NOT to use
git cherry-pick <sha>applies cleanly: do that.- Rebase has a few conflicts: resolve them. Do not re-architect.
- The branches share a recent ancestor (hours or days): use a plain merge.
- The feature is one or two commits: cherry-pick each.
Use this skill for long-lived divergence, major target refactors, or features that mix code the target still needs with code the target has made obsolete.
Rules (read first)
- Never run
git checkout <source-branch> -- <file>. It discards the target's evolution. - Never run
git diff <source> | git applyacross diverged branches. - Halt at Phase 4 (Port Plan). Wait for user confirmation before you write code.
- If a conflict is ambiguous, stop and ask.
- Verify schema and migration changes against the target's schema state.
- If Phase 5 discovery invalidates the Port Plan, stop and re-plan. Do not push through a broken plan.
- Do not mark failing ported tests
@skiporxfailto get green. Rewrite them for target conventions or report the failure to the user. - Keep the port as one reviewable commit or a small focused series.
Phase 1: Context
git fetch --all --prune
export BASE=$(git merge-base <source> <target>)
git log --oneline "$BASE"..<source>Ask the user only for missing information (source, target, scope). If the trigger message provided it, skip the question.
Detect overlap. Has any part of the feature already reached the target?
git range-diff "$BASE"..<source> "$BASE"..<target>Read the output:
=: identical patch on target. Skip.!: similar but different patch on target. Inspect manually. It could be a partial backport, a whitespace tweak, or a different implementation. Do not skip it blind.-: only on source. Port.+: only on target. Not relevant to the port.
Phase 2: Understand the feature
git diff --stat "$BASE" <source> # prioritize by surface area
git diff "$BASE" <source> -- <path> # drill into files that matterFor each significant file, read its final source state. If it went through major rewrites mid-feature, read its evolution too (commands in references/git-commands.md).
Inventory the non-code parts: dependencies, env vars, API contracts, migrations. All of these go in the Port Plan.
Phase 3: Analyze the target
Find what the target changed since the fork:
git log --oneline "$BASE"..<target>
git show <target>:<path> # for each file the feature touchesFor each touched file, decide: Does it still exist? Was the surrounding code restructured? Are there target-only utilities the ported code should use? Which target conventions (naming, module layout, framework idioms) apply?
Diff the project's dependency manifest between branches to find drift: missing packages, version conflicts, renames.
Phase 4: Port Plan (halt)
Write a plan that covers:
- Commit grouping of the source (core, tests, config, migrations, fixups)
range-difffindings (what to skip, what to inspect)- Files to create and files to modify, with the adaptation for each
- Dependencies, config and env, migrations
- Open questions and risks
Template and a filled example: references/port-plan-template.md.
Wait for user confirmation before you write code. A wrong answer mid-port costs hours.
Phase 5: Re-implement
Order: manifest, new files, modified shared files, config and env, tests, docs.
For each modified file: read the target's current version first. Apply the feature's logic into it. Follow the target's conventions. Run the project's typecheck, build, and lint between major groups. Stop and fix on failure.
If discovery here invalidates Phase 4, stop and re-plan with the user.
Phase 6: Verify
Run the feature's tests on the target. Adapt them where target conventions require it. Do not skip them to get green.
Review the full port surface:
git diff --stat origin/<target>...HEAD # summary
git diff origin/<target>...HEAD # full diffWalk the diff with the user. Name what needs manual smoke-testing: the feature's primary behavior plus the regression surface in files the port touched.
Authorship
If preserving the original author matters for your team, see references/git-commands.md for --author= and Co-Authored-By: patterns.
References
references/port-plan-template.md: Port Plan template and worked example.references/git-commands.md: git commands used across phases.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

