跳到正文
cccskills
免费在 GitHub 公开

powersync

Best practices for building and maintaining applications with PowerSync: Cloud and self-hosted setup, sync configuration, client SDK usage, backend integration (Supabase, custom Postgres, MongoDB, Azure DocumentDB, MySQL, MSSQL), schema changes, watch and reactive queries (useQuery), attachments, the upload queue, and debugging. Use this skill whenever the user mentions PowerSync, a @powersync/* package (@powersync/web, @powersync/react-native, @powersync/node), the powersync Flutter/Dart package, the powersync Rust crate, wa-sqlite, offline-first sync, local-first architecture, sync rules, sync streams, uploadData, fetchCredentials, disconnectAndClear, logout or user switching in a synced app, real-time data replication, Electric Cloud migration, Electric Shapes, an app stuck on Syncing, data not syncing, or wants to add offline-capable sync to a mobile or web app, even if they do not explicitly name PowerSync.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(30)

  • SKILL.md9.0 KB
  • AGENTS.md16.6 KB
  • CLAUDE.md41 B
  • references/attachments.md22.8 KB
  • references/custom-backend.md15.1 KB
  • references/migration-from-electric.md5.7 KB
  • references/onboarding-custom.md6.1 KB
  • references/onboarding-supabase.md5.8 KB
  • references/powersync-cli.md27.8 KB
  • references/powersync-debug.md29.6 KB
  • references/powersync-overview.md3.8 KB
  • references/powersync-service.md34.8 KB
  • references/raw-tables.md9.9 KB
  • references/sdks/powersync-dart.md13.5 KB
  • references/sdks/powersync-dotnet.md23.1 KB
  • references/sdks/powersync-js-node.md7.0 KB
  • references/sdks/powersync-js-orm.md3.0 KB
  • references/sdks/powersync-js-react-native.md6.0 KB
  • references/sdks/powersync-js-react.md14.1 KB
  • references/sdks/powersync-js-tanstack.md9.6 KB
  • references/sdks/powersync-js-vue.md9.8 KB
  • references/sdks/powersync-js.md41.2 KB
  • references/sdks/powersync-kotlin.md20.8 KB
  • references/sdks/powersync-rust.md8.6 KB
  • references/sdks/powersync-swift.md13.3 KB
  • references/sqlite-extensions.md7.4 KB
  • references/supabase-auth.md19.0 KB
  • references/sync-config.md28.7 KB
  • references/terraform.md6.4 KB
  • scripts/trim.mjs19.7 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

PowerSync Skills

Use this skill to onboard a project onto PowerSync and to keep it healthy afterwards, without trial-and-error. Treat this as a guided workflow first and a reference library second.

Agents: Read AGENTS.md before proceeding. It contains the mandatory compliance rules and onboarding playbook. The Quick Rules below are a reminder, not a substitute. powersync login is PowerSync Cloud only (PAT); self-hosted does not use it.

Terminology

  • Operator — the human directing this agent (whose request you are fulfilling).
  • User — an end-user of the operator's PowerSync app (JWT subjects, the row a sync stream filters by, the person calling disconnectAndClear()).

If a sentence is ambiguous, default to the operator interpretation. Full legend in AGENTS.md.

Quick Rules

  • CLI-first. Use the PowerSync CLI for all operations. Do not hand-write config files. See references/powersync-cli.md.
  • Ask, don't assume. Ask the operator: Cloud vs self-hosted, and which backend (Supabase, Postgres, MongoDB, Azure DocumentDB, MySQL, MSSQL). Do not default to Supabase.
  • Backend before frontend. Deploy sync config and verify the service before writing app code.
  • Sync Streams for new projects. Sync Rules are legacy.
  • Keep credentials in .env, never hardcoded. Record URLs and keys in .env as they become available; config (!env) and app code read from there.
  • Default scope on existing projects: sync-config only. Do not edit service.yaml or cli.yaml unless the operator explicitly authorized service/infra changes in this conversation.
  • Confirm the target instance before any mutating command (deploy, destroy, stop, link --create, pull instance). Never deploy to an instance not authorized by the operator. Treat production as off-limits unless explicitly approved.
  • Use project memory. If your harness supports it, persist the CLI invocation, sync-config path, authorized instance ids + environment (dev/staging/prod), and allowed scope of changes. Verify saved values still match reality before acting on them. See AGENTS.md § "Continuous Use & Guardrails".

First Use in a Repo: Offer to Trim (agents)

This copy ships reference files for every PowerSync platform. On your first use of this skill in a repo, check for .trim-state.json next to this file. If it exists, the operator already decided; skip this section.

Otherwise run node scripts/trim.mjs from this skill's directory. The default run is a read-only report: it detects which PowerSync platforms this repo uses and lists the reference files this copy does not need. It works on this installed copy only, makes no network requests, and is reversible by reinstalling the skill. If it refuses (shared or source install) or detects no PowerSync usage yet, skip this section silently. Otherwise show the report to the operator and ask whether to trim this installed copy. Never trim without explicit operator approval.

  • Operator approves: run node scripts/trim.mjs --apply (add --keep <platforms> for platforms the operator wants to keep anyway).
  • Operator declines: run node scripts/trim.mjs --decline so the operator is not asked again.

Reinstalling or npx skills update restores the full copy and clears the recorded decision; offering again after an update is expected.

What to Load for Your Task

TaskStart withLoad on demand
Supabase + PowerSyncreferences/onboarding-supabase.mdreferences/supabase-auth.md, references/sync-config.md, SDK files
Custom backend (non-Supabase)references/onboarding-custom.mdreferences/custom-backend.md, references/sync-config.md, SDK files
New project setupreferences/powersync-cli.md + references/powersync-service.mdreferences/sync-config.md, SDK files
Migrating from Electric Cloudreferences/migration-from-electric.mdreferences/sync-config.md, SDK files
Self-hosting / service configreferences/powersync-service.md + references/powersync-cli.mdreferences/sync-config.md
Terraform / IaC provisioningreferences/terraform.mdreferences/sync-config.md, references/supabase-auth.md (if Supabase source)
Writing sync configreferences/sync-config.md—
Debugging sync issuesreferences/powersync-debug.md—
Raw Tables (advanced)references/raw-tables.md—
Attachmentsreferences/attachments.md—
Architecture overviewreferences/powersync-overview.md—
SQLite extensions (vector search, FTS5, custom tokenizers)references/sqlite-extensions.md—

SDK Reference Files

JavaScript / TypeScript

Always load references/sdks/powersync-js.md for any JS/TS project, then load the applicable framework file.

FrameworkFileLoad early if…
React / Next.jsreferences/sdks/powersync-js-react.mdVite + React project — contains the required vite.config.ts setup (optimizeDeps.exclude, worker.format: 'es') needed before installing packages
React Native / Exporeferences/sdks/powersync-js-react-native.md
Vue / Nuxtreferences/sdks/powersync-js-vue.md
Node.js / Electronreferences/sdks/powersync-js-node.md
TanStackreferences/sdks/powersync-js-tanstack.md
Drizzle / Kysely ORMreferences/sdks/powersync-js-orm.mdProject uses Drizzle or Kysely

Other SDKs

| Platform | File | |----------| | Dart / Flutter | references/sdks/powersync-dart.md | | .NET | references/sdks/powersync-dotnet.md | | Kotlin | references/sdks/powersync-kotlin.md | | Swift | references/sdks/powersync-swift.md | | Rust | references/sdks/powersync-rust.md |

Key Rules to Apply Without Being Asked

  • Never define the id column in a PowerSync table schema; it is created automatically.
  • Use column.integer for booleans and column.text for ISO date strings.
  • connect() is fire-and-forget. Use waitForFirstSync() if you need readiness.
  • Call .connect() once per session. Do not call it again on window focus events, token refreshes, or network changes; redundant calls open additional sync connections.
  • transaction.complete() is mandatory or the upload queue stalls permanently.
  • On user sign-out, choose based on what data may remain on the device: if the same user will return and keeping data is acceptable, use disconnect() so the next session resumes without re-downloading. If visible rows must be hidden but PowerSync's internal copy may stay, use disconnectAndClear(soft: true), which deletes synced rows but keeps the internal copy, so reconnecting as the same user skips a full re-download in most cases. If no synced data may remain, use the default disconnectAndClear(). Never retain one user's data for a different user.
  • A 4xx response from uploadData blocks the upload queue permanently; return 2xx for validation errors.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

报告此技能的问题