clockworklabs/spacetimedb/rust-server
Claude Code and agent skill by clockworklabs/spacetimedb
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
SpacetimeDB Rust server module SDK reference. Use when writing tables, reducers, or module logic in Rust.
Install
npx vskill@latest install clockworklabs/spacetimedb/rust-serverSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as clockworklabs/spacetimedb/rust-server.
SpacetimeDB Rust SDK Reference
Imports
`Table` is required. Without it, ctx.db.*.insert(), .iter(), .find() etc. won't compile (no method named 'insert' found).
Tables
#[spacetimedb::table(...)] on a pub struct. accessor must be snake_case:
Options: accessor = snake_case (required), public, scheduled(reducer_fn), index(...)
ctx.db accessors use the accessor name (snake_case).
Column Types
| Rust type | Notes | |
|---|---|---|
u8 / u16 / u32 / u64 / u128 | unsigned integers | |
i8 / i16 / i32 / i64 / i128 | signed integers | |
spacetimedb::sats::u256 / spacetimedb::sats::i256 | 256-bit integers | |
f32 / f64 | floats | |
bool | boolean | |
String | text | |
Vec<T> | list/array | |
Identity | user identity | |
ConnectionId | connection handle | |
Timestamp | server timestamp (microseconds since epoch) | |
TimeDuration | duration in microseconds | |
Uuid | UUID | |
Option<T> | nullable column |
Column Attributes
Defaults support compatible addition of a newly appended field. Do not place #[default(...)] on primary-key, unique, or auto-increment columns.
Indexes
Prefer #[index(btree)] inline for single-column. Multi-column uses table-level:
When you frequently look up rows by multiple columns, prefer a multi-column index over filtering by one column and looping over the results.
Reducers
Note: insert() panics on constraint violations. Use try_insert() with ? when returning Result.
DB Operations
Note: iter() and filter() return iterators. Collect to Vec if you need .sort(), .filter(), .map().
Range queries on btree indexes: filter(18..=65), filter(18..), filter(..18).
String column accessors operate on the column's owned String type, not &str. Pass a String or &String to find and delete; index filters borrow the key, as in ctx.db.product().category().filter(&"hardware".to_string()).
Lifecycle Hooks
The current connection ID is available through ctx.connection_id() (not a public field) and may be absent outside connection-scoped calls.
Views
Procedural-view table handles support indexed find and filter access, but not full-table iter(). Start a procedural view from an appropriate table index.
Declare a procedural view primary key in the view attribute:
Procedural-view primary keys are explicit schema metadata. Add one only when the view itself is required to expose a primary key; a source table's primary key is not inherited by the view.
Query-builder views use ViewContext, ctx.from, and return impl Query<Row>. Use filter for predicates and right_semijoin when the result should contain right-side rows that have a matching left-side row:
Query-builder comparisons against a String column take an owned String, for example row.label.eq("active".to_string()).
Views can also accept arguments (2.13+), after the context:
Floating-point arguments and primary keys are rejected on argument-bearing views. See client skills for SQL subscription syntax and restrictions.
Client Visibility Filters
Reducer Context API
ReducerContext (ctx) is the only source of sender identity, time, and randomness; stdlib clocks and RNG are unavailable in modules.
Environment Variables
For constrained values, derive spacetimedb::EnvironmentValue on a payload-free enum and use it as a field type (or Option<Enum>). #[env(value = "production")] on a variant supplies its exact accepted string; without it, the Rust variant name is used. #[env(values("info", "debug"))] also constrains String/Option<String> fields.
See the concepts skill for shared environment and secret-handling rules.
Scheduled Tables
To let only the scheduler run a callback, reject calls where ctx.sender() != ctx.database_identity().
Construct a connection ID from a numeric representation with ConnectionId::from_u128(value).
Inter-Database Calls (Async IDC)
A reducer calls a reducer in another database by inserting a row into an outbox table. The call is sent only if the transaction commits, runs exactly once, and runs in order with other calls through the same outbox to the same database. The sending reducer doesn't wait for it. Both databases must be on the same server.
Generate receiver bindings by listing the receiving module under dependencies in the sending database's spacetime.json, then running spacetime generate <sending-database>. Rust bindings are written to src/remote_bindings/.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/rust-server/SKILL.md
Popularity
- Repository stars
- 25,439
- Repository forks
- 1,100
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/clockworklabs/spacetimedb/rust-server)