.claude/skills/ts-electric-sql/SKILL.md
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.
npx skillsauth add eliferjunior/Claude electric-sqlInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
# Server: Electric sync service
docker run -e DATABASE_URL=postgresql://... -p 3000:3000 electricsql/electric
# Client
npm install @electric-sql/react
// 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);
}
}
});
// 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.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();
}
});
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.
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.
where for filtering — only sync data the user should seecolumns for projection — reduce sync payload to needed fieldsdevelopment
Expert guidance for Fireworks AI, the platform for running open-source LLMs (Llama, Mixtral, Qwen, etc.) with enterprise-grade speed and reliability. Helps developers integrate Fireworks' inference API, fine-tune models, and deploy custom model endpoints with function calling and structured output support.
development
Convert any website into clean, structured data with Firecrawl — API-first web scraping service. Use when someone asks to "turn a website into markdown", "scrape website for LLM", "Firecrawl", "extract website content as clean text", "crawl and convert to structured data", or "scrape website for RAG". Covers single-page scraping, full-site crawling, structured extraction, and LLM-ready output.
tools
Expert guidance for Firebase, Google's platform for building and scaling web and mobile applications. Helps developers set up authentication, Firestore/Realtime Database, Cloud Functions, hosting, storage, and analytics using Firebase's SDK and CLI.
development
When the user needs to build file upload functionality for a web application. Use when the user mentions "file upload," "image upload," "upload endpoint," "multipart upload," "presigned URL," "S3 upload," "file validation," "upload to cloud storage," or "accept user files." Handles upload endpoints, file validation (type, size, magic bytes), cloud storage integration, and upload status tracking. For image/video processing after upload, see media-transcoder.