chore: add tracked .git-wt/pr-hook so wt <pr> launches a Claude review (#11383)

@zkochan/git-wt 0.0.3 looks for an executable .git-wt/pr-hook in the
worktree before falling back to ~/.config/git-wt/pr-hook. Shipping the
hook in-repo gives every contributor with Claude Code installed an
auto-launched PR review via `wt <pr-number>`. The hook silently no-ops
when `claude` isn't on PATH so contributors who don't use it aren't
affected.
This commit is contained in:
Zoltan Kochan
2026-04-29 00:36:03 +02:00
parent f9afe81eed
commit 2d061b74a6
2 changed files with 20 additions and 0 deletions

14
.git-wt/pr-hook Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
# Invoked by @zkochan/git-wt's `wt` shell function after `wt <pr-number>`
# creates a worktree and cds into it. Silently no-ops for contributors who
# don't have claude installed.
command -v claude >/dev/null 2>&1 || exit 0
exec claude --dangerously-skip-permissions "Review and fix PR #$PR_NUMBER. Steps:
1. Use gh to read the PR description, diff, and all review comments (both PR-level and inline).
2. Understand the intent of the PR and what each change does.
3. Resolve any conflicts with the base branch by running './shell/resolve-pr-conflicts.sh $PR_NUMBER'. This force-fetches the base branch (avoiding stale refs), rebases, and auto-resolves lockfile conflicts. If it prints MANUAL_RESOLUTION_NEEDED, read the listed conflicted files, resolve the conflict markers, run 'git add' on each resolved file, then run './shell/resolve-pr-conflicts.sh $PR_NUMBER --continue' to finish the rebase and push. Do NOT skip this step. Do NOT assume the branch is up to date.
4. Address every review comment — fix the code as requested or as appropriate.
5. Look for any other bugs, issues, or style problems in the changed code and fix those too.
6. Run the relevant tests to verify your fixes work (check CLAUDE.md for how to run tests).
7. Give me a summary of what you found and what you changed, including any conflicts you resolved.
Do NOT push. Leave all non-merge changes unstaged for me to review."

View File

@@ -81,6 +81,12 @@ Passing a number is interpreted as a PR number. The PR is fetched via
`git fetch origin pull/<number>/head` into a local branch named `pr-<number>`, so it works
for both same-repo branches and forks.
If [Claude Code](https://www.anthropic.com/claude-code) is installed on your system, `wt
<pr-number>` will additionally launch a Claude review of the PR via the tracked hook at
`.git-wt/pr-hook`. The hook silently no-ops if `claude` isn't on your `PATH`, so contributors
who don't use Claude aren't affected. Requires `@zkochan/git-wt` ≥ 0.0.3, which is the
version that introduced the per-repo hook lookup.
If you only need the worktree path (e.g. to open it in an editor) without switching directories,
run the underlying script directly: