client-methods
できること
このスキルは、Agent-Nativeのアプリのブラウザーのコードで、どのクライアントのメソッドとフックを使うべきかを説明します。アクション、アプリの状態、ナビゲーション、アップロード、設定を扱います。これらのアプリで画面のコードを書く開発者向けです。
使う場面
- ✓ブラウザーのコードが、アプリのアクションからデータを読んだり変更したりする必要があるとき。
- ✓コンポーネントがフレームワークやアプリのルートを呼び出す必要があるとき。
- ✓画面のコードに、アップロード、認証、設定を追加するとき。
スキルのリンク
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-methods/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“設定画面は、生のリクエストではなく、アプリの名前の付いたクライアントのメソッドを使って値を保存するようにしてもらえますか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、必要に合う既存のクライアントのメソッドやフックを探します。独自のリクエストを書く代わりにそのメソッドを使うので、認証とエラー処理が一貫します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Client Methods
Rule
Browser/client code imports named methods, hooks, or client modules instead of hand-writing REST calls to framework or app routes.
Why
Route shapes are transport details. If components and docs call
fetch("/_agent-native/...") or template /api/* routes directly, every caller
has to rediscover auth, base paths, request-source headers, JSON parsing, error
handling, optimistic updates, sync invalidation, and route quirks. A named client
method gives the UI, docs, and future agents one stable contract.
How
Look for an existing client API first.
Need Use App action reads/writes useActionQuery/useActionMutationfrom@agent-native/core/client/hooksImperative action calls callActionfrom@agent-native/core/client/hooksBrowser application state readClientAppState,writeClientAppState,setClientAppState,deleteClientAppStatefrom@agent-native/core/client/hooksNavigation/app-state sync useAgentRouteState/useSemanticNavigationStatefrom@agent-native/core/client/navigationAgent chat context Agent chat helpers from @agent-native/core/client/agent-chatAsk the user a multiple-choice question from app code askUserQuestionfrom@agent-native/core/client/agent-chat(renders inline in the agent panel; answer goes to the agent — do not build a custom modal)Live sync useDbSync,useChangeVersion,useChangeVersionsfrom@agent-native/core/client/hooksExtension iframe calls appAction,appFetch,extensionFetchfrom the extension runtimeAction fetch behavior: every
useActionQuery/useActionMutation/callActionrequest is bounded by a 60s timeout, and timeouts surface as errors instead of retrying silently.useActionQuerycancels superseded requests automatically via React Query's abort signal. For imperative calls,callAction(name, params, { method, signal, timeoutMs })accepts anAbortSignaland atimeoutMsoverride for legitimately long operations.If no client API exists, add the narrowest helper at the boundary.
- Put shared framework helpers in
packages/core/src/client/*. - Put template-local helpers in
templates/<app>/app/hooks/*,templates/<app>/app/lib/*, or an existing local client module. - Export reusable core helpers from the focused
@agent-native/core/client/*entry for their domain. Never recommend the deprecated broad@agent-native/core/clientbarrel in new code. - Keep raw
fetch,agentNativePath, and route paths inside that helper, not scattered through components or docs. - Add focused tests for URL construction, headers, response parsing, error shape, and any sync invalidation.
- Put shared framework helpers in
Teach the helper, not the route.
Docs, skills, examples, and generated code should show:
await setClientAppState("selection", selection, { keepalive: true });not:
await fetch("/_agent-native/application-state/selection", { method: "PUT", body: JSON.stringify(selection), });
Exceptions
Raw route calls are acceptable only inside low-level client helpers or for route-shaped protocols that cannot be hidden cleanly:
- multipart uploads
- streaming/SSE/WebSocket transports
- OAuth redirects and callback URL construction
- webhooks and external provider callbacks
- extension sandbox
appFetch/extensionFetch, which are themselves exposed client methods - tests that assert route construction
Even for exceptions, prefer a named helper as soon as more than one caller needs the behavior.
Don't
- Don't put
fetch("/_agent-native/..."),fetch(agentNativePath(...)), or template/api/*calls directly in React components for normal app data, actions, settings, or application state. - Don't document route calls as the way client code should do work.
- Don't add pass-through
/api/*routes just to make client fetches look simpler; expose an action and call it with action hooks. - Don't duplicate auth/session/base-path/request-source/error parsing logic in every component.
Related Skills
actions— app operations shared by UI and agent.context-awareness— application-state navigation and selection helpers.real-time-sync— keeping helper-backed UI reads fresh.server-plugins— when a new route is actually warranted.
References
- `references/legacy-client-fet
よくある質問
なぜ生のリクエストを避けるのですか?
ルートの形は内部の詳細であり、名前付きのメソッドなら認証、エラー、更新を1か所にまとめられるからです。
アクションを読むフックはどれですか?
読み取りと書き込みのために、アクションのクエリとミューテーションのフックをスキルは挙げています。
ルートを直接呼び出してもよいですか?
まず名前付きのメソッドを探し、既にある場合は手書きの呼び出しを避けるよう、スキルは述べています。
詳細
作者による元の説明
Client method surface rules. Use when wiring browser/client code to actions, application state, framework routes, app APIs, uploads, auth, or settings.
repo: BuilderIO/agent-native
人気
- GitHubのスター
- 7.6k
- ランキング
- #13145
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
design-exploration
7.6kUIの複数のデザインの方向性を並べて検討し、1つを選んでもらい、選んだデザインを磨き上げるようエージェントを支援します。
visual-edit
7.6k実行中のローカルのアプリをビジュアルエディターで開き、本物の画面をまとめて確認し編集できるようエージェントを支援します。
turn-into-app
7.6kワークフロー、スプレッドシート、プロジェクトを、画面にデータが入り、操作の裏でエージェントが働く、洗練されたビジュアルアプリに変えます。
visual-plan
7.6kプレーンテキストの計画を、図、ファイルのマップ、コードの断片、未解決の質問を含む、対話できるビジュアルな計画に変えます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。