Skip to content
Development
Skill

/merge-tracks

Manually merge parallel development tracks. Debug/Expert command - track merging normally happens automatically via /devteam:implement.

From plugin
michael-harris-devteam
1820 skills128 agents20 commands13 hooks
+1
Install
$ npx -y skills add michael-harris/devteam --skill merge-tracks --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/merge-tracks

Context preview

The summary Claude sees to decide when to auto-load this skill.

Manually merge parallel development tracks. Debug/Expert command - track merging normally happens automatically via /devteam:implement.

SKILL.md

merge-tracks.SKILL.md
name: merge-tracks
description: Manually merge parallel development tracks. Debug/Expert command - track merging normally happens automatically via /devteam:implement.
argument-hint: [--manual-merge] [--keep-worktrees] [--delete-branches] [--dry-run]
user-invocable: true
allowed-tools: Read, Glob, Grep, Bash, Task
model: opus

Current session: !`source "${CLAUDE_PLUGIN_ROOT}/scripts/state.sh" && get_current_session 2>/dev/null || echo "No active session"` Active sprint: !`source "${CLAUDE_PLUGIN_ROOT}/scripts/state.sh" && get_kv_state "active_sprint" 2>/dev/null || echo "None"` Failure count: !`source "${CLAUDE_PLUGIN_ROOT}/scripts/state.sh" && get_kv_state "consecutive_failures" 2>/dev/null || echo "0"`

Merge Tracks Command

**Debug/Expert Command** - Manually merge parallel development tracks.

> **Note:** This command is rarely needed. Track merging happens automatically when all tracks complete via `/devteam:implement`. Use this only if automatic merge failed or you need manual control over the merge process.

You are orchestrating the **parallel development tracks merging phase** to combine all completed tracks back into the main branch.

Command Usage

/devteam:merge-tracks                      # Merge all tracks, create PR, cleanup worktrees (default)
/devteam:merge-tracks --manual-merge       # Merge all tracks, skip PR, cleanup worktrees
/devteam:merge-tracks --keep-worktrees     # Merge, create PR, keep worktrees
/devteam:merge-tracks --delete-branches    # Merge, create PR, cleanup worktrees & branches
/devteam:merge-tracks --dry-run            # Show what would be merged without doing it

**Flags:**

  • `--manual-merge`: Skip automatic PR creation after merge, allow manual PR creation
  • `--keep-worktrees`: Keep worktrees after merge (default: delete)
  • `--delete-branches`: Delete track branches after merge (default: keep)
  • `--dry-run`: Preview merge plan without executing

Prerequisites

This command only works for projects planned with git worktrees (`--use-worktrees` flag).

**Pre-flight checks:** 1. SQLite state database must exist with worktree mode enabled 2. All tracks must be complete (all sprints in all tracks marked "completed") 3. No uncommitted changes in any worktree 4. All worktrees should have pushed to remote (optional but recommended)

Your Process

Step 0: Parse Parameters

Extract flags from command:

  • `--manual-merge`: Skip PR creation after merge (default: false)
  • `--keep-worktrees`: Do not delete worktrees after merge (default: false)
  • `--delete-branches`: Delete track branches after merge (default: false)
  • `--dry-run`: Show merge plan without executing (default: false)

Step 1: Load State and Validate

1. **Load state from SQLite** (`.devteam/devteam.db` via `source "${CLAUDE_PLUGIN_ROOT}/scripts/state.sh"`)

2. **Verify worktree mode:**

   if state.parallel_tracks.mode != "worktrees":
       error("This project was not planned with worktrees. Nothing to merge.")
       suggest("/devteam:implement --sprint all  # All work already in main branch")
       exit(1)

3. **Verify all tracks complete:**

   incomplete_tracks = []
   for track_id, track_info in state.parallel_tracks.track_info.items():
       track_sprints = filter(s for s in state.sprints if s.track == track_id)
       if any(sprint.status != "completed" for sprint in track_sprints):
           incomplete_tracks.append(track_id)

   if incomplete_tracks:
       error(f"Cannot merge: Tracks {incomplete_tracks} not complete")
       suggest(f"/devteam:implement --sprint all {incomplete_tracks[0]:02d}  # Complete remaining tracks")
       exit(1)

4. **Check for uncommitted changes:**

   for track in tracks:
       cd $worktree_path
       if [ -n "$(git status --porcelain)" ]; then
           error("Uncommitted changes in $worktree_path")
           suggest("Commit or stash changes before merging")
           exit(1)
       fi

5. **Check remote push status (warning only):**

   for track in tracks:
       cd $worktree_path
       if git status | grep "Your branch is ahead"; then
           warn("Track $track has unpushed commits - recommend pushing for backup")
       fi

Step 2: Create Pre-Merge Backup

**Safety measure:**

# Return to main directory
cd $MAIN_REPO

# Create backup tag
git tag pre-merge-backup-$(date +%Y%m%d-%H%M%S)

echo "Created backup tag: pre-merge-backup-YYYYMMDD-HHMMSS"
echo "  (To restore: git reset --hard <tag-name>)"

Step 3: Show Merge Plan (Dry-Run)

If `--dry-run` flag:

Merge Plan

Tracks to merge: 3
- Track 1 (dev-track-01): 7 commits, 15 files changed
- Track 2 (dev-track-02): 5 commits, 12 files changed
- Track 3 (dev-track-03): 4 commits, 8 files changed

Merge strategy: Sequential merge (track-01 -> track-02 -> track-03)
Target branch: main (or current branch)

Potential conflicts: 2 files
- src/config.yaml (modified in tracks 01 and 02)
- package.json (modified in tracks 01 and 03)

After merge:
- Delete worktrees: YES (default)
- Delete branches: NO (use --delete-branches to enable)

To proceed with merge:
/devteam:merge-tracks

Exit without merging.

Step 4: Launch Track Merger Agent

If not dry-run, launch the **track-merger** agent:

Task(
  subagent_type="orchestration:track-merger",
  model="opus",
  description="Merge all development tracks intelligently",
  prompt=`Merge all development tracks back to main branch.

State database: .devteam/devteam.db (via source "${CLAUDE_PLUGIN_ROOT}/scripts/state.sh")

Your responsibilities:
1. Verify all pre-flight checks passed
2. Ensure we're on the correct base branch (main or specified)
3. Merge each track branch sequentially:
   - Track 1: dev-track-01
   - Track 2: dev-track-02
   - Track 3: dev-track-03
4. Handle merge conflicts intelligently (use context from PRD and tasks)
5. Run integration tests after each merge
6. Create merge commit messages tha
Read more
Ships withmichael-harris-devteam

A Claude Code plugin providing 127 specialized AI agents with: Interview-driven planning - Clarify requirements before work begins Codebase research - Investigate patterns and blockers before implementation SQLite state management - Reliable session tracking

Get the whole plugin

Other skills on michael-harris-devteam.