Git branch management with stacked PRs using git-machete. Simplifies rebase workflows, branch synchronization, and GitHub/GitLab integration. Triggers on stacked, machete, branch stack, dependent branches.
Manage stacked PR workflows with git-machete. Triggers on "stacked", "machete", "branch stack", or "dependent branches" to set up branch hierarchies, automate rebasing, and create GitHub/GitLab PRs.
/plugin marketplace add settlemint/agent-marketplace/plugin install devtools@settlemintThis skill inherits all available tools. When active, it can use any tool Claude has access to.
scripts/install.shworkflows/cleanup.mdworkflows/setup-stack.mdworkflows/stacked-prs.mdworkflows/sync-branches.md<essential_principles> Branch Layout is the Source of Truth
The machete file defines parent-child relationships between branches. Indentation represents hierarchy:
main
feature-base
feature-part-1
feature-part-2
another-feature
Worktree Support
In worktrees, the machete file is in the main repo's .git directory, not the worktree:
# Get the correct machete file path (works in worktrees too)
machete_file="$(git rev-parse --git-common-dir)/machete"
Status Colors Indicate Sync State
Rebase Over Merge for Stacks
Always use rebase (not merge) when syncing stacked branches. Merging creates tangled history that's hard to untangle.
Merge Order: Top to Bottom
Merge PRs from top-most (closest to main) first. This prevents big-ball-of-code PRs at the end of the stack. </essential_principles>
<constraints>NEVER use shell redirects to edit the machete file. The following patterns WILL FAIL:
# WRONG - these will fail in various shells
cat > .git/machete << 'EOF'
echo "..." > .git/machete
printf '...' >| /path/machete
ALWAYS use the Write tool or git machete edit:
# Correct: Use git machete commands
git machete discover # Auto-detect layout
git machete edit # Opens in editor
git machete add --onto main # Add branch to layout
# Or use the Write tool with the correct path
machete_file="$(git rev-parse --git-common-dir)/machete"
# Then use Write tool, not shell redirects
</constraints>
<quick_start> Setup a new stack:
# Discover existing branches
git machete discover
# Or manually edit layout
git machete edit
# Check current state
git machete status --list-commits
Daily workflow:
# Sync all branches with parents and remotes
git machete traverse -W -y
# Create PR using parent from layout as base
git machete github create-pr
# After PR merged, remove branch and rebase children
git machete slide-out --delete
Navigation:
git machete go down # Child branch
git machete go up # Parent branch
git machete go # Interactive selection
</quick_start>
<intake> Use the **AskUserQuestion tool** to determine the task:AskUserQuestion:
header: "Task"
question: "What do you need help with?"
options:
- label: "Setup stacked branches"
description: "Initialize git-machete and define branch layout"
- label: "Sync branches"
description: "Rebase and push branches to sync with parents"
- label: "Create stacked PRs"
description: "Create GitHub/GitLab PRs for branch stack"
- label: "Clean up merged branches"
description: "Remove merged branches and reconnect children"
- label: "Install git-machete"
description: "Install and configure shell completions"
multiSelect: false
</intake>
<routing>
| Response | Workflow |
|----------|----------|
| 1, "setup", "initialize", "layout" | `workflows/setup-stack.md` |
| 2, "sync", "rebase", "update" | `workflows/sync-branches.md` |
| 3, "pr", "pull request", "create" | `workflows/stacked-prs.md` |
| 4, "clean", "merged", "slide-out" | `workflows/cleanup.md` |
| 5, "install", "setup tool" | Execute `scripts/install.sh` |
| other | Clarify, then select |
After reading the workflow, follow it exactly. </routing>
<commands_reference> Layout Management:
git machete discover — Auto-detect branch layout from commit historygit machete edit — Open .git/machete in editorgit machete add [branch] [--onto parent] — Add branch to layoutgit machete status [-l] — Show branch tree with sync statusSynchronization:
git machete update — Rebase current branch onto parentgit machete traverse — Walk through branches, syncing eachgit machete traverse -W -y — Fetch, sync all, auto-confirmNavigation:
git machete go up/down/prev/next — Move between branchesgit machete go — Interactive branch selectionGitHub/GitLab:
git machete github create-pr [--draft] — Create PR with parent as basegit machete github checkout-prs --mine — Checkout your PRsgit machete github retarget-pr — Update PR base to match layoutgit machete github anno-prs — Add PR numbers to statusCleanup:
git machete slide-out [branch] — Remove branch, reconnect childrengit machete advance — Fast-forward merge child into current
</commands_reference><fork_point> Understanding Fork Point
Git-machete tracks where each branch diverged from its parent. This ensures only unique commits are rebased, avoiding duplicate commits.
# Check fork point
git machete fork-point [branch]
# Override if detection fails
git machete update --fork-point <commit>
Best Practice: Don't immediately delete merged branches — their reflogs help determine fork points for other branches. </fork_point>
<workflows_index>
| Workflow | Purpose |
|---|---|
| setup-stack.md | Initialize git-machete and define branch hierarchy |
| sync-branches.md | Rebase and push all branches in stack |
| stacked-prs.md | Create and manage GitHub/GitLab PRs for stack |
| cleanup.md | Remove merged branches and slide out from stack |
| </workflows_index> |
<success_criteria>
.git/machete file defines correct branch hierarchygit machete status shows expected branch relationshipstraverseThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.