Ux Captureのロゴ

Ux Capture

コミュニティ
bacnh85
ux-capture

Capture playbook for the pi-ux render-and-inspect loop: screenshotting a UI you just built via local headless Chrome vs web_screenshot, daemon reachability (localhost vs LAN IP vs host.docker.internal), SSRF-protected daemons, and cloudflared tunnels. Load when setting up render inspection or when a UI screenshot capture fails. Covers WebGL/three.js pages (SwiftShader capture flags + in-app WebGL guard).

概要

公開者bacnh85
リポジトリpi-extensions
スキル名ux-capture
スター
42
フォーク
15
同梱ファイル
指示のみ
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    bacnh85がGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Ux Capture」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/bacnh85/pi-extensions/tree/main/pi-ux/skills/ux-capture
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/bacnh85/pi-extensions.git /tmp/pi-extensions
mkdir -p .claude/skills
cp -r /tmp/pi-extensions/pi-ux/skills/ux-capture .claude/skills/ux-capture
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでUx Captureを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にUx Captureを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Ux Captureは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

UX Capture Playbook

Judge captures at viewer resolution (1×–3×); never chase sub-visible precision.

Disable entrance animations when capturing: pass reduced_motion=true to web_screenshot / web_interact (pi-web ≥0.16.0), or add --force-prefers-reduced-motion to manual headless Chrome (or emulate the media query). Pages rightly use staggered page-load reveals with opacity:0 backwards-fill — captured mid-animation they screenshot as blank sections, and you will "fix" content that isn't broken. The same forced query doubles as a reduced-motion audit: with animations off, every section must still be fully visible and readable.

Capture at the brief's target viewport. Web pages: 1280–1440 wide. App screens and mobile-first briefs: the width the brief names (usually 390) at its target height (~844). pi-web handles this honestly now: web_screenshot and web_interact with width/viewport below 500px automatically use CDP device-metrics emulation (true 390px CSS viewport) and return a scrollWidth/innerWidth probe — scrollWidth > width means overflowing CSS. If you fall back to manual headless Chrome, know its trap: many builds clamp window width to 500px, so a "390 capture" secretly renders at 500 and crops (see the layout probe below for the wrapper that does it honestly). If content overflows or dead-ends at the target size, the page is broken — fix the page. Never widen the viewport to make a problem invisible.

Interaction — web_interact (pi-web ≥0.16.0)

A screenshot proves the page LOOKS right; only interaction proves it WORKS. After visual inspection, verify behavior with web_interact — one call = one browser lifecycle: open url, run steps in order, get per-step results, a final inline PNG, and a scrollWidth probe.

text
web_interact url="http://localhost:5173" viewport={width:390,height:844} \
  reduced_motion=true grant=["clipboard-read","clipboard-write"] steps=[
  {click: "#copy-btn"},
  {evaluate: "document.getElementById('status').textContent", label: "status"},
  {type: {selector: "#email", text: "a@b.co"}},
  {press: "Enter"},
  {wait_for: "[data-success]"}
  • Trusted clicks: steps click via CDP Input.dispatchMouseEvent at the element's center — synthetic el.click() grants no user activation, so document.execCommand('copy') and login/clipboard flows would silently fail under it. Under a trusted click, copy returns true.
  • evaluate is double-unwrapped: Runtime.evaluate nests the value at {result:{result:{value}}} — the tool returns the real value; if you ever hand-roll CDP, single-unwrapping yields undefined and makes the app LOOK broken when it isn't.
  • Steps stop at the first failure with the reason — a broken selector surfaces loudly instead of no-op'ing later steps.
  • Authenticated dev routes need the token set BEFORE navigating: the call opens url then runs steps, so a deep link into a login-protected route fetches before your token exists and bounces to the login page (you then screenshot the login screen and blame the UI). Hop through the origin: {evaluate:"localStorage.setItem('token','…')"}, {wait_ms:400}, {evaluate:"location.replace('/app?id=1')"}, {wait_ms:6000}. The tool warns that a navigating step means later steps run against the NEW document — order the token step first, never after the navigation.
  • Read the app's own error/status element ({evaluate:"(document.getElementById('error')||{}).textContent"}) before concluding the app is broken: a blank canvas can be an app-side failure notice (bad fixture, failed fetch) that only the DOM text names.
  • One action key per step: a step object takes exactly ONE of click/type/press/evaluate/wait_for/dialog/screenshot (plus optional label). wait_for accepts a selector string OR a millisecond number, and wait_ms is the flat alias for wait_for: <number> (mapped before validation) — but it IS an action key, so it cannot ride along with another one ({screenshot:true, wait_ms:1500} is rejected as two actions — make them two steps). {screenshot:false} is the lone exception: a declined capture, filtered out before validation.
  • Slow steps — the budget is a top-level param, not a step key: pass timeout_ms on the web_interact CALL (default 60s, clamped 1s–600s); it bounds each step and fails loudly with the reason instead of hanging. A step object carrying timeout_ms is rejected as an unknown key. Raise it for legitimately slow evaluate steps.
  • Clipboard readback on insecure origins: there is no clipboard API to read back with; execCommand returning true under a trusted click is the strongest available signal (grant permissions for secure origins).

Manual CDP (fallback only, when web_interact is unavailable): launch Chrome with --remote-debugging-port=0, read <profile>/DevToolsActivePort for the ws URL, create targets over the websocket (Target.createTarget — not the /json/new HTTP endpoint, whose method flipped to PUT), attach with flatten: true.

WebGL pages (three.js / r3f / model-viewer)

Headless Chrome without a GPU has no WebGL context: a three.js canvas throws on creation and — unguarded — the error boundary replaces the whole page with "Application error", so you screenshot a blank/error page and blame the app.

  1. In the app: probe first (document.createElement('canvas').getContext('webgl2') ?? …getContext('webgl')) and render a fallback message when absent. A GPU-less viewer must not crash the route it lives on.
  2. In the capture: launch Chrome with software rendering — --enable-unsafe-swiftshader --use-gl=angle --use-angle=swiftshader — then the canvas really renders and the screenshot shows the model. Verify with a CDP probe (canvas.getContext('webgl')) before trusting a blank capture; gl:true with an empty canvas means the scene, not the context, is broken.

Layout probe (fallback for manual captures)

Needed only when CDP tooling above is unavailable. Two Chrome facts make naive mobile checks lie:

  1. Headless Chrome clamps window width to 500px. A --window-size=390 capture renders the page at 500px and crops the PNG to 390 — cuts at the right edge are the CROP, not your CSS. Detect it: --dump-dom a page containing window.innerWidth — 500 at a 390 request means clamped.
  2. window.innerWidth therefore never reports the true mobile viewport.

The honest way to see and measure a 390px screen: a wrapper page with a 390×844 iframe (an iframe IS a true 390px CSS viewport, immune to the clamp), rendered at a 500px window with --allow-file-access-from-files:

bash
cp index.html /tmp/page.html
cat > /tmp/wrapper.html <<'EOF'
<!DOCTYPE html><html><head><meta charset="utf-8"><style>
body{margin:0;background:#888}#frame{width:390px;height:844px;border:0;outline:2px solid #000}
</style></head><body>
<iframe id="frame" src="./page.html"></iframe>
<pre id="out">measuring…</pre>
<script>
const f=document.getElementById('frame');
f.addEventListener('load',()=>{
  const d=f.contentDocument;
  document.getElementById('out').textContent=
    'page scrollWidth:'+d.documentElement.scrollWidth+' / viewport:390';
});
</script>
</body></html>
EOF
"$CHROME" --headless --disable-gpu --allow-file-access-from-files \
  --virtual-time-budget=6000 --window-size=500,900 \
  --screenshot=/tmp/mobile-390.png "file:///tmp/wrapper.html"
"$CHROME" --headless --disable-gpu --allow-file-access-from-files \
  --virtual-time-budget=6000 --window-size=500,900 \
  --dump-dom "file:///tmp/wrapper.html" | grep -o 'page scrollWidth:[^<]*'

Pass = scrollWidth 390 / viewport:390, and the screenshot shows the true mobile render (grey letterbox on the right is the wrapper, not your page). If scrollWidth exceeds 390, fix the CSS (min-width on rows/grid, an unbreakable string, a fixed-width column) and probe again — on the delivered file, after the last edit.

Alternative: puppeteer-core device emulation (when node ≥18 and npm are available — no wrapper file, and it gives true fullPage + a JS overflow probe): npm i puppeteer-core once, then launch with executablePath pointing at installed Chrome and page.setViewport({ width: 390, height: 844, deviceScaleFactor: 2 }). setViewport is real device-metrics emulation — immune to the window clamp. Probe with document.documentElement.scrollWidth via page.evaluate before screenshotting; page.screenshot({ fullPage: true }) for the tall capture.

Default — web_screenshot (pi-web ≥0.16.0, auto local detection)

web_screenshot auto-routes localhost/LAN/file URLs to the locally installed headless Chrome and returns the PNG inline — no daemon, no manual commands:

  • web_screenshot url="http://localhost:PORT" width=390 height=844 — the model sees the render; below 500px the capture is CDP device-emulated (honest viewport, no clamp) and includes the scrollWidth probe.
  • reduced_motion=true disables entrance animations for the shot.
  • full_page=true captures a tall 8000px window; wait_for settles JS via --virtual-time-budget; engine="local" forces local on a public URL.
  • web_pdf works the same way (--print-to-pdf) for full-content archival.
  • If Chrome is missing: web_status shows localChrome.path; set CHROME_PATH.
  • Empty replies / connection resets from a dev-server URL usually mean a STALE HUNG server on the port (accepts TCP, returns nothing) — lsof -ti :PORT and kill it before diagnosing the tools.

Fallback — manual headless Chrome (pi-web <0.7.0 or if the tool errors)

Headless Chrome writes the PNG; the read tool shows it inline (multimodal models see it). Keep --window-size at the target viewport (e.g. 390,844 for a phone screen) — never widen it to hide overflow.

  • Linux: google-chrome --headless --screenshot=/tmp/shot.png --window-size=1280,800 http://localhost:PORT (or chromium)
  • macOS: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --headless --screenshot=/tmp/shot.png --window-size=1280,800 http://localhost:PORT

Alternative — web_screenshot (daemon-rendered, pi-web 0.6.2+)

The screenshot URL is navigated by the DAEMON's browser, so addresses must resolve on the daemon host:

  • Reachable: your machine's LAN IP, or host.docker.internal for a Dockerized daemon.
  • Plain localhost/file:// only for a daemon you know runs natively on this machine — web_status can't tell you (a Dockerized daemon on a published port also shows 127.0.0.1 + healthy but cannot see your localhost).
  • SSRF-protected daemons (common) block private/localhost URLs outright — failures say "URL blocked (SSRF protection)".
  • Last resort: a temporary public tunnel (cloudflared tunnel --url http://localhost:PORT) when the remote daemon must render the page; quick tunnels are often flaky. If all capture paths fail, fall back to the deterministic ux_audit gates only.

よくある質問

AIスキル「Ux Capture」では何ができますか?

Capture playbook for the pi-ux render-and-inspect loop: screenshotting a UI you just built via local headless Chrome vs web_screenshot, daemon reachability (localhost vs LAN IP vs host.docker.internal), SSRF-protected daemons, and cloudflared tunnels. Load when setting up render inspection or when a UI screenshot capture fails. Covers WebGL/three.js pages (SwiftShader capture flags + in-app WebGL guard).

TypingMindでUx Captureを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Ux Captureはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにUx Captureをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/bacnh85/pi-extensions/tree/main/pi-ux/skills/ux-captureを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Ux Captureを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Ux Captureで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもUx Captureを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Ux Capture」は無料ですか?

bacnh85がGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇