Merge

From julianobarbosa/claude-code-skills · View interactive version

Merge is an AI agent skill from the GitHub repository julianobarbosa/claude-code-skills. Merge the current feature branch into main and (optionally) clean up the branch and worktree. Prefers fast-forward (--ff-only) for linear history; falls back to a merge commit (--no-ff) when the branch has diverged or the user wants the merge commit preserved. Interactive cleanup at the end. USE WHE

How to use this skill

Skill file

Merge

Combine merge-and-cleanup and merge-to-main into one flow. Default to fast-forward; preserve a merge commit when fast-forward isn't possible or the user asks for one. Always interactive about deleting branches and worktrees.

Flow

  1. Refuse if already on main. If git rev-parse --abbrev-ref HEAD returns main (or master), stop and report — there's nothing to merge.
  2. Working tree must be clean. If there are uncommitted changes, ask the user whether to commit, stash, or abort. Do not silently stash.
  3. Capture the feature branch name — FEATURE=$(git rev-parse --abbrev-ref HEAD).
  4. Sync main.
  1. Try fast-forward merge first.
  1. Fall back to merge commit — git merge --no-ff "$FEATURE".
  1. Push — git push origin main.
  2. Interactive cleanup. Ask the user: "Delete $FEATURE (local + remote) and any associated worktree?"
  1. Report final status — commit hash on main, whether branch was deleted, whether a worktree was removed.

Notes

Gotchas

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.