Problem
Worktrees created from origin/main drift silently as other branches merge to main. By the time a PR is pushed, the branch may be multiple commits behind, causing:
- Unnecessary merge conflicts at PR time
- CI running against stale base (masking integration issues)
- Manual
git fetch && git rebase before every push
Example: the fix/194-ts-isolated-modules worktree was 1 commit behind origin/main at push time because PR #171 (ESLint 10) merged after branch creation.
Acceptance criteria
Suggested implementation
Option A: mise task worktree:sync (recommended)
Add a mise task that iterates active worktrees and rebases them on origin/main:
# mise.toml
[tasks."worktree:sync"]
description = "Fetch origin/main and rebase all active worktrees"
run = """
git fetch origin main
for wt in $(git worktree list --porcelain | grep '^worktree ' | grep -v '$(git rev-parse --show-toplevel)$' | sed 's/^worktree //'); do
branch=$(git -C "$wt" rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ -z "$(git -C "$wt" status --porcelain)" ]; then
echo "Rebasing $branch in $wt..."
git -C "$wt" rebase origin/main || git -C "$wt" rebase --abort
else
echo "SKIP $branch (dirty working tree)"
fi
done
"""
Option B (optional): SessionStart hook for staleness warning
A Claude Code hook or startup script that checks worktree age and warns:
# Check each worktree's distance from origin/main
for wt in $(git worktree list --porcelain | grep '^worktree ' | sed 's/^worktree //'); do
behind=$(git -C "$wt" rev-list --count HEAD..origin/main 2>/dev/null)
if [ "$behind" -gt 0 ]; then
echo "⚠ $wt is $behind commit(s) behind origin/main"
fi
done
Option C (optional): pre-push rebase
Add to the pre-push hook: if the branch is behind origin/main, auto-rebase before pushing (abort if conflicts).
Labels
enhancement, developer-experience
Problem
Worktrees created from
origin/maindrift silently as other branches merge to main. By the time a PR is pushed, the branch may be multiple commits behind, causing:git fetch && git rebasebefore every pushExample: the
fix/194-ts-isolated-modulesworktree was 1 commit behindorigin/mainat push time because PR #171 (ESLint 10) merged after branch creation.Acceptance criteria
origin/main(enforcegit fetch origin mainbeforegit worktree add)Suggested implementation
Option A: mise task
worktree:sync(recommended)Add a mise task that iterates active worktrees and rebases them on
origin/main:Option B (optional): SessionStart hook for staleness warning
A Claude Code hook or startup script that checks worktree age and warns:
Option C (optional): pre-push rebase
Add to the pre-push hook: if the branch is behind
origin/main, auto-rebase before pushing (abort if conflicts).Labels
enhancement,developer-experience