[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F3X234KGTABJDXPYQWTMDG":3,"skill-same:01M6F3X234KGTABJDXPYQWTMDG":75},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":55,"repositoryHtmlUrl":56,"repositoryHomepageUrl":57,"ownerHtmlUrl":58,"ownerBlogUrl":6,"ownerDescription":59,"updatedAt":60,"install":61,"resources":74},"01M6F3X234KGTABJDXPYQWTMDG","electric-schema-shapes",null,"Design Postgres schema and Electric shape definitions together for a new feature. Covers single-table shape constraint, cross-table joins using multiple shapes, WHERE clause design for tenant isolation, column selection for bandwidth optimization, replica mode choice (default vs full for old_value), enum casting in WHERE clauses, and txid handshake setup with pg_current_xact_id() for optimistic writes. Load when designing database tables for use with Electric shapes.","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Felectric-sql\u002Felectric\u002Felectric-schema-shapes\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"electric schema shapes","schema","default","with","casting","guides","handshake","id","feature","postgres","selection","design","use","new feature","choice","Optimization","website","database","core","sql","2026-11-10 10:12:30",false,"---\nname: electric-schema-shapes\ndescription: >\n  Design Postgres schema and Electric shape definitions together for a new\n  feature. Covers single-table shape constraint, cross-table joins using\n  multiple shapes, WHERE clause design for tenant isolation, column selection\n  for bandwidth optimization, replica mode choice (default vs full for\n  old_value), enum casting in WHERE clauses, and txid handshake setup with\n  pg_current_xact_id() for optimistic writes. Load when designing database\n  tables for use with Electric shapes.\ntype: core\nlibrary: electric\nlibrary_version: '1.5.10'\nrequires:\n  - electric-shapes\nsources:\n  - 'electric-sql\u002Felectric:AGENTS.md'\n  - 'electric-sql\u002Felectric:website\u002Fdocs\u002Fguides\u002Fshapes.md'\n---\n\nThis skill builds on electric-shapes. Read it first for ShapeStream configuration.\n\n# Electric — Schema and Shapes\n\n## Setup\n\nDesign tables knowing each shape syncs one table. For cross-table data, use multiple shapes with client-side joins.\n\n```sql\n-- Schema designed for Electric shapes\nCREATE TABLE todos (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  org_id UUID NOT NULL,\n  text TEXT NOT NULL,\n  completed BOOLEAN DEFAULT false,\n  created_at TIMESTAMPTZ DEFAULT now()\n);\n\nALTER TABLE todos REPLICA IDENTITY FULL;\n```\n\n```ts\nimport { ShapeStream } from '@electric-sql\u002Fclient'\n\nconst todoStream = new ShapeStream({\n  url: '\u002Fapi\u002Ftodos', \u002F\u002F Proxy sets: table=todos, where=org_id=$1\n})\n```\n\n## Core Patterns\n\n### Cross-table data with multiple shapes\n\n```ts\n\u002F\u002F Each shape syncs one table — join client-side\nconst todoStream = new ShapeStream({ url: '\u002Fapi\u002Ftodos' })\nconst userStream = new ShapeStream({ url: '\u002Fapi\u002Fusers' })\n\n\u002F\u002F With TanStack DB, use .join() in live queries:\n\u002F\u002F q.from({ todo: todoCollection })\n\u002F\u002F   .join({ user: userCollection }, ({ todo, user }) => eq(todo.userId, user.id))\n```\n\n### Choose replica mode\n\n```ts\n\u002F\u002F Default: only changed columns sent on update\nconst stream = new ShapeStream({ url: '\u002Fapi\u002Ftodos' })\n\n\u002F\u002F Full: all columns + old_value on updates (more bandwidth, needed for diffs)\nconst stream = new ShapeStream({\n  url: '\u002Fapi\u002Ftodos',\n  params: { replica: 'full' },\n})\n```\n\n### Backend txid handshake for optimistic writes\n\nCall `pg_current_xact_id()::xid::text` inside the same transaction as your mutation. If you query it outside the transaction, you get a different txid and the client will never reconcile.\n\n```ts\n\u002F\u002F API endpoint — txid MUST be in the same transaction as the INSERT\napp.post('\u002Fapi\u002Ftodos', async (req, res) => {\n  const client = await pool.connect()\n  try {\n    await client.query('BEGIN')\n    const result = await client.query(\n      'INSERT INTO todos (id, text, org_id) VALUES ($1, $2, $3) RETURNING id',\n      [crypto.randomUUID(), req.body.text, req.body.orgId]\n    )\n    const txResult = await client.query(\n      'SELECT pg_current_xact_id()::xid::text AS txid'\n    )\n    await client.query('COMMIT')\n    \u002F\u002F txid accepts number | bigint | `${bigint}`\n    res.json({ id: result.rows[0].id, txid: parseInt(txResult.rows[0].txid) })\n  } finally {\n    client.release()\n  }\n})\n```\n\n```ts\n\u002F\u002F Client awaits txid before dropping optimistic state\nawait todoCollection.utils.awaitTxId(txid)\n```\n\n## Common Mistakes\n\n### HIGH Designing shapes that span multiple tables\n\nWrong:\n\n```ts\nconst stream = new ShapeStream({\n  url: '\u002Fapi\u002Fdata',\n  params: {\n    table: 'todos JOIN users ON todos.user_id = users.id',\n  },\n})\n```\n\nCorrect:\n\n```ts\nconst todoStream = new ShapeStream({ url: '\u002Fapi\u002Ftodos' })\nconst userStream = new ShapeStream({ url: '\u002Fapi\u002Fusers' })\n```\n\nShapes are single-table only. Cross-table data requires multiple shapes joined client-side via TanStack DB live queries.\n\nSource: `AGENTS.md:104-105`\n\n### MEDIUM Using enum columns without casting to text in WHERE\n\nWrong:\n\n```ts\n\u002F\u002F Proxy route\noriginUrl.searchParams.set('where', \"status IN ('active', 'done')\")\n```\n\nCorrect:\n\n```ts\noriginUrl.searchParams.set('where', \"status::text IN ('active', 'done')\")\n```\n\nEnum types in WHERE clauses require explicit `::text` cast. Without it, the query may fail or return unexpected results.\n\nSource: `packages\u002Fsync-service\u002Flib\u002Felectric\u002Freplication\u002Feval\u002Fenv\u002Fknown_functions.ex`\n\n### HIGH Not setting up txid handshake for optimistic writes\n\nWrong:\n\n```ts\n\u002F\u002F Backend: just INSERT, return id\napp.post('\u002Fapi\u002Ftodos', async (req, res) => {\n  const result = await db.query(\n    'INSERT INTO todos (text) VALUES ($1) RETURNING id',\n    [req.body.text]\n  )\n  res.json({ id: result.rows[0].id })\n})\n```\n\nCorrect:\n\n```ts\n\u002F\u002F Backend: INSERT and return txid in same transaction\napp.post('\u002Fapi\u002Ftodos', async (req, res) => {\n  const client = await pool.connect()\n  try {\n    await client.query('BEGIN')\n    const result = await client.query(\n      'INSERT INTO todos (text) VALUES ($1) RETURNING id',\n      [req.body.text]\n    )\n    const txResult = await client.query(\n      'SELECT pg_current_xact_id()::xid::text AS txid'\n    )\n    await client.query('COMMIT')\n    res.json({ id: result.rows[0].id, txid: parseInt(txResult.rows[0].txid) })\n  } finally {\n    client.release()\n  }\n})\n```\n\nWithout txid, the UI flickers when optimistic state is dropped before the synced version arrives from Electric. The client uses `awaitTxId(txid)` to hold optimistic state until the real data syncs.\n\nSource: `AGENTS.md:116-119`\n\nSee also: electric-shapes\u002FSKILL.md — Shapes are immutable; dynamic filters require new ShapeStream instances.\nSee also: electric-orm\u002FSKILL.md — Schema design affects both shapes (read) and ORM queries (write).\n\n## Version\n\nTargets @electric-sql\u002Fclient v1.5.10.\n\n","This skill builds on electric-shapes. Read it first for ShapeStream configuration.\n\n# Electric — Schema and Shapes\n\n## Setup\n\nDesign tables knowing each shape syncs one table. For cross-table data, use multiple shapes with client-side joins.\n\n```sql\n-- Schema designed for Electric shapes\nCREATE TABLE todos (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  org_id UUID NOT NULL,\n  text TEXT NOT NULL,\n  completed BOOLEAN DEFAULT false,\n  created_at TIMESTAMPTZ DEFAULT now()\n);\n\nALTER TABLE todos REPLICA IDENTITY FULL;\n```\n\n```ts\nimport { ShapeStream } from '@electric-sql\u002Fclient'\n\nconst todoStream = new ShapeStream({\n  url: '\u002Fapi\u002Ftodos', \u002F\u002F Proxy sets: table=todos, where=org_id=$1\n})\n```\n\n## Core Patterns\n\n### Cross-table data with multiple shapes\n\n```ts\n\u002F\u002F Each shape syncs one table — join client-side\nconst todoStream = new ShapeStream({ url: '\u002Fapi\u002Ftodos' })\nconst userStream = new ShapeStream({ url: '\u002Fapi\u002Fusers' })\n\n\u002F\u002F With TanStack DB, use .join() in live queries:\n\u002F\u002F q.from({ todo: todoCollection })\n\u002F\u002F   .join({ user: userCollection }, ({ todo, user }) => eq(todo.userId, user.id))\n```\n\n### Choose replica mode\n\n```ts\n\u002F\u002F Default: only changed columns sent on update\nconst stream = new ShapeStream({ url: '\u002Fapi\u002Ftodos' })\n\n\u002F\u002F Full: all columns + old_value on updates (more bandwidth, needed for diffs)\nconst stream = new ShapeStream({\n  url: '\u002Fapi\u002Ftodos',\n  params: { replica: 'full' },\n})\n```\n\n### Backend txid handshake for optimistic writes\n\nCall `pg_current_xact_id()::xid::text` inside the same transaction as your mutation. If you query it outside the transaction, you get a different txid and the client will never reconcile.\n\n```ts\n\u002F\u002F API endpoint — txid MUST be in the same transaction as the INSERT\napp.post('\u002Fapi\u002Ftodos', async (req, res) => {\n  const client = await pool.connect()\n  try {\n    await client.query('BEGIN')\n    const result = await client.query(\n      'INSERT INTO todos (id, text, org_id) VALUES ($1, $2, $3) RETURNING id',\n      [crypto.randomUUID(), req.body.text, req.body.orgId]\n    )\n    const txResult = await client.query(\n      'SELECT pg_current_xact_id()::xid::text AS txid'\n    )\n    await client.query('COMMIT')\n    \u002F\u002F txid accepts number | bigint | `${bigint}`\n    res.json({ id: result.rows[0].id, txid: parseInt(txResult.rows[0].txid) })\n  } finally {\n    client.release()\n  }\n})\n```\n\n```ts\n\u002F\u002F Client awaits txid before dropping optimistic state\nawait todoCollection.utils.awaitTxId(txid)\n```\n\n## Common Mistakes\n\n### HIGH Designing shapes that span multiple tables\n\nWrong:\n\n```ts\nconst stream = new ShapeStream({\n  url: '\u002Fapi\u002Fdata',\n  params: {\n    table: 'todos JOIN users ON todos.user_id = users.id',\n  },\n})\n```\n\nCorrect:\n\n```ts\nconst todoStream = new ShapeStream({ url: '\u002Fapi\u002Ftodos' })\nconst userStream = new ShapeStream({ url: '\u002Fapi\u002Fusers' })\n```\n\nShapes are single-table only. Cross-table data requires multiple shapes joined client-side via TanStack DB live queries.\n\nSource: `AGENTS.md:104-105`\n\n### MEDIUM Using enum columns without casting to text in WHERE\n\nWrong:\n\n```ts\n\u002F\u002F Proxy route\noriginUrl.searchParams.set('where', \"status IN ('active', 'done')\")\n```\n\nCorrect:\n\n```ts\noriginUrl.searchParams.set('where', \"status::text IN ('active', 'done')\")\n```\n\nEnum types in WHERE clauses require explicit `::text` cast. Without it, the query may fail or return unexpected results.\n\nSource: `packages\u002Fsync-service\u002Flib\u002Felectric\u002Freplication\u002Feval\u002Fenv\u002Fknown_functions.ex`\n\n### HIGH Not setting up txid handshake for optimistic writes\n\nWrong:\n\n```ts\n\u002F\u002F Backend: just INSERT, return id\napp.post('\u002Fapi\u002Ftodos', async (req, res) => {\n  const result = await db.query(\n    'INSERT INTO todos (text) VALUES ($1) RETURNING id',\n    [req.body.text]\n  )\n  res.json({ id: result.rows[0].id })\n})\n```\n\nCorrect:\n\n```ts\n\u002F\u002F Backend: INSERT and return txid in same transaction\napp.post('\u002Fapi\u002Ftodos', async (req, res) => {\n  const client = await pool.connect()\n  try {\n    await client.query('BEGIN')\n    const result = await client.query(\n      'INSERT INTO todos (text) VALUES ($1) RETURNING id',\n      [req.body.text]\n    )\n    const txResult = await client.query(\n      'SELECT pg_current_xact_id()::xid::text AS txid'\n    )\n    await client.query('COMMIT')\n    res.json({ id: result.rows[0].id, txid: parseInt(txResult.rows[0].txid) })\n  } finally {\n    client.release()\n  }\n})\n```\n\nWithout txid, the UI flickers when optimistic state is dropped before the synced version arrives from Electric. The client uses `awaitTxId(txid)` to hold optimistic state until the real data syncs.\n\nSource: `AGENTS.md:116-119`\n\nSee also: electric-shapes\u002FSKILL.md — Shapes are immutable; dynamic filters require new ShapeStream instances.\nSee also: electric-orm\u002FSKILL.md — Schema design affects both shapes (read) and ORM queries (write).\n\n## Version\n\nTargets @electric-sql\u002Fclient v1.5.10.\n\n",{"name":5,"type":37,"library":44,"sources":45,"requires":48,"description":50,"library_version":51},"electric",[46,47],"electric-sql\u002Felectric:AGENTS.md","electric-sql\u002Felectric:website\u002Fdocs\u002Fguides\u002Fshapes.md",[49],"electric-shapes","Design Postgres schema and Electric shape definitions together for a new feature. Covers single-table shape constraint, cross-table joins using multiple shapes, WHERE clause design for tenant isolation, column selection for bandwidth optimization, replica mode choice (default vs full for old_value), enum casting in WHERE clauses, and txid handshake setup with pg_current_xact_id() for optimistic writes. Load when designing database tables for use with Electric shapes.\n","1.5.10","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Felectric-sql\u002Felectric\u002Felectric-schema-shapes",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill electric-schema-shapes",{"tool":67,"command":68},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill electric-schema-shapes",{"tool":70,"command":71},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill electric-schema-shapes","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Felectric-sql\u002Felectric\u002Felectric-schema-shapes\u002FSKILL.md",true,[],[76,85,94,103,109,115],{"skillNo":77,"name":78,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":39},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[82,83,84],"model","model hierarchy","model hierarchy skill",{"skillNo":86,"name":87,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":39},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[91,92,93],"MCP","zoom","zoom mcp",{"skillNo":95,"name":96,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":39},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[100,101,102,92],"sdk","zoom apps sdk","apps",{"skillNo":104,"name":105,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":39},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[105],{"skillNo":110,"name":111,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":39},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[111],{"skillNo":116,"name":117,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":120,"publishedAt":39},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[117]]