MCPInstall

local-merge

Use when landing a branch onto a target branch requires a safe local-git merge path that avoids mutating active worktrees directly, such as /ship, /reflect, or autonomous-mode integration work.

Installs
351
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/camacho/ai-skills --skill local-merge
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads local-merge automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

/local-merge

Land a source branch onto a target branch through a disposable shallow clone, then update the PRIMARY worktree only if that worktree is already on the target branch.

Default target is main.

Inputs

InputRequiredDefaultExample
BRANCHyes—feat/local-merge-skill
TARGETnomaindevelop, release/v2
PRIMARYnoprimary worktree path/Users/you/projects/repo
MESSAGEnomerge: $BRANCH into $TARGETmerge: feat/auth into main

Operating model

Treat this as two separate problems:

  1. Remote integration: merge the source branch into the target branch inside a disposable shallow clone, then push the updated target branch.
  2. Local propagation: if PRIMARY is already on the target branch, update that worktree safely.

Do not assume that a successful remote integration means local propagation is also safe.

Core invariants

  • Use local git only for merge and publish operations.
  • Prefer a disposable shallow clone as the integration workspace.
  • Never discard tracked local state.
  • Never silently choose merge versus rebase when a checked-out local target branch has local-only commits.
  • Fast-forward automatically only when the local target is simply behind and otherwise cleanly updateable.
  • Conflict means stop and return control to the user.
  • Never force-push.
  • Use absolute paths and git -C <abs-path> for state-changing commands.
  • Validate refs before constructing shell commands.

Primary resolution

Use the repo's primary worktree as PRIMARY.

If the primary worktree path is ambiguous, stop and ask the user instead of guessing from incidental ordering.

Tracked-state shelter

When this skill needs to preserve tracked local changes before mutating a checked-out target branch, use one recipe consistently:

  • stage tracked changes only
  • create a temporary WIP commit
  • record the temporary commit ref before continuing
  • perform the branch update
  • restore the exact tracked state with a soft reset of that temporary commit

Do not silently include untracked files in this sheltering step.

Phase 1 — Remote integration

1. Resolve state

Determine:

  • repo root
  • source branch
  • target branch
  • remote name
  • primary worktree path
  • whether PRIMARY is currently on the target branch

Validate:

  • source and target are valid branch refs
  • the remote refs for both branches exist

Stop if:

  • the source branch is detached
  • the source branch is not published and cannot be pushed cleanly

If the source branch is unpublished but can be pushed cleanly, push it first and continue. The source branch must be published before remote integration begins.

If the source worktree has tracked local changes that are not represented in the published branch, stop. local-merge integrates published branch state only; it does not shelter or merge source-side dirty state as part of Phase 1.

2. Build the integration workspace

Create a disposable shallow clone from the repo's remote URL.

Fetch only what is needed:

  • <remote>/$TARGET
  • <remote>/$BRANCH

Ensure the clone has enough history to merge and, if needed, retry safely. If shallow history is insufficient, deepen deliberately or stop and report the limitation.

3. Merge source into target

Check out the target branch in the shallow clone and merge the source branch into it.

Default to a normal merge. If the merge is already a fast-forward, accept it.

If there is a conflict:

  • stop immediately
  • surface the conflict clearly
  • do not auto-resolve
  • do not continue to push

4. Push target

Push the updated target branch from the shallow clone.

If the push is rejected because the remote moved, one retry strategy is allowed:

  • refresh the target branch in the shallow clone
  • rebuild the integration commit or rebase only inside the disposable clone
  • retry only if the refreshed state does not introduce a new human-choice point

Stop immediately if the retry itself conflicts or becomes ambiguous.

Maximum retries: 3. Never force-push.

Cleanup failure for the disposable clone is non-blocking.

Phase 2 — Local propagation

Only run this phase if PRIMARY is already on the target branch.

If PRIMARY is on some other branch, report that remote integration succeeded and leave local propagation untouched.

1. Inspect local target state

Gather enough evidence to classify the local target state:

  • whether the worktree has tracked local changes
  • whether local $TARGET is behind <remote>/$TARGET
  • whether local $TARGET has commits not on <remote>/$TARGET
  • whether the branch is fast-forwardable or diverged
  • whether incoming and local-only changes overlap in a way that is operationally risky even if git would merge cleanly

Use standard git evidence:

  • status
  • ahead and behind counts
  • incoming commit log
  • local-only commit log
  • diff stat

2. Update local target branch

Case: clean and only behind

Fast-forward automatically to <remote>/$TARGET.

Case: tracked local changes and only behind

Use the tracked-state shelter, fast-forward to <remote>/$TARGET, then restore the sheltered tracked state.

Case: local target has commits not on <remote>/$TARGET

Do not silently rewrite or merge.

Ask the user whether to:

  • rebase local commits onto the updated remote target
  • merge the updated remote target into the local target

If tracked local changes are also present, use the tracked-state shelter before that operation and restore it afterward.

Once the user chooses merge or rebase, the agent may execute that choice. If the chosen operation conflicts, stop immediately, preserve the shelter reference if one exists, and return control to the user.

This is an intentional policy tightening from the current skill. Even if a low-risk auto-merge might be possible, this version treats any local-only target commits as a human-choice point.

Case: semantic risk or ambiguity

If git says a merge is possible but the overlapping area is operationally risky, stop and escalate instead of treating "no textual conflict" as "safe."

Examples:

  • related config spread across files
  • hooks and supporting scripts changed in parallel
  • command contract changes that may invalidate local assumptions

Finish

Report:

  • whether remote integration succeeded
  • whether local propagation ran
  • whether the local target was fast-forwarded, escalated, or left untouched
  • whether tracked state was sheltered
  • any user decision still required

Safety rules

  • No force-push
  • No hard reset unless explicitly directed
  • No silent conflict resolution
  • No silent merge-versus-rebase choice for divergent local target branches
  • Preserve human state over automation

Output format

Source branch: <branch>
Target branch: <target>
Remote: <remote>

Remote integration:
- source branch published: yes/no
- shallow clone merge: clean/conflict
- target pushed: yes/no

Local propagation:
- primary on target: yes/no
- tracked state shelter used: yes/no
- result: fast-forward / user decision required / conflict / skipped

If action is required:
- reason
- exact worktree or branch involved
- whether tracked state is currently sheltered

FAQ

What does the local-merge skill do?

Use when landing a branch onto a target branch requires a safe local-git merge path that avoids mutating active worktrees directly, such as /ship, /reflect, or autonomous-mode integration work.

How do I install local-merge?

Run npx skills add https://github.com/camacho/ai-skills --skill local-merge in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/local-merge/ (personal) or .claude/skills/local-merge/ (project).

Which AI agents can use local-merge?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is local-merge safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains local-merge?

It is published by camacho in camacho/ai-skills. It has 351 recorded installs.

More from camacho/ai-skills

View all →

archive

camacho/ai-skills

Fills Outcomes & Learnings in a plan file and renames it to .done.md.

bail

camacho/ai-skills

Reflects, updates GitHub Issue, closes PR if open, cleans up worktree/branch.

capture

camacho/ai-skills

Creates a draft GitHub Issue with triage label from natural language description.

669 installs

plan-review

camacho/ai-skills

Auto-assembles review panel using deterministic rules, dispatches agents against plan file, collects verdicts.

orient

camacho/ai-skills

Fetches issue context, auto-detects task type, maps to branch prefix, presents brief.

reflect

camacho/ai-skills

Use after merging a branch or completing a task to consolidate learnings into memory layers, close out issues, and verify the phase gate.

Popular code quality & workflow skills

View category →

grill-me

mattpocock/skills

A relentless interview to sharpen a plan or design.

Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

handoff

mattpocock/skills

Compact the current conversation into a handoff document for another agent to pick up.

domain-modeling

mattpocock/skills

Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.

codebase-design

mattpocock/skills

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

diagnosing-bugs

mattpocock/skills

Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.