SLOPSHOPPER

pr-view

A pane listing the project root repository's open pull requests with titles; click one to open it in the browser.

panecommandprocesstimer
★ 12v0.1.0no licenseupdated 2026-10-23ushironoko/dotfiles/claude/.claude/skills/pr-view
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · pr-view
│ ┃ Pull Requests ✕ › fix the failing auth test and add an audit log call │ ┃ Open PRs 0 ↻ refresh │ ┃ filter : title, #number, branch or @author ⏺ Read(src/auth.ts) │ ┃ JSON Parse error: Unexpected EOF ⎿ Read 6 lines │ ⏺ Update(src/auth.ts) │ ⎿ Added 2 lines, removed 1 line │ ⏺ Bash(bun test) │ ⎿ 3 pass, 1 fail │ │ ● Done. refresh now rejects expired claims and logs an audit event. │ │ ✻ Worked for 42s · done 4:20 PM │ │ › /prs │ ⎿ pr-view: Pull requests pane shown. │ │ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Pane · Pull Requests
Open PRs 0 ↻ refresh filter : title, #number, branch or @author JSON Parse error: Unexpected EOF
README

Dotfiles

ushironoko's dotfiles management system.

Setup

# Initial setup
git clone https://github.com/ushironoko/dotfiles.git
cd dotfiles
./init.sh

# After setup, the dotfiles command is available:
dotfiles install    # Install symlinks
dotfiles list       # List managed files
dotfiles restore    # Restore from backup
dotfiles doctor     # Check environment

# Future updates with ghq (after initial setup):
ghq get ushironoko/dotfiles
cd $(ghq root)/github.com/ushironoko/dotfiles

Commands

dotfiles install

Creates symbolic links from repository to system locations.

  • -d, --dryRun: Preview changes
  • -f, --force: Force overwrite
  • -s, --select: Interactive selection
  • -v, --verbose: Detailed output

dotfiles list

Shows all managed dotfiles and their status.

  • -v, --verbose: Detailed information

dotfiles restore

Restores files from backup.

  • -b, --backup <timestamp>: Specific backup
  • -l, --list: List available backups
  • -v, --verbose: Detailed output

dotfiles doctor

Diagnoses environment issues.

  • -c, --check <categories>: Check specific areas (environment,conflicts,ghq,config,mcp)
  • -v, --verbose: Detailed diagnostics

Troubleshooting

Quick Diagnostics

If you're having issues with the initial setup, run the diagnostic tool:

./init.sh --check

This will show:

  • Binary locations (mise, bun, node)
  • Command availability in PATH
  • mise installation status
  • Installed tools
  • Recommendations for fixing issues

Common Issues

Run dotfiles doctor to diagnose issues. Common fixes:

# If mise commands are not found after installation
# Make sure ~/.local/bin is in your PATH and restart shell
export PATH="$HOME/.local/bin:$PATH"
exec $SHELL

# Remove conflicting Bun installation
rm -rf ~/.bun

# Fix PATH permanently
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(mise activate bash)"' >> ~/.bashrc
exec $SHELL

# Migrate old repos to ghq
./scripts/migrate-to-ghq.sh --dry-run
./scripts/migrate-to-ghq.sh --symlink

Configuration

Edit dotfiles.config.ts to manage your files:

  • file: Single file symlink
  • directory: Entire directory symlink
  • selective: Specific files with permissions

Codex harness

The versioned Codex harness installs global instructions, native custom agents, lifecycle hooks, command restrictions, and the shared Claude skills alongside ~/.codex/config.toml. Each component is linked selectively so Codex runtime state and bundled skills remain intact. After hook changes, review and trust them with /hooks in Codex.

Live config (~/.codex/config.toml)

~/.codex/config.toml is symlinked to codex/config.toml, but codex rewrites that file at runtime, filling it with machine-local state — [projects."<path>"] trust levels (absolute paths, including private/client repo names), [mcp_servers.*] tables wired to Codex.app paths, [marketplaces.*] sources, the notify helper path, per-repo [desktop...perPath] prefs, and [hooks.state] approval hashes. A git clean filter (codex-scrub, codex/scrub-config.awk) drops anything carrying a quoted absolute path, every [projects.*]/[mcp_servers.*] table, and the complete [hooks.state] tree at git add time. The path rule remains content-based so unknown machine state is scrubbed by default; URLs and relative paths are kept. The working tree keeps the live file untouched, so codex keeps functioning.

The filter driver lives in .git/config (never committed), so it must be registered once per clone:

bun run setup:git-filters   # also run automatically by init.sh and run-all

init.sh runs it on initial setup and bun run run-all runs it before every pre-commit check, so under normal use no manual step is needed. If you commit codex/config.toml on a fresh clone without it, trust state would leak — the filter is set to required = true to fail loudly if the scrubber ever errors.

Source 1 files
hooks/register.tsx 444 lines
1import type { ElementTable, On } from "claude-code";
2
3const PANE_ID = "pr-view";
4const PANE_TITLE = "Pull Requests";
5const COMMAND = "prs";
6const REFRESH_MS = 60_000;
7const PR_LIMIT = 500;
8const MAX_TITLE_CHARS = 200;
9const CHROME_ROWS = 6;
10const ROW_LINES = 2;
11const MIN_PAGE_SIZE = 5;
12const GH_FIELDS = "number,title,url,isDraft,author,headRefName";
13
14interface PullRequest {
15  number: number;
16  title: string;
17  url: string;
18  isDraft: boolean;
19  author: string;
20  branch: string;
21}
22
23type Listing =
24  | { kind: "idle" }
25  | { kind: "loading"; previous: readonly PullRequest[] }
26  | { kind: "loaded"; prs: readonly PullRequest[]; root: string }
27  | { kind: "error"; message: string };
28
29interface Host {
30  root: () => Promise<string>;
31  run: (
32    argv: readonly string[],
33    cwd?: string,
34  ) => Promise<{ exitCode: number; stdout: string; stderr: string }>;
35  open: () => Promise<unknown>;
36  close: () => Promise<unknown>;
37  redraw: () => void;
38}
39
40type Kit = Pick<ElementTable<"terminal">, "Box" | "Text" | "Button">;
41
42interface Paged<T> {
43  items: readonly T[];
44  page: number;
45  pages: number;
46  first: number;
47  last: number;
48}
49
50const isDrawable = (char: string): boolean => {
51  const code = char.codePointAt(0) ?? 0;
52
53  return code >= 32 && code !== 127;
54};
55
56const lineOf = (text: string): string => {
57  const cleaned = [...text.replaceAll(/\s+/g, " ").trim()]
58    .filter(isDrawable)
59    .join("");
60
61  return cleaned.length > MAX_TITLE_CHARS
62    ? `${cleaned.slice(0, MAX_TITLE_CHARS - 1)}…`
63    : cleaned;
64};
65
66const messageOf = (error: unknown): string =>
67  error instanceof Error ? error.message : String(error);
68
69const isWebUrl = (value: unknown): value is string => {
70  if (typeof value !== "string") {
71    return false;
72  }
73
74  try {
75    return new URL(value).protocol === "https:";
76  } catch {
77    return false;
78  }
79};
80
81const pullRequestOf = (raw: unknown): PullRequest | null => {
82  if (typeof raw !== "object" || raw === null) {
83    return null;
84  }
85
86  const record = raw as Record<string, unknown>;
87  const author = record.author as Record<string, unknown> | null | undefined;
88
89  if (typeof record.number !== "number" || !isWebUrl(record.url)) {
90    return null;
91  }
92
93  return {
94    number: record.number,
95    title: lineOf(typeof record.title === "string" ? record.title : ""),
96    url: record.url,
97    isDraft: record.isDraft === true,
98    author: typeof author?.login === "string" ? lineOf(author.login) : "",
99    branch:
100      typeof record.headRefName === "string" ? lineOf(record.headRefName) : "",
101  };
102};
103
104const pullRequestsOf = (stdout: string): PullRequest[] => {
105  const parsed: unknown = JSON.parse(stdout);
106
107  return Array.isArray(parsed)
108    ? parsed.flatMap((raw) => {
109        const pr = pullRequestOf(raw);
110
111        return pr === null ? [] : [pr];
112      })
113    : [];
114};
115
116const fetchListing = async (host: Host): Promise<Listing> => {
117  try {
118    const root = await host.root();
119    const { exitCode, stdout, stderr } = await host.run(
120      [
121        "zsh",
122        "-c",
123        '"$@"',
124        "zsh",
125        "gh",
126        "pr",
127        "list",
128        "--state",
129        "open",
130        "--limit",
131        String(PR_LIMIT),
132        "--json",
133        GH_FIELDS,
134      ],
135      root,
136    );
137
138    if (exitCode !== 0) {
139      return {
140        kind: "error",
141        message: lineOf(stderr) || `gh exited with ${exitCode}`,
142      };
143    }
144
145    return { kind: "loaded", prs: pullRequestsOf(stdout), root };
146  } catch (error) {
147    return { kind: "error", message: lineOf(messageOf(error)) };
148  }
149};
150
151const openInBrowser = async (
152  host: Host,
153  url: string,
154): Promise<string | null> => {
155  try {
156    const { exitCode, stderr } = await host.run(["open", url]);
157
158    return exitCode === 0
159      ? null
160      : lineOf(stderr) || `open exited with ${exitCode}`;
161  } catch (error) {
162    return lineOf(messageOf(error));
163  }
164};
165
166const prsOf = (listing: Listing): readonly PullRequest[] => {
167  switch (listing.kind) {
168    case "loaded": {
169      return listing.prs;
170    }
171    case "loading": {
172      return listing.previous;
173    }
174    default: {
175      return [];
176    }
177  }
178};
179
180const statusView = ({ Text }: Kit, listing: Listing) => {
181  switch (listing.kind) {
182    case "idle":
183    case "loading": {
184      return <Text dimColor>Loading…</Text>;
185    }
186    case "error": {
187      return <Text color="red">{listing.message}</Text>;
188    }
189    case "loaded": {
190      return listing.prs.length === 0 ? (
191        <Text dimColor>No open pull requests.</Text>
192      ) : null;
193    }
194  }
195};
196
197const rowLabelOf = (pr: PullRequest): string =>
198  `#${pr.number}${pr.isDraft ? " [draft]" : ""} ${pr.title}${pr.author === "" ? "" : ` @${pr.author}`}`;
199
200const matchesOf = (prs: readonly PullRequest[], query: string) => {
201  const needle = query.trim().toLowerCase();
202
203  return needle === ""
204    ? prs
205    : prs.filter((pr) =>
206        [`#${pr.number}`, pr.title, pr.branch, `@${pr.author}`].some((field) =>
207          field.toLowerCase().includes(needle),
208        ),
209      );
210};
211
212const pageSizeOf = (bodyRows: number): number =>
213  Math.max(MIN_PAGE_SIZE, Math.floor((bodyRows - CHROME_ROWS) / ROW_LINES));
214
215const pagedOf = <T,>(
216  items: readonly T[],
217  page: number,
218  size: number,
219): Paged<T> => {
220  const pages = Math.max(1, Math.ceil(items.length / size));
221  const current = Math.min(Math.max(page, 0), pages - 1);
222  const first = current * size;
223
224  return {
225    items: items.slice(first, first + size),
226    page: current,
227    pages,
228    first,
229    last: Math.min(first + size, items.length),
230  };
231};
232
233const pagerView = <T,>(
234  { Box, Text, Button }: Kit,
235  paged: Paged<T>,
236  total: number,
237  onPage: (page: number) => void,
238) =>
239  paged.pages <= 1 ? null : (
240    <Box flexDirection="row" columnGap={2}>
241      {paged.page > 0 ? (
242        <Button
243          key="page:prev"
244          plain
245          hotkey="p"
246          label="‹ prev"
247          onPress={() => onPage(paged.page - 1)}
248        />
249      ) : (
250        <Text dimColor>‹ prev</Text>
251      )}
252      <Text dimColor>
253        page {paged.page + 1}/{paged.pages} · {paged.first + 1}–{paged.last} of{" "}
254        {total}
255      </Text>
256      {paged.page < paged.pages - 1 ? (
257        <Button
258          key="page:next"
259          plain
260          hotkey="n"
261          label="next ›"
262          onPress={() => onPage(paged.page + 1)}
263        />
264      ) : (
265        <Text dimColor>next ›</Text>
266      )}
267    </Box>
268  );
269
270export const register = (on: On) => {
271  let listing: Listing = { kind: "idle" };
272  let notice: string | null = null;
273  let query = "";
274  let page = 0;
275  let host: Host | null = null;
276  let isOpen = false;
277  let generation = 0;
278
279  const refresh = async (current: Host) => {
280    generation += 1;
281    const mine = generation;
282
283    listing = { kind: "loading", previous: prsOf(listing) };
284    current.redraw();
285
286    const next = await fetchListing(current);
287
288    if (mine === generation) {
289      listing = next;
290      current.redraw();
291    }
292  };
293
294  const press = async (current: Host, url: string) => {
295    notice = await openInBrowser(current, url);
296    current.redraw();
297  };
298
299  on("session.start", async ($, e, next) => {
300    const current: Host = {
301      root: () => $.session.root(),
302      run: (argv, cwd) =>
303        $.process.run(argv, cwd === undefined ? undefined : { cwd }),
304      open: () => $.ui.open({ id: PANE_ID, title: PANE_TITLE }),
305      close: () => $.ui.close({ id: PANE_ID }),
306      redraw: () => $.ui.invalidate("ui.render"),
307    };
308    host = current;
309
310    await $.command.register({
311      name: COMMAND,
312      description:
313        "Toggle the pane listing this repository's open pull requests",
314    });
315
316    const loop = () =>
317      $.clock.after(REFRESH_MS, () => {
318        const pending = isOpen ? refresh(current) : Promise.resolve();
319
320        void pending.catch(() => undefined).finally(loop);
321      });
322    loop();
323
324    return next(e);
325  });
326
327  on("command.run", { command: COMMAND }, async () => {
328    if (host === null) {
329      return { text: "pr-view is not ready yet." };
330    }
331
332    if (isOpen) {
333      isOpen = false;
334      await host.close();
335
336      return { text: "Pull requests pane hidden." };
337    }
338
339    isOpen = true;
340    notice = null;
341    await host.open();
342    void refresh(host).catch(() => undefined);
343
344    return { text: "Pull requests pane shown." };
345  });
346
347  on("ui.render", { component: "Pane" }, async ($, e, next) => {
348    if (e.requestId !== PANE_ID || e.surface !== "terminal") {
349      return next(e);
350    }
351
352    const { Box, Text, Button, Input } = $.ui.resolve(e);
353    const kit: Kit = { Box, Text, Button };
354    const prs = prsOf(listing);
355    const shown = matchesOf(prs, query);
356    const paged = pagedOf(shown, page, pageSizeOf(e.props.scroll.bodyRows));
357    const current = host;
358
359    return (
360      <Box flexDirection="column" paddingRight={1}>
361        <Box flexDirection="row" justifyContent="space-between">
362          <Text bold>
363            Open PRs{" "}
364            {shown.length === prs.length
365              ? prs.length
366              : `${shown.length}/${prs.length}`}
367          </Text>
368          <Button
369            key="refresh"
370            plain
371            dimColor
372            label="↻ refresh"
373            onPress={() => {
374              if (current !== null) {
375                void refresh(current).catch(() => undefined);
376              }
377            }}
378          />
379        </Box>
380        {listing.kind === "loaded" ? (
381          <Text dimColor wrap="truncate-start">
382            {listing.root}
383          </Text>
384        ) : null}
385        <Input
386          key="filter"
387          label="filter "
388          placeholder="title, #number, branch or @author"
389          value={query}
390          onInput={(value) => {
391            query = value;
392            page = 0;
393            current?.redraw();
394          }}
395          onSubmit={(value) => {
396            query = value;
397            page = 0;
398            current?.redraw();
399          }}
400        />
401        {pagerView(kit, paged, shown.length, (target) => {
402          page = target;
403          current?.redraw();
404        })}
405        {statusView(kit, listing)}
406        {shown.length === 0 && prs.length > 0 ? (
407          <Text dimColor>No pull requests match "{query.trim()}".</Text>
408        ) : null}
409        {notice === null ? null : <Text color="red">{notice}</Text>}
410        <Box flexDirection="column">
411          {paged.items.map((pr) => (
412            <Box key={`pr:${pr.number}`} flexDirection="column">
413              <Button
414                key={`open:${pr.number}`}
415                plain
416                dimColor={pr.isDraft}
417                label={rowLabelOf(pr)}
418                onPress={() => {
419                  if (current !== null) {
420                    void press(current, pr.url).catch(() => undefined);
421                  }
422                }}
423              />
424              <Text dimColor wrap="truncate-end">
425                {"   "}
426                {pr.branch}
427              </Text>
428            </Box>
429          ))}
430        </Box>
431      </Box>
432    );
433  });
434
435  on("ui.close", { id: PANE_ID }, (_, e, next) => {
436    isOpen = false;
437    query = "";
438    page = 0;
439    generation += 1;
440
441    return next(e);
442  });
443};
444