ai/skills/worktree-merge-to-main/SKILL.md
Merge the current worktree branch into main and sync main back. Use when the user says "merge to main", "ship it", "merge and continue", or after completing a task in a worktree and wanting to continue with the next one.
npx skillsauth add kurko/dotfiles worktree-merge-to-mainInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Merge the current worktree branch into main, sync main back, and reset the environment so the user can continue working on a new task in the same worktree.
git rev-parse --is-inside-work-tree # must be true
git worktree list # identify main worktree path
git branch --show-current # current branch name
git status --porcelain # must be empty
Extract the main worktree path from git worktree list (the first entry
in the output is always the main worktree).
Extract the current branch name for the merge command.
If the working tree is dirty, stop and ask the user what to do.
Use git -C to operate on the main worktree without leaving the current
directory. This is an intentional exception to the "avoid git -C" guideline —
the agent must operate on a different worktree than the current directory.
git -C <main_worktree_path> merge <current_branch_name>
If the merge has conflicts:
git -C or absolute paths to read/edit them).git -C <main_worktree_path> add -A
git -C <main_worktree_path> commit --no-edit
This brings the worktree branch up to date with main (including any other work that landed on main since the branch diverged).
git merge main
If this produces conflicts, resolve them in the current worktree (normal workflow since the files are local).
Handle stashed changes: if the working tree had unstaged changes from dependency files (yarn.lock, Gemfile.lock) that conflict, resolve by accepting the merged version and re-running the setup step.
If bin/setup-worktree exists, run it to:
if [ -f bin/setup-worktree ]; then
bin/setup-worktree
fi
Report what happened:
bin/setup-worktree ran| Scenario | Action |
|----------|--------|
| Dirty working tree | Ask user: commit, stash, or abort |
| Merge conflicts (into main) | Resolve using git -C on the main worktree |
| Merge conflicts (main into worktree) | Resolve locally in the worktree |
| bin/setup-worktree fails | Show the error output, suggest manual intervention |
| Not in a worktree | Abort with message: "This command is for worktrees only" |
tools
Synchronize AI agent skills, commands, configs, permissions, hooks, and instructions across Claude Code, Codex CLI, and other Agent Skills-compatible tools. Use when the user asks to pull skills from Claude into Codex, sync Codex work back to Claude, migrate agent commands, reconcile frontmatter, update permissions, or keep agent setup files in parity.
testing
Write or update UI-independent use cases for QA. Use when the user says "write use cases", "add use cases", "QA use cases", "update use cases", "compose use cases", or when starting implementation of a new feature (after plan approval). Also activates for "what should we test", "regression cases", or "use cases for QA".
documentation
Skill on how to write a task. Use when user asks you to write a task (for Asana, Linear, Jira, Notion and equivalent). Also activates when user says "create task", "write task", or similar task creation workflow requests.
development
Set up git worktree database isolation for a project. Use when adding worktree support, parallel branch development, or worktree database setup. Investigates the project's database config and env loading, then creates bin/setup-worktree and bin/teardown-worktree scripts with per-branch database names.