agentleFS
luabaggluabagg/agent-skills/skills/branch-port/SKILL.md

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.

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
  1. Distinctive:

    Use this skill for long-lived divergence, major target refactors, or features that mix code the target still needs with code the target has …

    line 17
  2. Very specific:

    Never run git checkout <source-branch> -- <file>.

    line 21
  3. Very specific:

    Never run git diff <source> | git apply across diverged branches.

    line 22
  4. Distinctive:

    If a conflict is ambiguous, stop and ask.

    line 24
  5. Distinctive:

    Verify schema and migration changes against the target's schema state.

    line 25
  6. Distinctive:

    If Phase 5 discovery invalidates the Port Plan, stop and re-plan.

    line 26
  7. Very specific:

    Do not mark failing ported tests @skip or xfail to get green.

    line 27
  8. Distinctive:

    Keep the port as one reviewable commit or a small focused series.

    line 28
  9. Distinctive:

    Ask the user only for missing information (source, target, scope).

    line 38
  10. Distinctive:

    Write a plan that covers:

    line 79
  11. Distinctive:

    Commit grouping of the source (core, tests, config, migrations, fixups)

    line 81
  12. Distinctive:

    Wait for user confirmation before you write code.

    line 89
  13. Distinctive:

    If discovery here invalidates Phase 4, stop and re-plan with the user.

    line 97
  14. Distinctive:

    Run the feature's tests on the target.

    line 101
  15. Very specific:

    If preserving the original author matters for your team, see references/git-commands.md for --author= and Co-Authored-By: patterns.

    line 114

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 apply across 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 @skip or xfail to 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 matter

For 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 touches

For 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-diff findings (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 diff

Walk 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.