Add current or specified branch to the machete stack
/plugin marketplace add settlemint/agent-marketplace/plugin install crew@settlemint[branch-name] [--onto parent]git/<stack_context>
!${CLAUDE_PLUGIN_ROOT}/scripts/git/machete-context.sh
</stack_context>
branch="${1:-$(git branch --show-current)}"
echo "Adding branch: $branch"
if git machete is-managed "$branch" 2>/dev/null; then
echo "Branch '$branch' is already in the machete layout"
git machete status
exit 0
fi
If no layout exists:
AskUserQuestion({
questions: [
{
question: "No machete layout found. How to initialize?",
header: "Layout",
options: [
{
label: "Discover (Recommended)",
description: "Auto-detect all branches from history",
},
{
label: "Start with this branch",
description: "Create layout with just this branch",
},
],
multiSelect: false,
},
],
});
If "Discover":
Skill({ skill: "crew:git:discover" });
If "Start with this branch":
echo "main" > .git/machete
echo " $branch" >> .git/machete
Get available parent options from machete context or open PRs:
AskUserQuestion({
questions: [
{
question: `Which branch should '${branch}' be stacked on?`,
header: "Parent",
options: [
{ label: "main", description: "Stack directly on main branch" },
// Dynamic options from open PRs or existing layout branches
// { label: "feature-base", description: "PR #123: Auth improvements" },
],
multiSelect: false,
},
],
});
git machete add "$branch" --onto "$parent"
AskUserQuestion({
questions: [
{
question: "Add any qualifiers to this branch?",
header: "Qualifiers",
options: [
{ label: "None", description: "Standard behavior" },
{
label: "rebase=no push=no",
description: "Not my branch, skip rebase/push",
},
{ label: "slide-out=no", description: "Never auto-slide-out" },
],
multiSelect: false,
},
],
});
If qualifiers selected:
git machete anno "$branch" "$qualifiers"
echo "=== Branch added to stack ==="
git machete status --list-commits
</process>
<qualifiers_reference>
| Qualifier | Effect | When to Use |
|---|---|---|
rebase=no | Skip rebase during traverse | Branch you don't own |
push=no | Skip push during traverse | Branch you don't own |
slide-out=no | Don't auto-slide-out when merged | Branch that should stay in layout |
Combining qualifiers:
git machete anno feature-x "PR #123 rebase=no push=no"
Removing qualifiers:
git machete anno feature-x ""
# Or keep just PR annotation:
git machete anno feature-x "PR #123"
</qualifiers_reference>
<stacking_strategies>
Linear stack:
main
feature-part-1
feature-part-2
feature-part-3
Fan-out from main:
main
feature-a
feature-b
feature-c
Mixed:
main
feature-base
feature-part-1
feature-part-2
hotfix
</stacking_strategies>
<after_adding>
After adding a branch to the stack:
Skill({ skill: "crew:git:pr" })Skill({ skill: "crew:git:traverse" })Skill({ skill: "crew:git:stack-status" })</after_adding>
<success_criteria>
</success_criteria>