spacetimedb

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Entry point for the SpacetimeDB skill collection. SpacetimeDB combines a database, server-side application logic, and realtime client sync into one programmable backend.
SpacetimeDB技能集合的入口。SpacetimeDB将数据库、服务端应用逻辑和实时客户端同步整合为一个可编程后端。

How to use this skill

使用本技能的方法

  1. Find the specialized skill in the router below that best matches the task.
  2. Load that skill's
    SKILL.md
    and follow its guidance.
  3. Open only the referenced Markdown files that match the current subtask.
  4. If no sub-skill fits, search copied references in the most likely skill before falling back to external docs.
Do not load every SpacetimeDB reference file by default. Start with the focused skill body, then load a reference only when the body says the details are needed or the task requires exact API syntax.
  1. 在下方的路由中找到与任务最匹配的专项技能。
  2. 加载该技能的
    SKILL.md
    并遵循其指引。
  3. 仅打开与当前子任务匹配的参考Markdown文件。
  4. 如果没有合适的子技能,先在最相关的技能中搜索已复制的参考内容,再求助外部文档。
默认情况下请勿加载所有SpacetimeDB参考文件。先从专项技能主体内容开始,仅当主体内容说明需要详细信息或任务要求精确API语法时,再加载参考文件。

Core model

核心模型

  • A database is a published instance of a module; the module defines tables, reducers, procedures, views, and public client surface.
  • Tables store state. Public tables can be subscribed to by clients; private tables are server-only unless exposed through views or reducers.
  • Reducers are transactional entrypoints for state changes. Failed reducers roll back their table mutations.
  • Procedures can return values and perform external work such as HTTP requests; open transactions explicitly when they need database writes.
  • Views expose derived, read-only data. Prefer anonymous views when the result does not depend on the caller.
  • Clients use generated bindings, connect with
    DbConnection
    , subscribe to rows, read the local cache, and invoke reducers or procedures.
For longer descriptions and trigger keywords for every skill, see references/index.md.
  • 数据库是模块的已发布实例;模块定义了表、reducer、存储过程、视图和面向客户端的公共接口。
  • 表用于存储状态。公共表可被客户端订阅;私有表默认仅服务端可见,除非通过视图或reducer暴露。
  • Reducer是状态变更的事务性入口。执行失败的reducer会回滚其对表的修改。
  • 存储过程可以返回值并执行外部操作(如HTTP请求);当需要写入数据库时,需显式开启事务。
  • 视图用于暴露派生的只读数据。当结果不依赖调用者时,优先使用匿名视图。
  • 客户端使用生成的绑定,通过
    DbConnection
    连接,订阅数据行,读取本地缓存,并调用reducer或存储过程。
如需每个技能的详细说明和触发关键词,请查看references/index.md

Skill router

技能路由

Foundations

基础部分

SkillLoad when...
spacetimedb-quickstartsInstalling SpacetimeDB, understanding the architecture, starting a new app, or choosing a framework quickstart.
spacetimedb-cliRunning
spacetime
commands:
init
,
build
,
publish
,
generate
,
call
,
sql
,
logs
,
dev
, server configuration, or standalone config.
spacetimedb-databasesCreating, developing, publishing, migrating, or operating SpacetimeDB database modules.
spacetimedb-upgradeMigrating projects from SpacetimeDB 1.0 to 2.0 or fixing code affected by those breaking changes.
技能加载时机
spacetimedb-quickstarts安装SpacetimeDB、理解架构、启动新应用或选择框架快速入门时。
spacetimedb-cli执行
spacetime
命令时:
init
build
publish
generate
call
sql
logs
dev
、服务器配置或独立部署配置。
spacetimedb-databases创建、开发、发布、迁移或运维SpacetimeDB数据库模块时。
spacetimedb-upgrade将项目从SpacetimeDB 1.0迁移至2.0或修复由破坏性变更影响的代码时。

Module Schema And Logic

模块架构与逻辑

SkillLoad when...
spacetimedb-tablesDefining tables, columns, indexes, constraints, primary keys, event tables, schedule tables, access permissions, or table performance.
spacetimedb-reducersWriting reducers, lifecycle reducers, reducer context code, scheduled reducers, table mutations, or reducer error handling.
spacetimedb-proceduresWriting procedures, calling reducers from procedures, making HTTP requests, or returning procedure values.
spacetimedb-viewsDefining views, view arguments, SQL-backed projections, and client-facing derived data.
spacetimedb-authAuthentication, SpacetimeAuth, Auth0, Clerk, auth claims, authorization, row-level security, or rejecting client connections.
技能加载时机
spacetimedb-tables定义表、列、索引、约束、主键、事件表、调度表、访问权限或优化表性能时。
spacetimedb-reducers编写reducer、生命周期reducer、reducer上下文代码、调度reducer、表修改或处理reducer错误时。
spacetimedb-procedures编写存储过程、从存储过程调用reducer、发起HTTP请求或返回存储过程结果时。
spacetimedb-views定义视图、视图参数、基于SQL的投影或面向客户端的派生数据时。
spacetimedb-auth处理认证、SpacetimeAuth、Auth0、Clerk、认证声明、授权、行级安全(RLS)或拒绝客户端连接时。

Clients

客户端

SkillLoad when...
spacetimedb-clientsGeneral client SDK concepts: codegen, connection lifecycle, local cache, subscriptions, reducer invocation, and update semantics.
spacetimedb-client-typescriptTypeScript, JavaScript, React, Vue, Svelte, browser, Node, Bun, Deno, Next.js, Nuxt, Remix, TanStack, Angular, or generated TS bindings.
spacetimedb-client-rustRust client SDK usage, Rust generated bindings, Rust connection code, callbacks, subscriptions, and reducer calls.
spacetimedb-client-c-sharpC# or Unity client SDK usage, generated C# bindings, callbacks, subscriptions, reducer calls, and Unity integration.
spacetimedb-client-unrealUnreal Engine client SDK usage, Unreal generated bindings, connection ticking, subscriptions, and reducers.
技能加载时机
spacetimedb-clients涉及通用客户端SDK概念时:代码生成、连接生命周期、本地缓存、订阅、reducer调用和更新语义。
spacetimedb-client-typescript涉及TypeScript、JavaScript、React、Vue、Svelte、浏览器、Node、Bun、Deno、Next.js、Nuxt、Remix、TanStack、Angular或生成的TS绑定时。
spacetimedb-client-rust使用Rust客户端SDK、Rust生成绑定、Rust连接代码、回调、订阅和reducer调用时。
spacetimedb-client-c-sharp使用C#或Unity客户端SDK、生成的C#绑定、回调、订阅、reducer调用和Unity集成时。
spacetimedb-client-unreal使用Unreal Engine客户端SDK、Unreal生成绑定、连接心跳、订阅和reducer时。

Operations And Reference

运维与参考

SkillLoad when...
spacetimedb-deployDeploying to Maincloud, self-hosting, standalone service setup, key rotation, logging, or PGWire.
spacetimedb-httpUsing HTTP endpoints for identity, database operations, reducer calls, SQL, or authorization headers.
spacetimedb-sqlWriting SpacetimeDB SQL for subscriptions, CLI queries, HTTP SQL, DML, literals, identifiers, or SQL performance.
spacetimedb-serializationBSATN, SATS JSON, AlgebraicType/AlgebraicValue encoding, WebAssembly ABI, or low-level module host calls.
spacetimedb-tutorialsFollowing or adapting chat app, Unity Blackhol.io, or Unreal Blackhol.io tutorials.
技能加载时机
spacetimedb-deploy部署至Maincloud、自托管、独立服务设置、密钥轮换、日志或PGWire时。
spacetimedb-http使用HTTP端点处理身份认证、数据库操作、reducer调用、SQL或授权头时。
spacetimedb-sql编写SpacetimeDB SQL用于订阅、CLI查询、HTTP SQL、DML、字面量、标识符或优化SQL性能时。
spacetimedb-serialization涉及BSATN、SATS JSON、AlgebraicType/AlgebraicValue编码、WebAssembly ABI或底层模块宿主调用时。
spacetimedb-tutorials学习或改编聊天应用、Unity Blackhol.io或Unreal Blackhol.io教程时。

Fallback

回退方案

If the task references a SpacetimeDB API not covered by the router, search the copied reference files in the most likely skill's
references/
directory, then inspect
src/raw-data-output
if this repository is available.
如果任务涉及路由未覆盖的SpacetimeDB API,请先在最相关技能的
references/
目录中搜索已复制的参考文件;若本仓库可用,再检查
src/raw-data-output
目录。