Auto-detect branch layout from git reflog
Auto-detects branch dependencies from git reflog and creates a machete layout file.
/plugin marketplace add settlemint/agent-marketplace/plugin install crew@settlemintgit/<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>
git_common_dir=$(git rev-parse --git-common-dir 2>/dev/null)
machete_file="${git_common_dir}/machete"
if [[ -f "$machete_file" ]]; then
echo "Existing layout found at $machete_file"
cat "$machete_file"
fi
If layout exists:
AskUserQuestion({
questions: [
{
question: "A machete layout already exists. What to do?",
header: "Existing",
options: [
{
label: "Keep existing",
description: "Don't modify the current layout",
},
{
label: "Re-discover",
description: "Backup existing and create new layout",
},
{ label: "Edit manually", description: "Open editor to modify layout" },
],
multiSelect: false,
},
],
});
# Backup existing layout if present
if [[ -f "$machete_file" ]]; then
cp "$machete_file" "${machete_file}~"
echo "Backed up existing layout to ${machete_file}~"
fi
# Run discovery (suggests layout based on reflog)
git machete discover --list-commits
Discovery shows a preview. Ask user to confirm:
AskUserQuestion({
questions: [
{
question: "Accept the discovered layout?",
header: "Confirm",
options: [
{
label: "Yes (Recommended)",
description: "Accept the discovered layout",
},
{
label: "Edit first",
description: "Open editor to modify before saving",
},
{ label: "Cancel", description: "Don't save, keep previous layout" },
],
multiSelect: false,
},
],
});
If "Yes":
git machete discover --yes
If "Edit first":
git machete discover --yes
git machete edit
If GitHub PRs exist for branches:
# Annotate branches with PR numbers
git machete github anno-prs
echo "=== Discovered Layout ==="
git machete status --list-commits
</process>
<discovery_tips>
How discovery works:
When discovery might be inaccurate:
Manual adjustment:
# Edit layout file directly
git machete edit
# Add a branch to the layout
git machete add <branch> --onto <parent>
# Reorder branches
# Just edit the .git/machete file (indentation = hierarchy)
</discovery_tips>
<success_criteria>
.git/machetegit machete status shows correct tree</success_criteria>
/discoverComprendre le besoin avant développement (Phase 0)
/discoverComprendre le besoin avant développement - Mode AUTO (Phase 0)