real-time-sync
하는 일
이 스킬은 어떤 화면이 다른 사람의 변경을 보여 주기 위해 스스로 새로고침해야 하는지, 그리고 공유 업데이트 채널을 안전하게 켜는 방법을 에이전트에게 알려 줍니다. 데이터가 스스로 바뀌는 페이지를 만드는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓사용자가 새로고침하기 전에 다른 사람이 바꾼 내용을 보여 줘야 하는 페이지일 때.
- ✓백그라운드 작업의 진행 상황이 사용자가 지켜보는 동안 업데이트되어야 할 때.
- ✓공개 페이지, 설정 페이지 또는 양식 페이지처럼 실시간 업데이트가 필요 없어 꺼 두어야 할 때.
스킬 링크
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/real-time-sync/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“새 메일이 도착하면 제가 새로고침하지 않아도 받은편지함이 스스로 업데이트되게 해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
이 스킬은 간단한 규칙을 둡니다. 사용자 없이도 데이터가 바뀔 수 있고 사용자가 그것을 봐야 할 때만 실시간 확인을 켭니다. 그렇지 않으면 페이지는 포커스나 이동 시 새로고침됩니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Real-Time Sync
Decision rule
Opt in only when both are true:
- The data can change without the current user acting.
- The user needs to see that change before refreshing or navigating.
A local agent edit does not meet this rule. The chat run stream already invalidates action queries and source counters after each side-effecting tool and again at run end, without opening a background poll.
Opt in
- Slides deck editor: another collaborator can edit the open deck.
- Mail inbox: new mail can arrive while the inbox is open.
- A watched job: a background job changes progress while the user watches it.
- Cross-tab state: state must converge across this user's open tabs without a new action.
Keep it off
- Public, anonymous, marketing, docs, and SSR pages.
- Settings, forms, and read-mostly lists or dashboards. Refresh them on focus or navigation instead.
- Single-user agent edits. The chat run stream handles those.
- Pages where an update is useful eventually but not before the next refresh.
Cost and behavior
useDbSync() has no background transport unless the page opts in with a
non-empty reason. One transport is shared per tab. A visible opted-in tab polls
at 1 minute, then 2, then 5 minutes while idle; user activity or a local
mutation resets that sequence. Hidden tabs pause by default. During an active
agent run, opted-in sync can poll at its configured interval; local tool
completion and run-end invalidation do not depend on that poll.
On a long-lived host, same-process changes stream over
/_agent-native/events; polling is the cross-process fallback. On a production
serverless host, the local events endpoint refuses the long-lived stream and
/_agent-native/poll carries remote changes. The paid Hosted Realtime Sync
Gateway is not required for this pattern.
While a collab doc shows another person present, the transport polls every
2.5 s instead (acquireCollabPollBoost(), held by the collab client, not by
pages). It is a no-op whenever a stream is connected, lapses after 3 minutes
without input or remote events, and never applies to lone tabs.
Use the hook
Declare the reason beside the route gate so reviewers can see why the page pays for remote sync:
useDbSync({
queryClient,
realtime: isPrivateDeckEditorPath(location.pathname)
? { reason: "other collaborators can edit this deck while it is open" }
: undefined,
pauseWhenHidden: true,
});
The reason is required by the TypeScript API. Opt in only for a named private or authenticated route; public, documentation, and SSR pages should not start a background transport.
An opted-in page only hears about an action when its change event reaches the
current user. By default an action event reaches the actor alone, so a
collaborator's comment, save, or agent edit never arrives. Declare
changeResource: (input, result) => ({ resourceType, resourceId }) on the
mutating action and the event also reaches everyone who can read that resource.
Name it from input when the call carries the resource id (Content's
documentChangeResource, Slides' comment actions) and from result when the
call is keyed by a child id (Design's designChangeResource for
delete-file); return null for a call that changed nothing. Do not publish a
parallel per-template event for the same purpose.
Do not start subscribeSyncEvents() or an EventSource in a feature to bypass
the decision. subscribeSyncEvents() is a lower-level transport subscription
used by the existing Yjs collaboration client and narrow framework plumbing.
Keep Yjs collaborative editing on its existing channel.
Query freshness
Prefer useActionQuery() for action-backed data. Mutating actions refresh local
action observers; the chat run stream also invalidates them for agent tool
side effects. Raw queries should include the relevant source counters:
const versions = useChangeVersions(["dashboards", "action"]);
useQuery({
queryKey: ["dashboard", id, versions],
queryFn: () => fetchDashboard(id),
placeholderData: (previous) => previous,
});
That covers local chat-run edits. Remote edits reach the counter through
useDbSync() only on an opted-in page. Use useReconciledState when a form or
inline editor copies a query value into local state so incoming data does not
replace active typing.
URL commands (__set_url__, set-url, and set-search-params) and
refresh-screen also flow through local chat events. The sideb
자주 묻는 질문
에이전트의 편집에도 실시간 동기화가 필요한가요?
아니요. 채팅 실행이 에이전트가 변경할 때마다 데이터를 이미 새로고침합니다.
숨겨진 탭에서도 실시간 확인이 실행되나요?
아니요. 숨겨진 탭은 기본적으로 일시 중지됩니다.
보이는 탭은 얼마나 자주 확인하나요?
처음에는 약 1분마다, 그 뒤에는 유휴 상태일 때 더 드물게 확인합니다.
상세 정보
작성자의 원본 설명
Decide whether a page needs external changes before refresh, then use the opt-in shared SSE and polling transport safely.
repo: BuilderIO/agent-native
인기도
- GitHub 스타
- 7.6k
- 순위
- #13175
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
design-exploration
7.6k에이전트가 여러 UI 디자인 방향을 나란히 보여 주고, 사용자가 하나를 고르면 그 디자인을 다듬도록 돕습니다.
visual-edit
7.6k에이전트가 실행 중인 로컬 앱을 시각 편집기에 열어, 실제 화면을 함께 검토하고 편집하도록 돕습니다.
turn-into-app
7.6k워크플로, 스프레드시트 또는 프로젝트를 데이터가 채워진 세련된 시각 앱으로 바꾸고, 컨트롤 뒤에서 에이전트가 작업하도록 합니다.
visual-plan
7.6k일반 텍스트 계획을 다이어그램, 파일 맵, 코드 조각, 열린 질문이 담긴 대화형 시각 계획으로 바꿔 줍니다.
비슷한 스킬
angular-developer
280k에이전트가 Angular 코드를 만들고 프로젝트 구조를 조언하도록 돕습니다. 새 프로젝트 시작, 코드 부분 생성, 성능과 접근성 개선에 유용합니다.
frontend-a11y
280k모든 사람이 웹 인터페이스를 쓸 수 있도록 에이전트를 돕습니다. 웹사이트와 앱이 화면 읽기 프로그램과 키보드 탐색에서 잘 작동하도록 합니다.
frontend-patterns
280k프론트엔드 개발의 현대적인 패턴을 적용하도록 에이전트를 돕습니다. React와 Next.js에서 성능을 최적화하고, 상태를 관리하며, 모범 사례를 따릅니다.