Navigate to branches in the machete stack
Navigates between branches in the git machete stack using directional commands.
/plugin marketplace add settlemint/agent-marketplace/plugin install crew@settlemint[up | down | next | prev | root | first | last]git/<worktree_status>
!${CLAUDE_PLUGIN_ROOT}/scripts/git/worktree-context.sh 2>&1
</worktree_status>
<stack_context>
!${CLAUDE_PLUGIN_ROOT}/scripts/git/machete-context.sh 2>&1
</stack_context>
| Direction | Meaning |
|---|---|
up | Parent branch |
down | First child branch |
next | Next sibling (same level, next in order) |
prev | Previous sibling (same level, prev in order) |
root | Root of current branch's tree |
first | First branch in the entire layout |
last | Last branch in the entire layout |
If no argument provided:
AskUserQuestion({
questions: [
{
question: "Which direction to navigate?",
header: "Navigate",
options: [
{ label: "Up", description: "Go to parent branch" },
{ label: "Down", description: "Go to first child branch" },
{ label: "Next", description: "Go to next sibling" },
{ label: "Prev", description: "Go to previous sibling" },
],
multiSelect: false,
},
],
});
direction="${1:-up}" # default to up
# Show what branch we'll navigate to
target=$(git machete show "$direction" 2>/dev/null || echo "")
if [[ -z "$target" ]]; then
echo "No branch in direction '$direction' from current branch"
git machete status
exit 1
fi
echo "Will checkout: $target"
Check <worktree_status> for WORKTREE_MACHETE_SAFE status:
If safe pattern (single stack): Proceed normally - navigation within the stack is fine.
If unsafe pattern (multi-stack layout):
AskUserQuestion({
questions: [
{
question: `Target branch "${target}" may be outside this worktree's stack. Continue?`,
header: "Worktree",
options: [
{
label: "Continue anyway",
description: "Switch branches (know what you're doing)",
},
{
label: "Show main checkout path",
description: "Navigate in main checkout instead",
},
{
label: "Create worktree",
description: "Create a new worktree for the target branch",
},
{ label: "Cancel", description: "Stay on current branch" },
],
multiSelect: false,
},
],
});
If "Create worktree":
# Create worktree for target branch
git worktree add "../$(basename $(pwd))-${target}" "$target"
echo "Created worktree at: ../$(basename $(pwd))-${target}"
echo "cd there to continue work on $target"
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "You have uncommitted changes"
git status --short
fi
If uncommitted changes:
AskUserQuestion({
questions: [
{
question: "You have uncommitted changes. What to do?",
header: "Changes",
options: [
{ label: "Stash", description: "Stash changes and switch" },
{ label: "Commit", description: "Commit changes first" },
{ label: "Discard", description: "Discard changes and switch" },
{ label: "Cancel", description: "Stay on current branch" },
],
multiSelect: false,
},
],
});
If "Stash":
git stash push -m "Auto-stash before go $direction"
If "Commit":
Skill({ skill: "crew:git:commit" });
git machete go "$direction"
Or directly:
git checkout "$target"
echo "=== Now on: $(git branch --show-current) ==="
git machete status
</process>
<interactive_mode>
On Unix terminals, git machete go supports interactive mode:
git machete go # Without argument
Controls:
Note: Interactive mode not available on Windows.
</interactive_mode>
<navigation_examples>
Navigate through a stack:
main
feature-base ← git machete go down (from main)
feature-1 ← git machete go down (from feature-base)
feature-2 ← git machete go next (from feature-1)
hotfix ← git machete go next (from feature-base)
Common patterns:
# Go to parent to check its state
git machete go up
# Go to child to continue work
git machete go down
# Cycle through siblings
git machete go next
git machete go next
# Jump to root of current tree
git machete go root
</navigation_examples>
<success_criteria>
</success_criteria>
/goStart autonomous execution loop (Ralph Wiggum pattern). Simple, powerful iteration until task complete. Activates for go, ship it, autonomous mode, keep working, iterate.
/goWORKFLOW COMMAND - Execute TodoWrite FIRST, then Preflight → Phase 1 → 2 → 3. Do NOT read ~/.claude/plans/ until after TodoWrite.