본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)7.6k · #13145

client-methods

하는 일

이 스킬은 Agent-Native 앱의 브라우저 코드에서 어떤 클라이언트 메서드와 훅을 써야 하는지 설명합니다. 액션, 앱 상태, 탐색, 업로드, 설정을 다룹니다. 이 앱들의 화면을 작성하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓브라우저 코드가 앱 액션의 데이터를 읽거나 바꿔야 할 때.
  • ✓컴포넌트가 프레임워크나 앱 경로를 호출해야 할 때.
  • ✓화면 코드에 업로드, 인증 또는 설정을 추가할 때.

스킬 링크

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-methods/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-methods/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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

  1. Look for an existing client API first.

    Need Use
    App action reads/writes useActionQuery / useActionMutation from @agent-native/core/client/hooks
    Imperative action calls callAction from @agent-native/core/client/hooks
    Browser application state readClientAppState, writeClientAppState, setClientAppState, deleteClientAppState from @agent-native/core/client/hooks
    Navigation/app-state sync useAgentRouteState / useSemanticNavigationState from @agent-native/core/client/navigation
    Agent chat context Agent chat helpers from @agent-native/core/client/agent-chat
    Ask the user a multiple-choice question from app code askUserQuestion from @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, useChangeVersions from @agent-native/core/client/hooks
    Extension iframe calls appAction, appFetch, extensionFetch from the extension runtime

    Action fetch behavior: every useActionQuery / useActionMutation / callAction request is bounded by a 60s timeout, and timeouts surface as errors instead of retrying silently. useActionQuery cancels superseded requests automatically via React Query's abort signal. For imperative calls, callAction(name, params, { method, signal, timeoutMs }) accepts an AbortSignal and a timeoutMs override for legitimately long operations.

  2. 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/client barrel 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.
  3. 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
자주 묻는 질문

원시 요청을 피하는 이유는 무엇인가요?

경로 형태는 내부 세부 사항이며, 이름 붙은 메서드는 인증, 오류, 업데이트를 한곳에 모아 주기 때문입니다.

액션을 읽는 훅은 무엇인가요?

이 스킬은 읽기와 쓰기를 위한 액션 쿼리 훅과 뮤테이션 훅을 언급합니다.

경로를 직접 호출할 수 있나요?

이 스킬은 먼저 이름 붙은 메서드를 찾고, 그런 메서드가 있으면 손으로 작성한 호출은 피하라고 말합니다.

상세 정보

작성자의 원본 설명

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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬