workspace-api
$
npx mdskill add EpicenterHQ/epicenter/workspace-apiManages workspace schemas, data access, and collaboration features in Epicenter
- Enables defining and managing workspace tables, KV stores, and actions
- Relies on Yjs for CRDTs, Svelte for reactivity, and Arktype for validation
- Applies migrations and versioning to evolve workspace data structures
- Provides APIs for real-time collaboration and persistent data access
SKILL.md
.github/skills/workspace-apiView on GitHub ↗
--- name: workspace-api description: 'Epicenter workspace API patterns: `defineTable`, `defineKv`, migrations, actions, `attach*` primitives, `openCollaboration`, and workspace connections. Use when editing workspace schemas, table/KV access, actions, attachments, or collaboration setup.' metadata: author: epicenter version: '6.0' --- # Workspace API Use this skill for Epicenter workspace definitions, table and KV access, action factories, attachment composition, collaboration setup, and workspace connections. ## Reference Repositories - [Yjs](https://github.com/yjs/yjs): CRDT framework used by the workspace data layer ## Related Skills - `yjs`: Yjs CRDT patterns and shared types - `svelte`: reactive wrappers such as `fromTable` and `fromKv`, plus commit-on-blur workspace inputs - `attach-primitive`: the full contract and invariants every `attach*` function must follow - `arktype`: runtime schema and branded ID validation ## When To Apply This Skill Use this skill when you are: - Defining a table or KV store with `defineTable()` or `defineKv()`. - Adding a version or migration to an existing table definition. - Reading, writing, or observing table or KV data. - Creating actions with `defineMutation` or `defineQuery`. - Composing a live document with a direct builder and `attach*` primitives. - Adding `createDisposableCache(builder)` for per-row or fan-out documents. - Attaching persistence, collaboration, encryption, or materializers. - Writing server-side Bun scripts with `connectWorkspace()`. ## Core Rules - Tables always include `_v` with a number literal. Use single-version shorthand until a table actually needs evolution. - Derive row types with `InferTableRow<typeof tableDefinition>` in the same module that defines the table. Consumers import the type from the workspace definition module. - Do not re-derive row types from runtime table methods or relay them through state files. - KV stores use `defineKv(schema, defaultValue)`. Prefer one scalar per dot-namespaced key unless the value is a true atomic object. - Every table `id` and string foreign key uses a branded type plus a co-located generator. Call sites use the generator, never a direct cast. - Isomorphic actions belong in `workspace/actions.ts` factories that close over `tables` and `batch`. Runtime-specific actions live in the runtime builder where browser, Node, Tauri, or extension APIs are in scope. - Local action calls see the handler shape directly. Remote dispatch wraps raw values and failures in `Promise<Result<T, DispatchError>>`. Read the action return reference before changing handler failure behavior. - Every action method inside the workspace action object should have JSDoc that adds developer-facing value beyond the short `description` field. - Keep `workspace/definition.ts` and `workspace/actions.ts` isomorphic. Keep `client.ts` runtime-specific and outside the `workspace/` folder. - Compose attachments inline in the builder after creating the `Y.Doc`. Avoid wrapper helpers that hide ordering unless the abstraction owns a real invariant. - Use `connectWorkspace()` for one-off Bun scripts that need a connected workspace without app UI bootstrapping. ## Reference Map - [Schema definition patterns](references/schema-definition-patterns.md): `defineTable`, `defineKv`, row type inference, KV scalar design, and branded IDs. - [Actions, layout, and attachments](references/actions-layout-and-attachments.md): action factories, JSDoc, workspace file layout, attachment ordering, `connectWorkspace`, and `_v`. - [Action return shapes](references/action-return-shapes.md): local vs remote action return contracts and error normalization. - [Table, KV, CRUD, and observation](references/table-kv-crud-observation.md): table/KV read, write, observe, and derived-state details. - [Table migrations](references/table-migrations.md): migration rules and version evolution examples. - [Primitive API](references/primitive-api.md): lower-level primitive contracts and composition details.
More from EpicenterHQ/epicenter
- agent-goalWrite `/goal` prompts for long-running agent work in Codex or Claude Code. Use for slash goal, agent goal, durable objective, autonomous coding run.
- approachability-auditReview code as a new TypeScript developer. Use when code feels indirect, clever, hard to follow, or needs a pass on abstractions, names, first-read clarity.
- arktypeArktype: runtime validation, discriminated unions with .merge()/.or(), spread keys. Use when mentioning arktype, type(), union types, command/event schemas.
- attach-primitiveContract and invariants for `attach*` composition primitives in `packages/workspace` (side-effectful building blocks like attachIndexedDb, attachSqlite, attachBroadcastChannel, attachEncryption, attachTable, openCollaboration), and when to use `create*` (pure construction) instead. Use when writing or reviewing an `attach*` or `create*` function, naming a new workspace primitive, composing inside a workspace builder, or deciding whether a primitive registers listeners at call time.
- authEpicenter auth packages: `@epicenter/auth`, `@epicenter/auth-svelte`, OAuth sessions, identity state, auth-owned fetch/WebSocket, and workspace lifecycle binding. Use when editing Epicenter auth clients, session state, hosted sign-in, or auth/workspace integration.
- autumnAutumn billing in Epicenter: `autumn.config.ts`, `autumn-js` credit checks, `atmn` CLI, plan gates, and metered AI usage. Use when changing billing, pricing, credits, plan access, refunds, or usage events.
- better-auth-best-practicesBetter Auth server/client setup: `auth.ts`, generated schema, DB adapters, sessions, cookies, env vars, and plugins. Use when mentioning Better Auth, betterauth, auth handlers, OAuth, email/password, or session configuration.
- better-auth-security-best-practicesBetter Auth security hardening: rate limits, secrets, CSRF, trusted origins, cookies, sessions, OAuth tokens, and audit logging. Use when reviewing auth security, brute-force protection, token handling, or deployment safety.
- change-proposalPresent proposed code changes visually before implementing. Use when: "show me options", "compare approaches", "what should we do", or when changes need before/after comparison.
- claude-code-consultUse this skill when the user asks to consult Claude, ask Claude Code, get another model's take, run a taste check, find cleaner options, or prepare a Claude prompt. Create a bounded second-opinion prompt or run a read-only Claude Code consult, then verify Claude's claims against local files.