---
name: merge
description: Merge a worktree branch into main - handle conflicts, run full checks, auto-fix issues
title: merge
canonical_url: https://skilld.dev/gh/sandharbor/meadow/merge
last_updated: 2026-10-08T17:30:29.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install sandharbor/meadow/merge`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/merge`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/sandharbor/meadow/merge) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/merge`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/merge --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/merge --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Merge Worktree Branch into Main

Follow these steps to merge a parallel-development worktree branch back into main.

## Step 1: Preflight checks

1. Ensure we are not already on main
2. Ensure all changes are already committed.  If not, you can automatically commit them

## Step 2: Merge the branch to main

### If the merge succeeds with no conflicts

Proceed to Step 3.

### If there are merge conflicts

1. Run `git diff --name-only --diff-filter=U` to list conflicted files.
2. Tell the user which files have conflicts.
3. For each conflicted file:
   - Read the file to understand the conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`)
   - Analyze both sides of each conflict and resolve it intelligently, preserving the intent of both changes where possible
   - Edit the file to remove all conflict markers with the correct resolution
4. After resolving all files, stage them: `git add <resolved files>`
5. Complete the merge: `git commit --no-edit`
6. Tell the user what resolutions were made.

## Step 3: Rebuild native utilities if changed

After merging, check if the merged branch touched any native utility source code.
Use the merge commit's two parents to see what the branch changed:

```bash
git diff HEAD^1 HEAD --name-only -- app/runtime/native/
```

If any files under `app/runtime/native/` were changed, recompile the Rust binaries
by running `./prepare` from the repo root. This is critical because worktree
builds don't carry over to main — the release binaries in `target/release/`
are local to each worktree checkout.

```bash
./prepare
```

If no native utility files were changed, skip this step.

## Step 4: Run the checks

Run the check suite from the repo root:

```bash
./quickcheck
```

Then run the end-to-end test suite using the "e2e" skill.

### If checks pass

Proceed to Step 5.

### If checks fail

1. Read the check output carefully to identify what failed.
2. Investigate the failing code — read the relevant files and understand the issue.
3. Fix the problem.
4. Stage the fix and commit it with the prefix `merge fix:` in the commit message. For example:
   ```
   merge fix: update import paths after merge
   ```
5. Run `./quickcheck --full` again.
6. If it still fails, repeat this fix cycle up to 3 times. If checks still fail after 3 attempts, **stop** and tell the user:
   > "Checks are still failing after 3 fix attempts. Manual intervention needed."
   Show the remaining failure output so the user can debug.

## Step 5: Summary

Print a summary:

- Branch that was merged
- Whether there were conflicts (and how they were resolved)
- Whether any post-merge fixes were needed (list the fix commits)
- Final check status
- Remind the user they can delete the worktree branch if it's no longer needed:
  ```
  git branch -d <branch>
  git worktree remove <path>  # if the worktree directory still exists
  ```
