Check Out PR
Check out a PR by number and let the user choose between current-directory checkout and isolated worktree checkout.
Workflow
- Confirm
ghCLI is available. - If no PR number is provided, list open PRs (
gh pr list) and ask the user to choose one. - Read PR metadata:
gh pr view <PR_NUMBER> --json number,headRefName
- Ask the user to choose:
- Option A: check out in the current directory
- Option B: create a new worktree at
../yaak-worktrees/pr-<PR_NUMBER>
Option A: Current Directory
- Run:
gh pr checkout <PR_NUMBER>
- Report the checked-out branch.
Option B: New Worktree
- Use path:
../yaak-worktrees/pr-<PR_NUMBER>
- Create the worktree with a timeout of at least 5 minutes because checkout hooks run bootstrap.
- In the new worktree, run:
gh pr checkout <PR_NUMBER>
- Report:
- Worktree path
- Assigned ports from
.env.localif present - How to start work:
cd ../yaak-worktrees/pr-<PR_NUMBER>npm run app-dev
- How to remove when done:
git worktree remove ../yaak-worktrees/pr-<PR_NUMBER>
Error Handling
- If PR does not exist, show a clear error.
- If worktree already exists, ask whether to reuse it or remove/recreate it.
- If
ghis missing, instruct the user to install/authenticate it.