diff --git a/.claude/skills/git-workflow/SKILL.md b/.claude/skills/git-workflow/SKILL.md index 387faf5..97aa80e 100644 --- a/.claude/skills/git-workflow/SKILL.md +++ b/.claude/skills/git-workflow/SKILL.md @@ -46,6 +46,7 @@ mise run git:sync # Sync current branch after base PR merge 4. Push -> git push -u origin feature/your-feature 5. PR -> gh pr create -a "@me" -t "feat: ..." 6. Open -> mise run git:open-pr (CI wait -> browser -> merge watch -> cleanup) + ⚠ Run ONCE after final push. If CI fails, stop watcher -> fix -> push -> relaunch. 7. Cleanup -> (auto: merge detected -> git:cleanup runs) ``` @@ -59,11 +60,17 @@ Claude: [Bash(run_in_background=true)] mise run git:open-pr -- 3 phases run automatically: 1. **CI wait** — `gh pr checks --watch` waits for CI to pass -2. **Open in browser** — Opens PR page in default browser +2. **Open in browser** — Uses `scripts/open-url.local.sh` if present (gitignored), else default browser 3. **Merge watch** — Polls PR state every 30s - MERGED -> macOS notification + `mise run git:cleanup` -> exit - CLOSED -> message -> exit +**Singleton rule — only ONE watcher per PR:** +- `git:open-pr` must run **only once** per PR — after the final push, when no more changes are expected. +- If CI fails and you need to push a fix: **stop the existing watcher** with `TaskStop` first, fix and push, then launch a new `git:open-pr`. +- Never have multiple `git:open-pr` background tasks running for the same PR. +- Use `--no-wait` to skip CI wait phase when you just want the merge watcher. + **Claude behavior**: When background task output arrives via ``, Claude MUST: 1. Read the output file with `TaskOutput` or `Read` 2. Report the result to the user immediately diff --git a/.gitignore b/.gitignore index da20dc3..ee7aeb7 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,9 @@ Cargo.lock .gemini/ .codex/ +# Local hooks (user-specific, not committed) +scripts/*.local.sh + /tmp/ OUTPUT.md crates/agtrace-sdk/examples/debug/ diff --git a/tasks.toml b/tasks.toml index a961d76..fdc13f5 100644 --- a/tasks.toml +++ b/tasks.toml @@ -155,8 +155,14 @@ if [[ "$WAIT_CI" == true && -n "$PR_NUMBER" ]]; then fi # Phase 2: Open in browser +# Use local hook if available (gitignored), otherwise default browser echo "[git:open-pr] Phase 2/3: Opening PR in browser..." -gh pr view "$PR_NUMBER" --web +OPEN_HOOK="./scripts/open-url.local.sh" +if [[ -x "$OPEN_HOOK" ]]; then + "$OPEN_HOOK" "$URL" +else + gh pr view "$PR_NUMBER" --web +fi # Phase 3: Watch for merge if [[ -n "$PR_NUMBER" ]]; then