xcode-mods
Xcode in Claude Code: build, run and tests pane, scheme/destination band, notifications and SwiftUI previews over headless Xcode MCP
何をするか
- プロンプトの上の帯・欄・トーストを描く
- /build・/tests・/run・/stop を足す
- mcp__xcode__BuildProject・mcp__xcode__RunProject・mcp__xcode__StopProject・mcp__xcode__RenderPreview の呼び出しを見張る
- session.end・session.startにフックする
- プロセスを起こす
良いところ
- ネットワークに出ない
- TypeScript で書かれている
- デスクトップ専用の分岐がある
- エラーを扱う
作り始めるためのコード
2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。
雛形(register.tsx)
import type { Register } from 'claude-code'
// Drawn like xcode-mods by Artem Novichkov (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/artemnovichkov-xcode-mods/
// 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 band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Text, Select, Button } = $.ui.resolve(e)
const err = '…'
const scheme = '…'
const destination = '…'
const text = '…'
const errors = '…'
const warnings = '…'
const failedTests = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" gap={1}>
<Text dimColor />
<Text color="red">
{err}
</Text>
<Select value={`${scheme}`} />
<Text dimColor>
▸
</Text>
<Select value={`${destination}`} />
<Text dimColor>
│
</Text>
<Text>
{text}
</Text>
<Text dimColor>
│
</Text>
<Button plain label={`⛔${errors}`} />
<Button plain label={`⚠${warnings}`} />
<Button plain label={`✗${failedTests}`} />
</Box>
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "Xcode" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const name = '…'
const device = '…'
const index = '…'
const length = '…'
const at = '…'
const error = '…'
return (
<Box flexDirection="column">
<Text dimColor wrap="truncate-end">
{name}
{` · ${device}`}
{" · "}
{`${index}1`}
/
{length}
</Text>
<Box flexDirection="column">
<Box flexDirection="row" gap={1}>
<Button label="↻ Re-render (r)" hotkey="r" variant="primary" />
<Button label="✦ Ask Claude (x)" hotkey="x" />
</Box>
<Box flexDirection="row" gap={1}>
<Button label="◀ (h)" hotkey="h" />
<Button label="▶ (l)" hotkey="l" />
<Button label="Open (o)" hotkey="o" />
</Box>
</Box>
<Text color="yellow">
{"◐ Rendering "}
{at}
…
</Text>
<Text color="red">
{error}
</Text>
</Box>
)
})
on('session.start', async ($, e, next) => {
const warnings = '…'
const failure = '…'
await $.ui.toast(`Build Succeeded · ${warnings} warnings`)
await $.ui.toast(`Tests failed to run: ${failure}`)
return next(e)
})
}
Mod 自身のコード
Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。
mods/xcode-mods/hooks/build.tsx 769〜820 行 · バンド
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (e.props.hasSurvey || e.surface === 'mobile') return next(e)
const t = await read($, target)
const b = await read($, build)
const err = await read($, error)
const ts = await read($, tests)
const r = await read($, run)
// Still connecting: awaitServer reports if it never does.
if (!t && (!err || isNotConnected(err))) return next(e)
const { Box, Text, Select, Button } = $.ui.resolve(e)
const now = await $.clock.now()
const errors = b.issues.filter(i => i.severity === 'error').length
const warnings = b.issues.length - errors
const failedTests = ts.tests.filter(x => x.state === 'failed').length
const act = activity(b, ts, r, now)
const openTab = (v: XcodeTab) => async () => {
await $.ui.open({ id: PANE, title: 'Xcode' })
await selectTab($, v)
}
return (
<Box flexDirection="row" gap={1}>
<Text dimColor></Text>
{err && <Text color="red">{err}</Text>}
{t && (
<Select
key="scheme"
value={t.scheme}
options={(t.schemes.length ? t.schemes : [t.scheme ?? '—']).map(s => ({ value: s }))}
onSelect={(v: string) => void switchTo($, 'XcodeSwitchScheme', { workspaceIdentifier: t.workspace, schemeName: v })}
/>
)}
{t && <Text dimColor>▸</Text>}
{t && (
<Select
key="destination"
value={t.destination}
options={(t.destinations.length ? t.destinations : [t.destination ?? '—']).map(d => ({ value: d }))}
onSelect={(v: string) =>
void switchTo($, 'XcodeSwitchRunDestination', { workspaceIdentifier: t.workspace, displayTitle: v })
}
/>
)}
{act && <Text dimColor>│</Text>}
{act && <Text color={act.color} dimColor={act.color === undefined}>{act.text}</Text>}
{(errors > 0 || warnings > 0 || failedTests > 0) && <Text dimColor>│</Text>}
{errors > 0 && <Button key="band-errors" plain label={`⛔${errors}`} onPress={openTab('build')} />}
{warnings > 0 && <Button key="band-warnings" plain label={`⚠${warnings}`} onPress={openTab('build')} />}
{failedTests > 0 && <Button key="band-tests" plain label={`✗${failedTests}`} onPress={openTab('tests')} />}
</Box>
)
})mods/xcode-mods/hooks/canvas.tsx 249〜316 行 · ペイン
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const p = await read($, preview)
const columns = Math.max(10, e.props.bodyColumns - 2)
const rows = Math.max(6, (e.viewport?.rows ?? 40) - 9)
const snap = p.history[p.index]
const status = p.rendering ? (
<Text color="yellow">◐ Rendering {p.rendering.split('/').at(-1)}…</Text>
) : null
if (!snap) {
return (
<Box flexDirection="column">
{status ?? <Text dimColor>No preview yet. /preview [file.swift]</Text>}
{p.error && <Text color="red">{p.error}</Text>}
</Box>
)
}
const caption = (
<Text dimColor wrap="truncate-end">
{snap.name}{snap.device ? ` · ${snap.device}` : ''} · {p.index + 1}/{p.history.length}
</Text>
)
const controls = (
// Two rows, not flexWrap: wrapped rows lose mouse hit-testing.
<Box flexDirection="column">
<Box flexDirection="row" gap={1}>
{snap.source && <Button key="rerender" label="↻ Re-render (r)" hotkey="r" variant="primary" onPress={() => void renderPreview($, snap.source!)} />}
<Button key="ask" label="✦ Ask Claude (x)" hotkey="x" onPress={() => void askAboutSnapshot($, snap)} />
</Box>
<Box flexDirection="row" gap={1}>
<Button key="prev" label="◀ (h)" hotkey="h" onPress={() => void update($, preview, (v): CanvasPreview => ({ ...v, index: Math.max(0, v.index - 1) }))} />
<Button key="next" label="▶ (l)" hotkey="l" onPress={() => void update($, preview, (v): CanvasPreview => ({ ...v, index: Math.min(v.history.length - 1, v.index + 1) }))} />
<Button key="open" label="Open (o)" hotkey="o" onPress={() => void $.process.run(['open', snap.path])} />
</Box>
</Box>
)
let image
if (e.surface === 'terminal') {
const { Image } = $.ui.resolve(e)
const box = fitImage(snap.width, snap.height, columns, rows)
image = (
<Image key="snapshot" source={{ file: snap.path, format: 'png', generation: p.generation * 100 + p.index }}
columns={box.columns} rows={box.rows} alt={`${snap.name} preview (needs kitty/Ghostty): ${snap.path}`} />
)
} else if (e.surface !== 'mobile' && snap.jpeg) {
const { Svg } = $.ui.resolve(e)
const width = DESKTOP_WIDTH
const height = snap.width > 0 ? Math.round((width * snap.height) / snap.width) : Math.round(width * 2)
const svg =
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">` +
`<image href="data:image/jpeg;base64,${snap.jpeg}" width="${width}" height="${height}"/></svg>`
image = <Svg source={svg} alt={`${snap.name} preview`} width={width} height={height} />
} else {
image = <Text dimColor>{snap.path}</Text>
}
return (
<Box flexDirection="column">
{caption}
{controls}
{status}
{p.error && <Text color="red">{p.error}</Text>}
{image}
</Box>
)
})ライセンスの全文(MIT)
MIT License Copyright (c) 2026 Artem Novichkov 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 に読んだコミット 7d331251d3d4 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。
| 載せる条件: 確かめやすいコード | |
|---|---|
| 入口を読んだ | hooks/hooks.json が名指すモジュールをすべて読んだ。mods/xcode-mods/hooks/register.tsx |
| 解析できる | すべてのファイルが TypeScript か JavaScript として解析できる。3 ファイルを解析 |
| コードが 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/… などは無い)。mods/xcode-mods/hooks/build.tsx:83 find(Windows にない); mods/xcode-mods/hooks/canvas.tsx:183 grep(Windows にない); mods/xcode-mods/hooks/canvas.tsx:282 open(Windows にない) |
| 通信 | fetch の送り先(https のホスト)がコードに書いてあるか。通信なし |
| プログラム | 起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。mods/xcode-mods/hooks/build.tsx:1009 実行時に決まるプログラム |
| 読んで送る | ファイルや環境変数を読み、かつ通信するか。読んだうえで通信する |
| ソースの鍵 | ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし |
| ライセンス | オープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT |
コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件
入れる
入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。
リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。
/plugin marketplace add artemnovichkov/xcode-mods/plugin install xcode-mods@xcode-mods入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(7d331251d3d4)と違うことがあります。入れる前に見比べてください。
Claude に聞く
modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:
modscode のデザイン「artemnovichkov-xcode-mods」をコードごと読んで、同じようなペインを作って似たデザイン
-
Claude に頼む…Skins0 Your promptadd rate limiting to the hub api0 Tool rows: finished, running, failedYour prompt Spinner0 Folded group of reads and searches●main · note 3 · note 3 · note 30 Edit diff cardDesktop only; the terminal keeps Claude Code's diff.0 Shell output cardDesktop only.0 Code block cardDesktop only; the terminal keeps Claude Code's markdown.0 TableAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopyAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopyAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopy0 SpinnerAccent SpinnerSpinnerSpinner… 2h 10m0 Band above the prompt: normal, then nudging to compact█████░░░ 42% build█████░░░ 42% build█████░░░ 42% buildContext is 42% full0 Compact now0 Band above a questionTable BashBashBash0 Turn footer (terminal)3 build in 2h 10m · Grep · +3 −3
-
Claude に頼む…agent-discoverbuildbuildbuildRefreshMCP Browse/3Tab / shift+Tab move · Enter presses · ↑↓ scroll · Esc back to the promptBrowse...Audit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancel
-
Claude に頼む…Fanyi settingsOnAPI · OpusenOn this MacAPIHost src/ SaveKey K · paste a new one, Enter SaveOpus↻ RefreshCustom model model id, for an API that lists none UseFanyi settingsHostClose
-
● pace Write · Park to1 park 12 dismiss 2pace: resume point 2h 10m · Fix login · 33 resume 34 discard 45 all 3 5pace: Park to resume point older than 7 days6 clear 6Claude に頼む…
-
Claude に頼む…AvatarsSpoken replies: on API key: setSet it with /plugin (Avatars, configure), or export ELEVENLABS_API_KEY and restart.OffStopStopOpusPick one to playt r s o d cCloseNew modes: ask Claude to create one (the create-mode skill), or see .
-
Claude に頼む…Model routerLast reply: Fix login → a1b2c3dKept off Opus to save the cache. Start a prompt with @Opus to force it.OnOffRoutes model and effort for each kind of prompt0 Fix loginbuildbuildbuildbuildbuildbuild0 Fix loginbuildbuildbuildbuildbuildbuild0 Fix loginbuildbuildbuildbuildbuildbuildYour rules checked firstNo rules yet. Pick a model and effort, type the words, press Add rule.Tasksa1b2c3d✕Tasksa1b2c3d✕Tasksa1b2c3d✕words, for example landing page, redesign Add rulebuildbuildbuildbuildbuildbuildOptions CoolingWhen still broken after xhigh, move tobuildbuildbuildCache saver: skip one-off model switches in long chatsbuildbuildbuildOne prompt only: start it with @opus, @max or @hardReset