diff --git a/.claude/skills/worktree-update/SKILL.md b/.claude/skills/worktree-update/SKILL.md new file mode 100644 index 000000000..0dcea4479 --- /dev/null +++ b/.claude/skills/worktree-update/SKILL.md @@ -0,0 +1,109 @@ +--- +name: worktree-update +description: > + Sync worktree branches with main. Use when the user says "update worktrees", + "sync branches", "merge main", "worktree update", or invokes /worktree-update. + When on main: shows which worktree branches are ahead and lets the user pick + which to merge into main (flags branches with open PRs). When on a non-main + branch: merges main into the current branch. All operations are non-destructive. +user-invocable: true +allowed-tools: Bash, Read, AskUserQuestion +--- + +# Worktree Update Skill + +Sync worktree branches safely. Direction depends on the current branch. + +## Safety Rules (NON-NEGOTIABLE) + +- **Never force-push, reset --hard, rebase, or delete branches.** +- **Never use `--no-verify` or skip hooks.** +- **Always use `--no-edit` on merges** to avoid interactive editor prompts. +- **Stop on merge conflicts** — report them and let the user decide. Never + auto-resolve or abort a conflicted merge without asking. +- **Fetch before comparing** — always `git fetch --all` first so commit + comparisons are accurate. +- **Dry-run first on main** — show the user exactly what will happen before + merging anything into main. + +## Workflow + +### 1. Detect current branch + +```bash +git branch --show-current +``` + +Branch determines the mode: `main` → outbound sync, anything else → inbound sync. + +### 2a. On `main` — merge worktree branches into main + +#### Fetch and compare + +```bash +git fetch --all +``` + +For each worktree branch, check if it has commits ahead of main: + +```bash +git rev-list --count main.. +``` + +Skip branches with 0 commits ahead. For branches that ARE ahead, collect: +- Branch name +- Number of commits ahead +- One-line log of those commits: `git log --oneline main..` + +#### Check for open PRs + +```bash +tea pr list --login schweitz --repo jpmschweitzer/settled-reach --state open --output simple +``` + +Cross-reference open PR head branches with the ahead-of-main branches. + +#### Present results + +Show a summary table of branches ahead of main. For each branch, indicate: +- `[PR]` if it has an open pull request — warn that it should go through + normal review channels (use `/review-pr` instead) +- Commit count and summary + +Use `AskUserQuestion` to let the user pick which branches to merge. +Exclude PR-flagged branches from the default options (but allow the user to +override via "Other"). + +#### Merge selected branches + +For each selected branch, one at a time: + +```bash +git merge --no-edit +``` + +If a merge conflicts, **stop immediately**. Report the conflict and do NOT +continue to the next branch. The user must resolve before proceeding. + +After all merges, show the final state with `git log --oneline -N` (where N +covers the new commits). + +### 2b. Not on `main` — merge main into current branch + +```bash +git fetch --all +git merge origin/main --no-edit +``` + +If clean, report the result (fast-forward or merge commit, files changed). +If conflicts, report them and stop. + +### 3. Push prompt + +After a successful merge, ask the user if they want to push: + +```bash +git push origin +``` + +Never push without explicit confirmation. diff --git a/CHANGELOG.md b/CHANGELOG.md index fd7e8a3fc..11b22169d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Format based on [Keep a Changelog](https://keepachangelog.com/). - Ticketing database updated with new backlog items and status changes ### Added +- Worktree-update skill — non-destructive branch sync with PR detection and conflict safety - Inigo sound designer agent — soundscape design, ambient layers, diegetic cues, D-018 audio propagation - Team-agent mapping in sprint planning — each team has defined default agents for briefing assignment - Sprint skills recognize all team branches (server, client, copy, audio, visual, ci)