| name | worktree-first |
| description | Use when starting Git development work; keep main/master pristine by creating a feature worktree from the latest remote branch before editing, committing, pushing, or opening PRs. |
| version | 1.0.0 |
| author | Eric Hansen + Hermes Agent |
| license | MIT |
| metadata | {"hermes":{"tags":["git","worktree","workflow","portability"],"related_skills":["github-pr-workflow","gh-body-safe"]}} |
Worktree-First Git Workflow
Overview
Default to git worktrees for development. The primary checkout stays clean on main or master; feature work happens in a sibling directory on a feature branch.
When to Use
Use before editing code in any Git repo when:
- currently on
main or master
- starting a feature/fix/refactor branch
- preparing work that may become a PR
- you need to keep the main checkout pristine
Workflow
git status --short
git branch --show-current
git fetch origin
Determine default branch:
default_branch="$(git remote show origin 2>/dev/null | sed -n 's/.*HEAD branch: //p')"
default_branch="${default_branch:-main}"
Create a sibling worktree:
repo_name="$(basename "$(git rev-parse --show-toplevel)")"
branch="fix/short-description"
worktree_dir="../${repo_name}-${branch//\//-}"
git worktree add "$worktree_dir" -b "$branch" "origin/$default_branch"
cd "$worktree_dir"
Rules
- Never edit or commit directly on
main or master.
- Commit locally by default.
- Push/open PR only when explicitly requested.
- Before pushing, show a reviewable diff/stat summary and ask for confirmation.
- If git/gh operations fail unexpectedly, check
gh auth status for account mismatch.
Verification Checklist