client-methods
Fungsinya
Skill ini menjelaskan metode klien dan hook mana yang sebaiknya dipakai di kode browser aplikasi Agent-Native. Cakupannya meliputi aksi, status aplikasi, navigasi, unggahan, dan pengaturan. Skill ini untuk pengembang yang menulis layar di aplikasi ini.
Kapan dipakai
- βSaat kode browser perlu membaca atau mengubah data dari aksi aplikasi.
- βKetika sebuah komponen perlu memanggil framework atau rute aplikasi.
- βSaat Anda menambahkan unggahan, autentikasi, atau pengaturan ke kode layar.
Link skill
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-methods/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBisakah Anda membuat layar pengaturan menyimpan nilainya lewat metode klien bernama aplikasi, bukan permintaan mentah?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent mencari metode klien atau hook yang sudah ada dan sesuai kebutuhan. Agent memakai metode itu alih-alih menulis permintaan khusus, sehingga autentikasi dan penanganan error tetap konsisten.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum
Mengapa menghindari permintaan mentah?
Bentuk rute adalah detail internal, dan metode bernama menjaga autentikasi, error, dan pembaruan tetap di satu tempat.
Hook mana yang membaca aksi?
Skill ini menyebutkan hook kueri dan mutasi aksi untuk membaca dan menulis.
Bisakah saya tetap memanggil rute secara langsung?
Skill ini menyatakan agar mencari metode bernama lebih dulu dan menghindari panggilan tulis tangan jika sudah ada metodenya.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 7.6k
- Peringkat
- #13145
- Lisensi
- MIT
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
design-exploration
7.6kMembantu agent Anda mengeksplorasi beberapa arah desain UI secara berdampingan, membiarkan Anda memilih satu, lalu menyempurnakan desain yang dipilih.
visual-edit
7.6kMembantu agent Anda membuka aplikasi lokal yang sedang berjalan di editor visual agar Anda dapat meninjau dan mengedit layar aslinya bersama-sama.
turn-into-app
7.6kMengubah alur kerja, spreadsheet, atau proyek menjadi aplikasi visual yang rapi, dengan layar yang terisi dan agent yang bekerja di balik kontrol.
visual-plan
7.6kMengubah rencana teks biasa menjadi rencana visual interaktif dengan diagram, peta file, cuplikan kode, dan pertanyaan terbuka.
Skill serupa
angular-developer
280kMembantu agent Anda membuat kode Angular dan memberi saran struktur proyek. Berguna saat memulai proyek baru, membuat komponen, atau meningkatkan performa.
frontend-a11y
280kMembantu agent Anda membuat antarmuka web dapat diakses semua orang. Memastikan website dan aplikasi berfungsi baik dengan screen reader dan navigasi keyboard.
frontend-patterns
280kMembuat agent Anda menerapkan pola modern dalam frontend. Mengoptimalkan performa, mengelola state, dan mengikuti praktik terbaik React dan Next.js.