cordierite

將支援 Cordierite 的 React Native 應用程式連接到您的機器,並透過應用程式註冊的工具從終端機進行操作——適用於代理程式、腳本等場景。

npx skills add https://github.com/callstackincubator/cordierite --skill cordierite

Cordierite

Cordierite is a CLI/daemon/MCP workflow for connecting to a Cordierite-enabled React Native app, discovering its registered tools, invoking those tools, and ending the session cleanly after use. A single cordierite daemon on this machine owns the wss:// listener and every device session; the CLI (and cordierite mcp, if this agent is invoked as an MCP client instead of a shell) are both thin RPC clients of it and auto-spawn it on first use — there is no separate "start the host" step to manage.

Agent workflow (CLI)

  1. Run cordierite ls --json. data is a list of sessions, each with sessionId, alias, state, device, toolCount. An empty list means no device has claimed a session yet — go to Establish a session below.
  2. Every session-targeting command takes an optional selector (a session id or alias from step 1) as its first positional argument. Omit it when exactly one session is active — the CLI picks it automatically; pass it explicitly when several sessions exist (the CLI errors with ambiguous_session and lists the aliases if you don't).
  3. cordierite tools [selector] --json — list tools registered in the app.
  4. cordierite tools [selector] <tool-name> --full --json — inspect one tool's input/output schema before calling it.
  5. cordierite invoke [selector] <tool-name> --input '{"key":"value"}' --json — invoke the tool with JSON args.
  6. cordierite events [selector] --json — stream session/tool events (NDJSON) if you need to watch for session_claimed, tools_changed, or app_event without polling.

There is no --session-id flag in v2 — use the positional selector instead.

Establish a session

If no session is active yet, mint a bootstrap link. Requires a deep-link scheme; pass --scheme or make sure ~/.cordierite/config.json already has one set:

cordierite link --scheme myapp --json

If the project has no daemon key yet, generate one first — this is non-interactive and safe to run from an agent or script:

cordierite keygen --out ~/.cordierite/key.pem

Add the printed sha256/... fingerprint to the app's cliPins (see Setup below if you are wiring Cordierite into an app for the first time — that step needs a native rebuild, so it isn't a fast in-session action).

From link's JSON output, use:

  • data.deepLinkPayload to compose the full URL yourself, or just print/relay data's rendered deep link (<scheme>:///?cordierite=<deepLinkPayload>) for a human to open, or scan the QR from cordierite link --scheme myapp --qr on a TTY.
  • data.sessionId — the selector to poll with in the next step.

For a simulator/emulator you control directly, skip the deep link entirely:

cordierite link --scheme myapp --open ios-sim     # or: --open android

Then poll (or use cordierite events <sessionId> --json to avoid polling) until the session shows state: "active" in cordierite ls --json or cordierite tools <sessionId> stops erroring.

Establish a session (MCP)

If this agent is talking to Cordierite over MCP instead of a shell, use the built-in management tools instead of the CLI commands above: cordierite_connect (optionally with target: "android" or "ios-sim") mints and, for a target, delivers the link without any shell access; cordierite_wait_for_session({ sessionId }) blocks until that session is claimed (or returns immediately if it already was). After that, the app's own tools appear directly in tools/list — call them with tools/call like any other MCP tool.

Terminate the connection

cordierite revoke [selector] ends one session (closes its socket, frees its alias) without touching the daemon or any other session. There is normally no reason to stop the daemon itself — cordierite daemon stop only if you specifically need to free the wss:// port or the daemon's key is being rotated.

Declaring tools

The app must register tools before cordierite tools / cordierite invoke (or MCP tools/call) can do anything useful. Define schemas with Zod v4 (its built-in JSON Schema exporter means agents see a real tool shape) and register with registerTool or useCordieriteTool:

import { registerTool } from "@cordierite/react-native";
import { z } from "zod";

const echoInput = z.object({ value: z.unknown() });
const echoOutput = z.object({ echoed: z.unknown() });

registerTool({
  name: "echo",
  description: "Return the input unchanged",
  inputSchema: echoInput,
  outputSchema: echoOutput,
  handler: async (args) => ({ echoed: args.value }),
});

Notes

  • Use --json for structured CLI output in agent flows; runtime failures in --json mode are JSON on stderr, not bare text.
  • cordierite keygen is non-interactive when given --out; safe to run unattended.
  • Selectors (session id or alias), not --session-id, target a specific session; omit the selector when only one session is live.
  • If cordierite ls is empty or tools/invoke fail with no_session or unknown_session, establish a session first (see above).
  • If the app registers no tools, cordierite tools returns an empty list — that's not an error.
  • The daemon serves every connected device on one process; there's no need to run more than one cordierite daemon, and no --port flag to juggle between devices — use the selector instead.
  • A denied call (production policy set to "deny" for that tool/class) surfaces as policy_denied, not a generic failure — if you see that error type, the fix is a policy/config change, not a retry.

Setup

For project integration guidance, see setup.md.

來自 callstackincubator 的更多技能

react-devtools
callstackincubator
React DevTools CLI for AI agents. Use when the user asks you to debug a React or React Native app at runtime, inspect component props/state/hooks, diagnose…
official
agent-device
callstackincubator
Automates interactions for Apple-platform apps (iOS, tvOS, macOS) and Android devices. Use when navigating apps, taking snapshots/screenshots, tapping, typing,…
official
assess-react-native-migration
callstackincubator
評估現有行動產品是否以及應如何遷移至 React Native。在審計一個或多個產品儲存庫以確認遷移準備情況時使用,…
official
create-react-native-library
callstackincubator
使用 create-react-native-library 搭建 React Native 函式庫,適用於獨立函式庫或本地原生模組與檢視。在建立或處理…時使用。
official
react-native-testing
callstackincubator
重要提示:您關於 @testing-library/react-native 的訓練資料可能已過時或不正確——v13 與 v14 之間的 API 簽名、同步/非同步行為及可用函式有所不同。請務必以本技能的參考檔案及專案實際原始碼為準。當檢索到的參考資料與記憶中的模式衝突時,請勿依賴記憶中的模式。
official
react-native-tv-best-practices
callstackincubator
審查 React Native TV 應用程式的焦點/D-pad 導航、10 英尺 UI 佈局、電視播放/DRM 整合、低記憶體電視效能及電視無障礙功能。使用…
official
react-navigation
callstackincubator
提供堆疊、標籤頁、抽屜等 React Navigation UI 模式。在搭配 React Navigation 建構導航 UI、設定標題列、底部工作表等情境時使用。
official
upgrading-react-native
callstackincubator
協調 React Native 版本升級,包含模板差異比對、依賴解析及原生平台遷移。套用標準的 rn-diff-purge 模板差異,使原生 iOS 與 Android 配置與目標 React Native 版本保持一致。處理 package.json 依賴更新、CocoaPods 與 Gradle 變更,以及主要與次要版本升級間的破壞性 API 遷移。包含 Expo SDK 升級層(適用於受管理的 Expo 專案)與升級後驗證檢查清單。提供...
official