electric-sql
Build local-first applications with ElectricSQL — sync Postgres data to client devices in real-time. Use when someone asks to "sync database to client", "local-first app", "ElectricSQL", "offline-first sync", "real-time Postgres sync", "sync Postgres to SQLite", or "build an app that works offline". Covers shape-based sync, real-time subscriptions, offline support, and conflict resolution.
What this skill does
# ElectricSQL
## Overview
ElectricSQL syncs Postgres data to client applications in real-time. Instead of fetching data from an API, the data lives locally on the device — queries are instant, the app works offline, and changes sync automatically when connectivity returns. Think "Postgres replication to the browser." Define shapes (subsets of your data) and Electric keeps them in sync.
## When to Use
- Apps that must work offline (field service, mobile, travel)
- Real-time collaborative features (shared lists, dashboards)
- Low-latency reads — querying local data is instant
- Reducing API calls — data is already on the client
- Multi-device sync (phone, tablet, desktop see same data)
## Instructions
### Setup
```bash
# Server: Electric sync service
docker run -e DATABASE_URL=postgresql://... -p 3000:3000 electricsql/electric
# Client
npm install @electric-sql/react
```
### Define Shapes (What to Sync)
```typescript
// shapes.ts — Define what data to sync to the client
/**
* Shapes are "live queries" — subsets of your Postgres data
* that stay in sync on the client. Only sync what the user needs.
*/
import { ShapeStream } from "@electric-sql/client";
// Sync all todos for a specific user
const stream = new ShapeStream({
url: "http://localhost:3000/v1/shape",
params: {
table: "todos",
where: `user_id = '${userId}'`,
},
});
// Stream delivers initial data + real-time updates
stream.subscribe((messages) => {
for (const msg of messages) {
if (msg.headers.operation === "insert") {
console.log("New todo:", msg.value);
}
}
});
```
### React Integration
```tsx
// components/TodoList.tsx — Real-time synced todo list
import { useShape } from "@electric-sql/react";
interface Todo {
id: string;
title: string;
completed: boolean;
created_at: string;
}
export function TodoList({ userId }: { userId: string }) {
// Data syncs automatically — no loading states for reads
const { data: todos, isLoading } = useShape<Todo>({
url: "http://localhost:3000/v1/shape",
params: {
table: "todos",
where: `user_id = '${userId}'`,
columns: ["id", "title", "completed", "created_at"],
},
});
if (isLoading) return <div>Loading initial sync...</div>;
// Reads are instant — data is local
const active = todos.filter((t) => !t.completed);
const done = todos.filter((t) => t.completed);
return (
<div>
<h2>Active ({active.length})</h2>
{active.map((todo) => (
<div key={todo.id}>
<input
type="checkbox"
onChange={() => toggleTodo(todo.id)}
/>
{todo.title}
</div>
))}
<h2>Completed ({done.length})</h2>
{done.map((todo) => (
<div key={todo.id} style={{ textDecoration: "line-through" }}>
{todo.title}
</div>
))}
</div>
);
}
// Writes go through your API (Electric syncs the result back)
async function toggleTodo(id: string) {
await fetch(`/api/todos/${id}/toggle`, { method: "PATCH" });
// No need to refetch — Electric syncs the update automatically
}
```
### Offline Support
```typescript
// offline.ts — Electric handles offline automatically
/**
* When the device goes offline, reads still work (data is local).
* When connectivity returns, Electric syncs missed changes.
*
* For writes during offline, queue them and replay on reconnect:
*/
const writeQueue: Array<() => Promise<void>> = [];
async function createTodo(title: string) {
const action = () => fetch("/api/todos", {
method: "POST",
body: JSON.stringify({ title }),
});
if (navigator.onLine) {
await action();
} else {
writeQueue.push(action); // Queue for later
}
}
// Replay queued writes when back online
window.addEventListener("online", async () => {
while (writeQueue.length > 0) {
const action = writeQueue.shift()!;
await action();
}
});
```
## Examples
### Example 1: Build an offline-capable task manager
**User prompt:** "Build a task manager that works without internet and syncs when back online."
The agent will set up Electric with shapes for user tasks, local reads with React hooks, write queue for offline mutations, and automatic sync on reconnect.
### Example 2: Real-time dashboard
**User prompt:** "Build a dashboard that shows live data from our Postgres database without polling."
The agent will configure Electric shapes for dashboard metrics, subscribe to real-time updates, and render charts that update instantly as the database changes.
## Guidelines
- **Shapes define what syncs** — sync subsets of data, not entire tables
- **Reads are instant** — data is local, no network round-trip
- **Writes go through your API** — Electric syncs the result back to all clients
- **`where` for filtering** — only sync data the user should see
- **`columns` for projection** — reduce sync payload to needed fields
- **Postgres is the source of truth** — Electric reads the WAL (Write-Ahead Log)
- **No schema changes needed** — works with your existing Postgres schema
- **Shape streams are resumable** — reconnects sync from where they left off
- **For offline writes, queue locally** — replay when connectivity returns
- **Use with any framework** — React hook is convenient, but the core client works anywhere
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.