git-sync-trunk

Merge trunk_claude* worktree branches into trunk and sync with origin.

1|Updated Jan 19, 2026
One-click install
npx skills add https://github.com/saxonthune/carta --skill git-sync-trunk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-sync-trunk
Source: https://github.com/saxonthune/carta/tree/main/.claude/skills/git-sync-trunk
Command: npx skills add https://github.com/saxonthune/carta --skill git-sync-trunk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the problem of consolidating ongoing work from multiple worktree branches back into the trunk branch so the codebase and documentation workspace stay synchronized.

Core Features & Use Cases

  • Safely merges worktree branches into trunk: Automatically finds branches following the naming pattern trunk_claude* and merges only those with commits ahead of trunk.
  • Optionally syncs with the remote trunk: Pulls from origin/trunk when the remote is behind the local trunk, keeping histories aligned.
  • Guides conflict resolution: Halts on merge conflicts and provides clear steps to resolve them externally, then supports resuming the resolved merge.

Quick Start

Run bash .claude/skills/git-sync-trunk/sync.sh from the trunk branch to merge all relevant worktree branches and sync trunk with the remote when configured.

Frequently Asked Questions about git-sync-trunk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I merge worktree branches back into the trunk branch?

To merge worktree branches into trunk, run the sync script from the trunk branch. It automatically finds branches matching the trunk_claude* naming pattern and merges only those with commits ahead of trunk into the main branch.

Can I automatically pull origin/trunk when my local trunk branch is behind?

Yes, you can pull origin/trunk when the remote is behind. The sync process optionally syncs the local trunk with the configured remote, keeping your repository histories aligned automatically after merging worktrees.

What happens when there are merge conflicts during a trunk sync?

When merge conflicts occur during a trunk sync, the process halts immediately. It provides clear external steps to resolve the conflicts and supports resuming the resolved merge afterwards without losing your worktree changes.

Does git trunk syncing work with branches that have no _claude suffix?

Git trunk syncing requires running on a trunk branch without a _claude suffix. It targets trunk_claude* branches specifically, detecting which worktree branches have commits ahead of trunk before performing the merge.

When do I need to consolidate worktree branches before starting new work?

You need to consolidate worktree branches when AI agents or contributors create commit-bearing branches that require their changes merged into trunk. This synchronization ensures the codebase stays aligned before initializing new worktrees.

What are the limitations of automating worktree branch merges into trunk?

Limitations include halting on merge conflicts for manual resolution, requiring the script to run from the trunk branch, and only processing branches following the trunk_claude* naming convention with ahead-of-trunk detection.