instantdb
Real-time database integration with InstantDB. Use this skill when working with InstantDB apps to perform admin operations (create/update/delete entities, link/unlink relationships, query data) and subscribe to real-time data changes. Triggers include mentions of InstantDB, real-time updates, database sync, entity operations, or when OpenClaw needs to send action updates visible to humans in real-time.
What this skill does
# InstantDB Integration
## Overview
Node.js integration for InstantDB enabling OpenClaw to perform admin operations and monitor real-time data changes via WebSocket subscriptions.
## Setup
Install dependencies:
```bash
npm install
```
Set environment variables:
```bash
export INSTANTDB_APP_ID="your-app-id"
export INSTANTDB_ADMIN_TOKEN="your-admin-token"
```
## Core Capabilities
### 1. Query Data
Fetch data using InstantDB's query syntax:
```javascript
const { InstantDBClient } = require('./scripts/instantdb.js');
const client = new InstantDBClient(appId, adminToken);
const result = await client.query({
tasks: {
$: {
where: { status: 'active' }
}
}
});
```
CLI:
```bash
./scripts/instantdb.js query '{"tasks": {}}'
```
### 2. Create Entities
Add new entities to a namespace:
```javascript
const { entityId, result } = await client.createEntity('tasks', {
title: 'Process data',
status: 'pending',
priority: 'high'
});
```
CLI:
```bash
./scripts/instantdb.js create tasks '{"title": "Process data", "status": "pending"}'
```
Optional entity ID:
```bash
./scripts/instantdb.js create tasks '{"title": "Task"}' custom-entity-id
```
### 3. Update Entities
Modify existing entity attributes:
```javascript
await client.updateEntity(entityId, 'tasks', {
status: 'completed'
});
```
CLI:
```bash
./scripts/instantdb.js update <entity-id> tasks '{"status": "completed"}'
```
### 4. Delete Entities
Remove entities:
```javascript
await client.deleteEntity(entityId, 'tasks');
```
CLI:
```bash
./scripts/instantdb.js delete <entity-id> tasks
```
### 5. Link Entities
Create relationships between entities:
```javascript
await client.linkEntities(taskId, assigneeId, 'assignees');
```
CLI:
```bash
./scripts/instantdb.js link <parent-id> <child-id> assignees
```
### 6. Unlink Entities
Remove relationships:
```javascript
await client.unlinkEntities(taskId, assigneeId, 'assignees');
```
CLI:
```bash
./scripts/instantdb.js unlink <parent-id> <child-id> assignees
```
### 7. Real-time Subscriptions
Monitor data changes via WebSocket:
```javascript
const subscriptionId = client.subscribe(
{ tasks: { $: { where: { status: 'active' } } } },
(data) => {
console.log('Data updated:', data);
},
(error) => {
console.error('Subscription error:', error);
}
);
// Later: client.unsubscribe(subscriptionId);
```
CLI (listens for specified duration):
```bash
./scripts/instantdb.js subscribe '{"tasks": {}}' 60 # Listen for 60 seconds
```
### 8. Transactions
Execute multiple operations atomically using the tx builder:
```javascript
const { tx, id } = require('@instantdb/admin');
await client.transact([
tx.tasks[id()].update({ title: 'Task 1' }),
tx.tasks[id()].update({ title: 'Task 2' })
]);
```
CLI:
```bash
./scripts/instantdb.js transact '[{"op": "update", "id": "...", "data": {...}}]'
```
## OpenClaw Usage Patterns
### Action Status Updates
Send real-time progress to human observers:
```javascript
const { id } = require('@instantdb/admin');
// Create status entity
const actionId = id();
await client.createEntity('actions', {
type: 'file_processing',
status: 'started',
progress: 0,
timestamp: Date.now()
}, actionId);
// Update progress
await client.updateEntity(actionId, 'actions', {
progress: 50,
status: 'processing'
});
// Mark complete
await client.updateEntity(actionId, 'actions', {
progress: 100,
status: 'completed'
});
```
### Multi-step Workflow Tracking
Track complex operations:
```javascript
const { tx, id } = require('@instantdb/admin');
const workflowId = id();
const steps = ['Extract', 'Transform', 'Validate', 'Load', 'Verify'];
// Initialize workflow with linked steps
const txs = [
tx.workflows[workflowId].update({
name: 'Data Pipeline',
status: 'running',
currentStep: 1,
totalSteps: steps.length
})
];
const stepIds = steps.map((name, i) => {
const stepId = id();
txs.push(
tx.steps[stepId].update({
name,
order: i + 1,
status: 'pending'
}),
tx.workflows[workflowId].link({ steps: stepId })
);
return stepId;
});
await client.transact(txs);
// Update as steps complete
for (let i = 0; i < stepIds.length; i++) {
await client.updateEntity(stepIds[i], 'steps', {
status: 'completed'
});
await client.updateEntity(workflowId, 'workflows', {
currentStep: i + 2
});
}
```
### Human Monitoring Pattern
Humans subscribe to watch OpenClaw's actions:
```javascript
// Human's frontend code
import { init } from '@instantdb/react';
const db = init({ appId });
function ActionMonitor() {
const { data } = db.useQuery({
actions: {
$: {
where: { status: { in: ['started', 'processing'] } }
}
}
});
return data?.actions?.map(action => (
<div key={action.id}>
{action.type}: {action.progress}%
</div>
));
}
```
### Streaming Progress Updates
For long-running operations, stream updates:
```javascript
const { id } = require('@instantdb/admin');
async function processLargeDataset(items) {
const progressId = id();
await client.createEntity('progress', {
total: items.length,
completed: 0,
status: 'running'
}, progressId);
for (let i = 0; i < items.length; i++) {
// Process item...
await processItem(items[i]);
// Update every 10 items
if (i % 10 === 0) {
await client.updateEntity(progressId, 'progress', {
completed: i + 1,
percentage: Math.round(((i + 1) / items.length) * 100)
});
}
}
await client.updateEntity(progressId, 'progress', {
completed: items.length,
percentage: 100,
status: 'completed'
});
}
```
## Transaction Patterns
See `references/transactions.md` for detailed transaction patterns including:
- Batch operations
- Relationship management
- Conditional updates
- State machines
- Cascade operations
## Error Handling
All operations return promises that reject on failure:
```javascript
try {
const result = await client.createEntity('tasks', data);
} catch (error) {
console.error('Operation failed:', error.message);
}
```
## Query Syntax
See `references/query_syntax.md` for comprehensive query examples including:
- Where clauses and operators
- Relationship traversal
- Sorting and pagination
- Multi-level nesting
## References
- InstantDB documentation: https://www.instantdb.com/docs
- Admin SDK: https://www.instantdb.com/docs/admin
- Query reference: See `references/query_syntax.md`
- Transaction patterns: See `references/transactions.md`
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.