spacetimedb-procedures
Use when writing SpacetimeDB procedures, returning values, making HTTP requests from server code, accessing the database from procedures, calling reducers from procedures, or integrating external APIs. Triggers on: procedure, procedures, HTTP request, return value, external API, AI API, call reducer from procedure.
How do I install this agent skill?
npx skills add https://github.com/danmossa/spacetimedb-skills --skill spacetimedb-proceduresIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill provides legitimate documentation and code examples for implementing server-side procedures in SpacetimeDB. It includes clear security warnings regarding the handling of secrets, tokens, and response bodies, as well as best practices for managing database transactions alongside HTTP requests. No malicious patterns or behaviors were detected.
- Socketwarn
1 alert: gptAnomaly
- Snykpass
Risk: LOW · No issues
What does this agent skill do?
Use this skill for procedures and server-side work that is not a reducer transaction entrypoint.
Core procedure patterns
Procedures are server functions that can return values and perform work that reducers should not do, including external HTTP calls. Use reducers for client-invoked transactional state changes; use procedures when the caller needs a return value or the function must do external work.
TypeScript procedure shape:
export const add_two_numbers = spacetimedb.procedure(
{ lhs: t.u32(), rhs: t.u32() },
t.u64(),
(_ctx, { lhs, rhs }) => BigInt(lhs) + BigInt(rhs),
);
Language notes:
- TypeScript procedures return the declared
t.*type and receive(ctx, args). - C# procedures are unstable; add
#pragma warning disable STDB_UNSTABLEand use[SpacetimeDB.Procedure]. - Rust procedures are unstable; enable the
unstablefeature and use#[spacetimedb::procedure]with&mut ProcedureContext. - C++ procedures are unstable; define
SPACETIMEDB_UNSTABLE_FEATURESbefore including the header.
Transactions and HTTP
- Procedures do not automatically run in a transaction.
- Wrap database writes in the language's transaction helper, such as TypeScript
ctx.withTx(...). - Do not hold a transaction open while making HTTP requests. Fetch first, then open a short transaction to write results or call reducer logic.
- Treat external API secrets and failures explicitly; do not log tokens or response bodies that may contain private data.
- If a procedure calls reducer logic, keep the shared state-changing logic transaction-safe and reusable from reducer context.
Reference map
| Need | Open |
|---|---|
| Procedure definitions, database access, HTTP, reducer calls, and return values | references/functions-procedures.md |
Guidance
- Use reducers for transactional client-invoked state changes; use procedures when the reference indicates return values or external work are appropriate.
- Keep HTTP request and external API handling explicit about secrets, failures, and runtime expectations.
- Route table mutation details to spacetimedb-reducers or spacetimedb-tables as needed.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/danmossa/spacetimedb-skills/spacetimedb-procedures">View spacetimedb-procedures on skillZs</a>