pr-inbox
An inbox for review requests and your own PRs: AI summary and risk, an AI review that can approve, a reader for the description and diff, merging (gh stack too) and CI fixes with Claude
何をするか
- 欄・ステータス行・トーストを描く
- /pr-inbox を足す
- ツールの呼び出しを見張る(止めることがある)
- session.start・turn.complete・turn.start・ui.closeにフックする
- ターンをまたいで自分の状態を持つ
良いところ
- ネットワークに出ない
- TypeScript で書かれている
- エラーを扱う
- ファイルを書かない
作り始めるためのコード
2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。
雛形(register.tsx)
import type { Register } from 'claude-code'
// Drawn like pr-inbox by 2bo (pane, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/2bo-pr-inbox/
// Written by modscode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
// the pane: open it with $.ui.open({ id: 'my-pane', title: "PR Inbox" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Link, Button } = $.ui.resolve(e)
const prLink = '…'
const label = '…'
const title = '…'
const what = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" columnGap={1}>
<Text color="#ff00d7">
▍
</Text>
<Text color="#ff00d7" bold>
read
</Text>
<Link href={`${prLink}`}>
<Text color="#00d7ff" underline>
{label}
</Text>
</Link>
<Text bold wrap="truncate-end">
{title}
</Text>
</Box>
<Text color="#af5fff">
━━━━━━━━
</Text>
<Text color="#ff5f5f">
{what}
</Text>
<Box flexDirection="row" columnGap={2}>
<Button label={`${label}`} hotkey="q" plain />
</Box>
Still fetching · q goes back
</Box>
)
})
on('session.start', async ($, e, next) => {
const error = '…'
const number = '…'
await $.ui.status(`Could not fetch PRs: ${error}`)
await $.ui.toast(`Unsnoozed #${number}`)
await $.ui.toast(`Snoozed #${number} until it is updated (z shows snoozed PRs)`)
return next(e)
})
}
Mod 自身のコード
Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。
hooks/register.ts 3406〜3565 行 · ペイン
on('ui.render', { component: 'Pane' }, async ($, e, next) => {
if (e.requestId !== PANE || !diffView) return next(e)
const kit = $.ui.resolve(e)
const { Box, Link, Code, Markdown } = kit
const { Text, Button } = glyphed(kit)
type El = ReturnType<typeof Box>
const redraw = () => $.ui.invalidate('ui.render')
// One cell short of the width: a symbol a terminal draws two cells wide does not wrap a full-width row
const columns = Math.max(40, (e.props.bodyColumns ?? 80) - 1)
const focused = e.props.isFocused === true
const v = diffView
const key = (k: string, label: string, hotkey: string, onPress: () => void, dim = false) =>
Button({ key: k, label, hotkey, plain: true, dimColor: dim, onPress })
const close = key('diff-close', 'back', 'q', () => {
diffView = undefined
redraw()
})
const { pr } = v
const label = `${pr.repository.nameWithOwner.split('/')[1] ?? pr.repository.nameWithOwner}#${pr.number}`
const prLink = safeHref(pr.url)
const head: El[] = [
Box({
flexDirection: 'row',
columnGap: 1,
children: [
Text({ color: focused ? NEON.pink : NEON.rule, children: ['▍'] }),
Text({ color: NEON.pink, bold: true, children: ['read'] }),
prLink
? Link({ href: prLink, children: [Text({ color: NEON.cyan, underline: true, children: [label] })] })
: Text({ children: [label] }),
Text({ bold: true, wrap: 'truncate-end', children: [fit(pr.title, Math.max(10, columns - textWidth(label) - 8))] }),
],
}),
]
const rule = Text({ color: focused ? NEON.violet : NEON.rule, children: ['━'.repeat(columns)] })
const toast = (text: string) => $.ui.toast(text, { timeoutMs: 4000 })
// n: the next PR in the list, read the same way
const nextPr = () => {
const rows = visibleRows(groups(fetchedAt || Date.now()))
const i = rows.findIndex((p) => p.url === pr.url)
const following = rows[i + 1] ?? (i < 0 ? rows[0] : undefined)
if (!following) return toast('This is the last PR in the list · q goes back')
selected = following.url
void openDiff($, following)
}
const nextKey = key('diff-next-pr', 'next PR', 'n', nextPr, true)
if (v.loading || v.error) {
const what = v.loading
? `${SPINNER[Math.floor(Date.now() / 100) % SPINNER.length]} fetching the PR…`
: `✗ ${fit(v.error, columns - 4)}`
// A failed read still offers the way on: the whole PR (when this was the change since your approval), GitHub,
// the next PR, back
const ways = v.error
? [
...(isApproved(pr) && approvalOutdated(pr) ? [key('diff-since', 'all changes', 't', () => void openDiff($, pr, 'all'))] : []),
key('diff-open', 'open on GitHub', 'o', async () => void (await $.process.run(['gh', 'pr', 'view', pr.url, '--web']))),
nextKey,
]
: []
const tree = [
...head,
rule,
Text({ color: v.error ? NEON.red : NEON.muted, children: [what] }),
Box({ flexDirection: 'row', columnGap: 2, children: [...ways, close] }),
]
return Box({ flexDirection: 'column', children: [...tree, keyCatcher(kit, tree, () => 'Still fetching · q goes back', toast)] })
}
const files = v.files
// Pages: the description, then each file
const pages = files.length + 1
const at = Math.min(Math.max(0, v.at), pages - 1)
const file = at > 0 ? (files[at - 1] as DiffFile) : undefined
const go = (to: number) => {
v.at = Math.min(Math.max(0, to), pages - 1)
v.block = 0
v.list = false
redraw()
}
const counts = (f: DiffFile) => `+${f.additions} -${f.deletions}`
const marks = (f: DiffFile) => {
const found = findingsIn(pr, f.path)
const bad = found.filter((x) => findingMark(x) === '✗').length
const soft = found.length - bad
return { bad, soft, text: [bad ? `✗${bad}` : '', soft ? `△${soft}` : ''].filter(Boolean).join(' ') }
}
// j/k: the next or previous block of lines, scrolled to the top of the pane
const blocks = file && !(isGenerated(file.path) && !v.showGenerated.has(file.path)) ? file.pieces.length : 0
const scrollTo = (block: number) => {
if (blocks === 0) return toast(file ? 'Nothing to scroll here · l: next file' : 'j/k scroll a file · l: the first file')
v.block = Math.min(Math.max(0, block), blocks - 1)
$.ui.scroll(v.block === 0 ? { to: 'start', in: PANE } : { to: { key: `block-${v.block}` }, in: PANE, block: 'start' }).catch(() => {
// A surface that does not scroll: the arrow keys still do
})
}
// What you can do with the PR without leaving the reader
const isReview = review.some((p) => p.url === pr.url)
const actOnPr: El[] = []
if (isReview && reviews.get(pr.url)?.state !== 'running') actOnPr.push(key('diff-approve', 'approve', 'a', () => void approve($, pr)))
if (isApproved(pr) && approvalOutdated(pr)) actOnPr.push(key('diff-approve', 'approve again', 'a', () => void approve($, pr)))
if (isReview)
actOnPr.push(
key('diff-review', reviews.get(pr.url)?.state === 'running' ? 'cancel review' : 'review', 'v', () => void aiReview($, pr)),
)
actOnPr.push(
key('diff-explain', mine.some((p) => p.url === pr.url) ? 'diagnose' : 'explain', 'e', () => {
void $.prompt.submit({ text: explainRequest(pr), asUser: true })
toast(`Asked Claude about #${pr.number}`)
}),
)
// Since your approval, or the whole PR
const since = v.since
const toggleSince =
isApproved(pr) && approvalOutdated(pr)
? [
key('diff-since', since ? 'all changes' : 'since approval', 't', () => {
void openDiff($, pr, since ? 'all' : 'since')
}),
]
: []
const keys = Box({
key: 'diff-keys',
flexDirection: 'row',
flexWrap: 'wrap',
columnGap: 2,
children: v.list
? [
key('diff-cursor-down', '↓', 'j', () => {
v.cursor = Math.min(pages - 1, v.cursor + 1)
redraw()
}),
key('diff-cursor-up', '↑', 'k', () => {
v.cursor = Math.max(0, v.cursor - 1)
redraw()
}),
key('diff-pick', 'open', 'l', () => go(v.cursor)),
key('diff-list', 'close', 'f', () => {
v.list = false
redraw()
}),
close,
]
: [
key('diff-prev', '◂', 'h', () => (at === 0 ? toast('This is the description · l: the first file') : go(at - 1)), at === 0),
key(
'diff-next',
'▸',
'l',
() => (at === pages - 1 ? toast('End of this PR · n: the next PR · q: back') : go(at + 1)),
at === pages - 1,
),
key('diff-down', '↓', 'j', () => scrollTo(v.block + 1), blocks === 0),
key('diff-up', '↑', 'k', () => scrollTo(v.block - 1), blocks === 0),
key('diff-list', 'files', 'f', () => {
v.list = true
v.cursor = at
redraw()
}),
...(file && isGenerated(file.path)
? [
key('diff-generated', v.showGenerated.has(file.path) ? 'fold' : 'show', 'g', () => {ライセンスの全文(MIT)
MIT License Copyright (c) 2026 2bo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
コードが呼ぶもの
プログラム起動環境変数Claude を動かすツール呼び出し保存
コードから読み取ったデザイン
読み取ったコミットのソースから描いたもので、動かした結果ではありません。一覧は 3 回描き、条件はデスクトップアプリで描く最初の分岐を取り、動かしたときにだけ決まる値は仮の例(点線の下線)にするか省きます。色と書体はこのサイトのものです。
コードから読めること
2026-10-06 に読んだコミット 503ad9199786 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。
| 載せる条件: 確かめやすいコード | |
|---|---|
| 入口を読んだ | hooks/hooks.json が名指すモジュールをすべて読んだ。hooks/register.ts |
| 解析できる | すべてのファイルが TypeScript か JavaScript として解析できる。1 ファイルを解析 |
| コードが Mod の中で完結 | import は Mod 自身のファイルかエンジンのモジュールだけ。パッケージも require もない。コードはすべて Mod の中 |
| 読める | 圧縮した行・eval・new Function・計算した道の import()・符号化した塊がない。圧縮・eval・符号化した塊なし |
| 呼び出しが見える | 通信とプログラム起動はその場で $.http.fetch・$.process.run と書き、他へ渡さない。外への呼び出しはすべてその場の $ で |
| 入れる前に自分で判断する材料 | |
| 描く場所 | コードから読んだ、描く先。ターミナル・デスクトップアプリ・両方・何も描かない(フックだけ: 見張りやプロンプトの書き換え)のどれか。出すだけで、外す理由にはしない。ターミナルとデスクトップアプリに同じように描く |
| 入れる手順 | リポジトリ自身の .claude-plugin/marketplace.json にこの Mod が載っていて、ページに書いた手順でそのマーケットプレイスから入れられるか。リポジトリの .claude-plugin/marketplace.json に載っており、そこから入れられる |
| Windows のプログラム | $.process で起動するプログラムが Windows にあるか(tail・date・open・osascript・/usr/… などは無い)。Windows にないプログラムを使わない |
| 通信 | fetch の送り先(https のホスト)がコードに書いてあるか。通信なし |
| プログラム | 起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。hooks/register.ts:1001 実行時に決まるプログラム |
| 読んで送る | ファイルや環境変数を読み、かつ通信するか。読んだうえで通信する |
| ソースの鍵 | ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし |
| ライセンス | オープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT |
コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件
入れる
入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。
リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。
/plugin marketplace add 2bo/pr-inbox/plugin install pr-inbox@pr-inbox入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(503ad9199786)と違うことがあります。入れる前に見比べてください。
Claude に聞く
modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:
modscode のデザイン「2bo-pr-inbox」をコードごと読んで、同じようなペインを作って似たデザイン
-
✦ explain as pick how Claude answers×3 ● build3 ● build3 ● build▸ VideoClaude に頼む…
-
Claude に頼む…CIcross Bash · Classicmain · a1b2c3d · failed at 14:32Open the run on GitHubFix it fClose x
(no log available)
-
Claude に頼む…GitHub inboxGitHubloading…Refresh rbuildbuildbuildClose xStealth IssuesNo open issues in this view.#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopen#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopen#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopenPull requestsNo open pull requests.#3 Fix login · main · draft · build · HiddenChecksReviewopen#3 Fix login · main · draft · build · HiddenChecksReviewopen#3 Fix login · main · draft · build · HiddenChecksReviewopenChecks for #3Plain
-
授权已失效,请在 Web 重新授权拆分已不能决定,已刷新Claude に頼む…
-
Claude に頼む…CI#3 Fix loginRefresh● build● build● buildRefreshRe-run failedRefresh
-
Claude に頼む…ClayfoldBackend up 2h 10m open appPID Start server · Bun Clayfold · :FrontendStart server (heap Start server) · CPU 42% · DB Start serverOpus, critic Opus · $1.24 per run Frontendweb/dist built 2h 10m agoVite :Frontend upFrontend open event stream Claude Code instances: 3None running.note — 2h 10m long run build build buildFrontendKopen in browsernote — 2h 10m long run build build buildFrontendKopen in browsernote — 2h 10m long run build build buildFrontendKopen in browserRecently finishedBackend · 2h 10m agoBackend · 2h 10m agoBackend · 2h 10m ago