TspoonBase Agent Skill
This skill helps you build, deploy, and manage backends with TspoonBase — a TypeScript BaaS with SQLite, auth, realtime, file storage, AI tools, and vector search.
Quick Start
npm install -g tspoonbase
mkdir my-app && cd my-app
tspoonbase serve --dev --port 8090
This starts a full backend at http://localhost:8090 with REST API, Admin UI at /_/, and WebSocket realtime.
CLI Commands
| Command |
Description |
tspoonbase serve |
Start the server (--port, --dir, --dev) |
tspoonbase superuser-create <email> <password> |
Create admin account |
tspoonbase migrate up |
Run pending migrations |
tspoonbase migrate down [count] |
Rollback migrations |
tspoonbase migrate status |
Show migration status |
tspoonbase migrate create <name> |
Create a new migration file |
Key Features
Authentication
- Email/password auth via
/api/collections/:collection/auth-with-password
- OAuth2 (GitHub, Google, Discord, Facebook) via
/api/collections/:collection/auth-with-oauth2
- OTP (one-time password) via
/api/collections/:collection/auth-with-otp
- MFA/TOTP setup and verification
- JWT tokens with refresh, impersonation, and revocation
- Password reset, email verification, email change flows
Collections & Records
- Base, Auth, and View collection types
- 14 field types: text, number, email, url, bool, date, select, file, relation, json, editor, autodate, geoPoint, vector
- API rules per operation (list, view, create, update, delete) using
@request.* macro syntax
- Filter syntax:
field = 'value', field ~ 'substring', field > 10, field ?= 'array-element', (field1 = 'a' || field2 = 'b')
- Sort, pagination, field selection, record expansion
- Batch API (
/api/batch) with atomic transactions
File Storage
- Upload via
POST /api/collections/:c/records/:r/files (multipart)
- Serve via
GET /api/collections/:c/records/:r/:filename
- Protected file tokens via
POST /api/files/token
- Thumbnail generation (100x100, 300x300, 500x500) via sharp
- S3 storage driver (configured in Admin UI settings)
Realtime
- WebSocket at
ws://host:port/api/realtime
- SSE (Server-Sent Events) at
GET /api/realtime with Accept: text/event-stream
- Subscribe/unsubscribe to channels via
POST /api/realtime
- Record change events:
collections.{collectionId}.records
AI Tools
- Schema generator: generate collection schemas from natural language
- Rule generator: generate API rules from descriptions
- Data seeder: generate mock data for collections
- Chat assistant: conversational AI for managing your backend
- Supported providers: OpenAI, Anthropic, Ollama
Vector Search
- Cosine similarity via SQL
vector_cosine_similarity() function
POST /api/collections/:c/vector-search with query vector and limit
- Best for semantic search over stored embeddings
Admin UI
- Built React/Vite SPA at
/_/
- Manage collections, records, settings, logs, backups
- AI Assistant panel for schema generation and management
Migrations
- JavaScript migration files in
pb_migrations/
up() and down() functions per migration
- Auto-applied on server start, or manually via CLI
JavaScript Hooks
- Files in
pb_hooks/ with .js extension
- Events:
onBootstrap, onServe, onRecordCreate, onRecordUpdate, onRecordDelete, onCollectionCreate, onCollectionUpdate, onCollectionDelete
- Globals:
$app (settings, db, logger, etc.), console, setTimeout, fetch
- Timeout: 5 seconds per hook
Backups
- Create:
POST /api/backups with optional name
- List:
GET /api/backups
- Upload:
POST /api/backups/upload (multipart zip)
- Restore:
POST /api/backups/:key/restore
- Delete:
DELETE /api/backups/:key
- Includes data.db, auxiliary.db, and storage files
SDK Usage (Client-Side)
import TspoonBase from 'tspoonbase/client'
const pb = new TspoonBase('http://localhost:8090')
// Auth
const auth = await pb.collection('users').authWithPassword('email@example.com', 'password')
// CRUD
const records = await pb.collection('posts').getList(1, 20, { filter: 'status = "published"' })
const record = await pb.collection('posts').create({ title: 'Hello', content: 'World' })
await pb.collection('posts').update(record.id, { title: 'Updated' })
await pb.collection('posts').delete(record.id)
// Realtime (WebSocket)
pb.collection('posts').subscribe('*', (event) => {
console.log('Post changed:', event.action, event.record)
})
// File upload
const formData = new FormData()
formData.append('files', fileInput.files[0])
await pb.collection('posts').update(recordId, formData)
Environment Variables
| Env Var |
Purpose |
JWT_SECRET or TSPOONBASE_JWT_SECRET |
JWT signing secret (min 32 chars) |
TSPOONBASE_ENCRYPTION_KEY |
Encryption salt for settings secrets |
TSPOONBASE_DATA_DIR |
Data directory (default: ./pb_data) |
Deployment
Docker
docker compose up -d
Manual (Node.js 20+)
npm install -g tspoonbase
tspoonbase serve --port 8090 --dir ./pb_data
Programmatic
import { TspoonBase } from 'tspoonbase'
const app = new TspoonBase({ defaultDev: true })
await app.start(8090)
Common API Endpoints
| Method |
Endpoint |
Description |
| GET |
/api/health |
Health check (with DB connectivity) |
| GET |
/api/collections |
List all collections |
| POST |
/api/collections |
Create a collection |
| GET |
/api/collections/:c/records |
List records (with filter, sort, page) |
| POST |
/api/collections/:c/records |
Create a record |
| PATCH |
/api/collections/:c/records/:r |
Update a record |
| DELETE |
/api/collections/:c/records/:r |
Delete a record |
| POST |
/api/collections/:c/auth-with-password |
Auth with email/password |
| POST |
/api/batch |
Batch operations (transactional) |
Architecture
- Express server with middleware: helmet, CORS, rate limiting, auth token loading
- SQLite via better-sqlite3 with WAL mode — dual database design (data.db + auxiliary.db)
- WebSocket realtime via ws library, SSE fallback
- Zod for schema validation on settings and configuration
- Commander for CLI parsing
1---2name: tspoonbase3description: "TspoonBase — a TypeScript backend-as-a-service with SQLite, auth, realtime, file storage, AI tools, vector search, and Admin UI. Use when a user wants to build a backend, scaffold a BaaS, add auth/CRUD/realtime to a project, deploy a PocketBase-like backend in TypeScript, or needs help with TspoonBase CLI commands, API usage, or deployment. TRIGGER when: code imports `tspoonbase`; user asks to create, deploy, or manage a backend; user mentions PocketBase, BaaS, SQLite backend, auth backend, realtime backend, or TspoonBase itself; project needs authentication, file uploads, realtime subscriptions, or an admin panel. SKIP: non-TypeScript projects, Go/Python/other language backends, general database questions not involving TspoonBase."4license: Apache-2.05metadata:6 source: https://skillmd.com/skills/aibot88/tspoonbase7---89# TspoonBase Agent Skill1011This skill helps you build, deploy, and manage backends with **TspoonBase** — a TypeScript BaaS with SQLite, auth, realtime, file storage, AI tools, and vector search.1213## Quick Start1415```bash16npm install -g tspoonbase17mkdir my-app && cd my-app18tspoonbase serve --dev --port 809019```2021This starts a full backend at `http://localhost:8090` with REST API, Admin UI at `/_/`, and WebSocket realtime.2223## CLI Commands2425| Command | Description |26|---------|-------------|27| `tspoonbase serve` | Start the server (--port, --dir, --dev) |28| `tspoonbase superuser-create <email> <password>` | Create admin account |29| `tspoonbase migrate up` | Run pending migrations |30| `tspoonbase migrate down [count]` | Rollback migrations |31| `tspoonbase migrate status` | Show migration status |32| `tspoonbase migrate create <name>` | Create a new migration file |3334## Key Features3536### Authentication37- Email/password auth via `/api/collections/:collection/auth-with-password`38- OAuth2 (GitHub, Google, Discord, Facebook) via `/api/collections/:collection/auth-with-oauth2`39- OTP (one-time password) via `/api/collections/:collection/auth-with-otp`40- MFA/TOTP setup and verification41- JWT tokens with refresh, impersonation, and revocation42- Password reset, email verification, email change flows4344### Collections & Records45- Base, Auth, and View collection types46- 14 field types: text, number, email, url, bool, date, select, file, relation, json, editor, autodate, geoPoint, vector47- API rules per operation (list, view, create, update, delete) using `@request.*` macro syntax48- Filter syntax: `field = 'value'`, `field ~ 'substring'`, `field > 10`, `field ?= 'array-element'`, `(field1 = 'a' || field2 = 'b')`49- Sort, pagination, field selection, record expansion50- Batch API (`/api/batch`) with atomic transactions5152### File Storage53- Upload via `POST /api/collections/:c/records/:r/files` (multipart)54- Serve via `GET /api/collections/:c/records/:r/:filename`55- Protected file tokens via `POST /api/files/token`56- Thumbnail generation (100x100, 300x300, 500x500) via sharp57- S3 storage driver (configured in Admin UI settings)5859### Realtime60- WebSocket at `ws://host:port/api/realtime`61- SSE (Server-Sent Events) at `GET /api/realtime` with `Accept: text/event-stream`62- Subscribe/unsubscribe to channels via `POST /api/realtime`63- Record change events: `collections.{collectionId}.records`6465### AI Tools66- Schema generator: generate collection schemas from natural language67- Rule generator: generate API rules from descriptions68- Data seeder: generate mock data for collections69- Chat assistant: conversational AI for managing your backend70- Supported providers: OpenAI, Anthropic, Ollama7172### Vector Search73- Cosine similarity via SQL `vector_cosine_similarity()` function74- `POST /api/collections/:c/vector-search` with query vector and limit75- Best for semantic search over stored embeddings7677### Admin UI78- Built React/Vite SPA at `/_/`79- Manage collections, records, settings, logs, backups80- AI Assistant panel for schema generation and management8182### Migrations83- JavaScript migration files in `pb_migrations/`84- `up()` and `down()` functions per migration85- Auto-applied on server start, or manually via CLI8687### JavaScript Hooks88- Files in `pb_hooks/` with `.js` extension89- Events: `onBootstrap`, `onServe`, `onRecordCreate`, `onRecordUpdate`, `onRecordDelete`, `onCollectionCreate`, `onCollectionUpdate`, `onCollectionDelete`90- Globals: `$app` (settings, db, logger, etc.), console, setTimeout, fetch91- Timeout: 5 seconds per hook9293### Backups94- Create: `POST /api/backups` with optional name95- List: `GET /api/backups`96- Upload: `POST /api/backups/upload` (multipart zip)97- Restore: `POST /api/backups/:key/restore`98- Delete: `DELETE /api/backups/:key`99- Includes data.db, auxiliary.db, and storage files100101## SDK Usage (Client-Side)102103```typescript104import TspoonBase from 'tspoonbase/client'105106const pb = new TspoonBase('http://localhost:8090')107108// Auth109const auth = await pb.collection('users').authWithPassword('email@example.com', 'password')110111// CRUD112const records = await pb.collection('posts').getList(1, 20, { filter: 'status = "published"' })113const record = await pb.collection('posts').create({ title: 'Hello', content: 'World' })114await pb.collection('posts').update(record.id, { title: 'Updated' })115await pb.collection('posts').delete(record.id)116117// Realtime (WebSocket)118pb.collection('posts').subscribe('*', (event) => {119 console.log('Post changed:', event.action, event.record)120})121122// File upload123const formData = new FormData()124formData.append('files', fileInput.files[0])125await pb.collection('posts').update(recordId, formData)126```127128## Environment Variables129130| Env Var | Purpose |131|---------|---------|132| `JWT_SECRET` or `TSPOONBASE_JWT_SECRET` | JWT signing secret (min 32 chars) |133| `TSPOONBASE_ENCRYPTION_KEY` | Encryption salt for settings secrets |134| `TSPOONBASE_DATA_DIR` | Data directory (default: `./pb_data`) |135136## Deployment137138### Docker139```bash140docker compose up -d141```142143### Manual (Node.js 20+)144```bash145npm install -g tspoonbase146tspoonbase serve --port 8090 --dir ./pb_data147```148149### Programmatic150```typescript151import { TspoonBase } from 'tspoonbase'152153const app = new TspoonBase({ defaultDev: true })154await app.start(8090)155```156157## Common API Endpoints158159| Method | Endpoint | Description |160|--------|----------|-------------|161| GET | /api/health | Health check (with DB connectivity) |162| GET | /api/collections | List all collections |163| POST | /api/collections | Create a collection |164| GET | /api/collections/:c/records | List records (with filter, sort, page) |165| POST | /api/collections/:c/records | Create a record |166| PATCH | /api/collections/:c/records/:r | Update a record |167| DELETE | /api/collections/:c/records/:r | Delete a record |168| POST | /api/collections/:c/auth-with-password | Auth with email/password |169| POST | /api/batch | Batch operations (transactional) |170171## Architecture172173- **Express** server with middleware: helmet, CORS, rate limiting, auth token loading174- **SQLite** via better-sqlite3 with WAL mode — dual database design (data.db + auxiliary.db)175- **WebSocket** realtime via ws library, SSE fallback176- **Zod** for schema validation on settings and configuration177- **Commander** for CLI parsing