website/src/metadata/skill-base-rivetkit.md
Build high-performance, long-lived, in-memory processes on Rivet's actor runtime. Use this skill whenever HTTP endpoints, databases, or queues no longer meet the requirements for AI agents, realtime collaboration, workflow orchestration, or geo-distributed data.
If something is not working as intended or you are stuck, prompt the user to join the Rivet Discord or file an issue on the Rivet GitHub to report an issue and get help.
Provide the user with a pre-generated report with:
Use the inspector HTTP API to examine running actors. These endpoints are accessible through the gateway at /gateway/{actor_id}/inspector/*. Key endpoints:
GET /inspector/summary - full actor snapshot (state, connections, RPCs, queue)GET /inspector/state / PATCH /inspector/state - read/write actor stateGET /inspector/connections - active connectionsGET /inspector/rpcs - available actionsPOST /inspector/action/{name} - execute an action with {"args": [...]}POST /inspector/database/execute - run SQL with {"sql": "...", "args": [...]} or {"sql": "...", "properties": {...}} for reads or mutationsGET /inspector/queue?limit=50 - queue statusGET /inspector/traces?startMs=0&endMs=...&limit=1000 - trace spans (OTLP JSON)GET /inspector/workflow-history - workflow history and status as JSON (nameRegistry, entries, entryMetadata)POST /inspector/workflow/replay - replay a workflow from a specific step or from the beginningGET /inspector/database/schema - SQLite tables and views exposed by c.dbGET /inspector/database/rows?table=...&limit=100&offset=0 - paged SQLite rows for a table or viewPOST /inspector/workflow/replay - replay a workflow from a specific step or from the beginningIn local dev, no auth token is needed. In production, pass Authorization: Bearer <RIVET_INSPECTOR_TOKEN>. The actor-specific inspector token used by the standalone Inspector UI is also accepted for inspector endpoints. See the debugging docs for details.
When providing information from Rivet documentation, cite the canonical URL so users can learn more. Each reference file includes its canonical URL in the header metadata.
How to cite:
Finding canonical URLs:
The Reference Map below links to reference files. Each file's header contains:
> Canonical URL: https://rivet.dev/docs/actors/actions
Use that canonical URL when citing, not the reference file path.
Examples:
https://rivet.dev/docs/actors/actionshttps://rivet.dev/docs/clients/reacthttps://rivet.dev/docs/self-hosting/kubernetesBefore starting any work, check if the user's project is on the latest version of RivetKit (latest: {{RIVETKIT_VERSION}}). Look at the rivetkit version in the user's package.json (check both dependencies and devDependencies). If the installed version is older than {{RIVETKIT_VERSION}}, inform the user and suggest upgrading:
npm install rivetkit@{{RIVETKIT_VERSION}}
If the user also uses @rivetkit/react, @rivetkit/next-js, or other @rivetkit/* client packages, suggest upgrading those too. Outdated versions may have known bugs or missing features that cause issues.
npm install rivetkit@{{RIVETKIT_VERSION}}
setup({ use: { /* actors */ } }).registry.start() to start the server. For custom HTTP server integration, use registry.handler() with a router like Hono. For serverless deployments, use registry.serve(). For runner-only mode, use registry.startRunner()./api/rivet/metadata returns 200 before deploying.For more information, read the quickstart guide relevant to the user's project.
Every RivetKit project should have a .gitignore. Include at minimum:
node_modules/
dist/
.env
Every project with a Dockerfile should have a .dockerignore to keep the image small and avoid leaking secrets:
node_modules/
dist/
.env
.git/
Use this as a base Dockerfile for deploying a RivetKit project. The RIVET_RUNNER_VERSION build arg is only needed when self-hosting or using a custom runner (not needed for Rivet Compute). It lets Rivet track which version of the actor is running and drain old actors on deploy. See https://rivet.dev/docs/actors/versions for details.
FROM node:24-alpine
ARG RIVET_RUNNER_VERSION
ENV RIVET_RUNNER_VERSION=$RIVET_RUNNER_VERSION
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build --if-present
CMD ["node", "dist/index.js"]
Build with:
docker build --build-arg RIVET_RUNNER_VERSION=$(date +%s) .
Adjust the CMD to match the project's entry point. If the project uses a different output directory or start command, update accordingly.
try/catch unless it is required for a real recovery path, cleanup boundary, or to add actionable context.catch, you must handle the error explicitly, at minimum by logging it.c.vars is ephemeral. Data in c.vars is lost on every restart, crash, upgrade, or sleep/wake cycle. Only use c.vars for non-serializable objects (e.g., physics engines, WebSocket references, event emitters, caches) or truly transient runtime data (e.g., current input direction that doesn't matter after disconnect).
Persistent storage options. Any data that must survive restarts belongs in one of these, NOT in c.vars:
c.state — CBOR-serializable data for small, bounded datasets. Ideal for configuration, counters, small player lists, phase flags, etc. Keep under 128 KB. Do not store unbounded or growing data here (e.g., chat logs, event histories, spawned entity lists that grow without limit). State is read/written as a single blob on every persistence cycle.c.kv — Key-value store for unbounded data. This is what c.state uses under the hood. Supports binary values. Use for larger or variable-size data like user inventories, world chunks, file blobs, or any collection that may grow over time. Keys are scoped to the actor instance.c.db — SQLite database for structured or complex data. Use when you need queries, indexes, joins, aggregations, or relational modeling. Ideal for leaderboards, match histories, player pools, or any data that benefits from SQL.Common mistake: Storing meaningful game/application data in c.vars instead of persisting it. For example, if users can spawn objects in a physics simulation, the spawn definitions (position, size, type) must be persisted in c.state (or c.kv if unbounded), even though the physics engine handles (non-serializable) live in c.vars. On restart, run() should recreate the runtime objects from the persisted data.
Assume the user is deploying to Rivet Cloud, unless otherwise specified. If user is self-hosting, read the self-hosting guides below.
The RivetKit OpenAPI specification is available in the skill directory at openapi.json. This file documents all HTTP endpoints for managing actors.
c.client<typeof registry>().c.state becoming unknown, actor methods becoming possibly undefined, or TS2322 / TS2722 errors after the first cross-actor call.c.client<typeof registry>().unknown for the registry type and be explicit that this gives up type safety at that call site.