$npx -y skills add Undertone0809/rudder --skill pr-local-preview-maintainerUse when checking out, running, previewing, reviewing, or validating a GitHub pull request locally in a safe worktree, including PR preview URLs, local screenshots, readiness checks, logs, and cleanup instructions.
| 1 | # PR Local Preview Maintainer |
| 2 | |
| 3 | Run pull requests in a disposable local worktree and give the user a stable |
| 4 | preview link. The point is to let the user review the PR while protecting their |
| 5 | current working tree and making UI changes visible. |
| 6 | |
| 7 | ## Default Workflow |
| 8 | |
| 9 | ### 1. Preserve the current workspace |
| 10 | |
| 11 | Start by checking the repository state: |
| 12 | |
| 13 | ```bash |
| 14 | git status --short --branch |
| 15 | gh pr view <number> --json number,title,state,headRefName,headRepositoryOwner,url,isCrossRepository |
| 16 | ``` |
| 17 | |
| 18 | If the current worktree has local changes, do not run `gh pr checkout` there. |
| 19 | Create or reuse a sibling worktree instead. This avoids overwriting unrelated |
| 20 | work and keeps the PR preview easy to remove later. |
| 21 | |
| 22 | Use a predictable path: |
| 23 | |
| 24 | ```text |
| 25 | <repo-parent>/<repo-name>-pr-<number> |
| 26 | ``` |
| 27 | |
| 28 | For this repository, PR 8 should become: |
| 29 | |
| 30 | ```text |
| 31 | /Users/zeeland/projects/rudder-oss-pr-8 |
| 32 | ``` |
| 33 | |
| 34 | If the directory already exists, inspect it before reusing it: |
| 35 | |
| 36 | ```bash |
| 37 | git -C <worktree-path> status --short --branch |
| 38 | git -C <worktree-path> branch --show-current |
| 39 | ``` |
| 40 | |
| 41 | If it is dirty, ask only if the dirty changes conflict with the user's goal. |
| 42 | Otherwise, pick a suffixed path such as `<repo-name>-pr-<number>-preview`. |
| 43 | |
| 44 | ### 2. Check out the PR in the worktree |
| 45 | |
| 46 | Create the worktree from the remote base, then check out the PR branch inside it: |
| 47 | |
| 48 | ```bash |
| 49 | git worktree add --detach <worktree-path> origin/main |
| 50 | gh pr checkout <number> --branch zeelandc/pr-<number> |
| 51 | ``` |
| 52 | |
| 53 | If `main` is not the base branch, use the PR's actual base ref. Prefer a local |
| 54 | branch name that makes the preview purpose clear and follows the user's branch |
| 55 | prefix convention when the repository defines one. |
| 56 | |
| 57 | After checkout, verify: |
| 58 | |
| 59 | ```bash |
| 60 | git status --short --branch |
| 61 | ``` |
| 62 | |
| 63 | ### 3. Install dependencies only when needed |
| 64 | |
| 65 | Check whether dependencies are present: |
| 66 | |
| 67 | ```bash |
| 68 | test -d node_modules && echo node_modules-present || echo node_modules-missing |
| 69 | ``` |
| 70 | |
| 71 | If missing, install them from the worktree: |
| 72 | |
| 73 | ```bash |
| 74 | pnpm install |
| 75 | ``` |
| 76 | |
| 77 | Report install warnings only when they affect the preview. Routine peer or bin |
| 78 | link warnings can be mentioned briefly. |
| 79 | |
| 80 | ### 4. Choose isolated runtime settings |
| 81 | |
| 82 | Before starting, inspect occupied ports and existing local runtimes: |
| 83 | |
| 84 | ```bash |
| 85 | lsof -nP -iTCP:<candidate-port> -sTCP:LISTEN |
| 86 | ``` |
| 87 | |
| 88 | For Rudder, prefer: |
| 89 | |
| 90 | ```bash |
| 91 | RUDDER_INSTANCE_ID=pr-<number> |
| 92 | PORT=<free-api-port> |
| 93 | RUDDER_EMBEDDED_POSTGRES_PORT=<free-pg-port> |
| 94 | ``` |
| 95 | |
| 96 | Use `3100` only if it is free and the user clearly wants the default instance. |
| 97 | If another Rudder dev runtime is already running, leave it alone and use a |
| 98 | separate port and instance ID. |
| 99 | |
| 100 | Example: |
| 101 | |
| 102 | ```bash |
| 103 | env RUDDER_INSTANCE_ID=pr-8 PORT=3118 RUDDER_EMBEDDED_POSTGRES_PORT=54358 pnpm dev |
| 104 | ``` |
| 105 | |
| 106 | ### 5. Start the preview so it survives hand-off |
| 107 | |
| 108 | Use `tmux` when available. It keeps the preview alive after the assistant turn |
| 109 | ends and gives the user a simple way to inspect logs. |
| 110 | |
| 111 | ```bash |
| 112 | tmux new-session -d -s rudder-pr-<number> -c <worktree-path> \ |
| 113 | 'env RUDDER_INSTANCE_ID=pr-<number> PORT=<port> RUDDER_EMBEDDED_POSTGRES_PORT=<pg-port> pnpm dev' |
| 114 | ``` |
| 115 | |
| 116 | If `tmux` is not available, use another managed background process and capture |
| 117 | logs to `/tmp/<repo-name>-pr-<number>.log`. Do not leave an opaque process |
| 118 | running without telling the user how to stop it. |
| 119 | |
| 120 | ### 6. Wait for readiness |
| 121 | |
| 122 | Poll the health endpoint or the app's equivalent readiness check: |
| 123 | |
| 124 | ```bash |
| 125 | curl -fsS http://127.0.0.1:<port>/api/health |
| 126 | ``` |
| 127 | |
| 128 | If the app has no health endpoint, use the first meaningful route and check for |
| 129 | a successful response. For frontend-only apps, load the dev server URL and |
| 130 | confirm it serves HTML. |
| 131 | |
| 132 | When startup fails, inspect the session logs before returning: |
| 133 | |
| 134 | ```bash |
| 135 | tmux capture-pane -pt rudder-pr-<number> -S -160 |
| 136 | ``` |
| 137 | |
| 138 | Fix straightforward startup issues yourself when they are local environment |
| 139 | problems, such as missing dependencies or port conflicts. Do not edit PR source |
| 140 | code unless the user asked for a fix. |
| 141 | |
| 142 | ### 7. Decide whether UI screenshots are required |
| 143 | |
| 144 | Screenshots are required when any of these are true: |
| 145 | |
| 146 | - the PR title, files, or user request mentions UI, layout, pages, components, |
| 147 | CSS, design, screenshots, visual review, browser behavior, or interaction |
| 148 | - changed files live under `ui/`, `desktop/`, frontend route files, component |
| 149 | directories, stylesheets, or public assets |
| 150 | - the user says they want to "see" the effect |
| 151 | |
| 152 | Use Browser Use for local browser inspection when available. Capture the |
| 153 | important screen or flow after the preview is running. Store temporary |
| 154 | screenshots outside the repository, for example: |
| 155 | |
| 156 | ```text |
| 157 | /tmp/rudder-pr-<number>-<view>.png |
| 158 | ``` |
| 159 | |
| 160 | For non-UI backend/API PRs, a health check plus a task-specific API smoke check |
| 161 | is usually enough. If the user still needs to review manually, provide the URL. |
| 162 | |
| 163 | ### 8. Han |