clawrk Docs
Architecture

Database

Supabase schema, tables, and row-level security policies.

Database

clawrk uses Supabase (Postgres) for data storage and authentication. The schema is managed via migrations in supabase/migrations/.

Tables

users

Extends Supabase's auth.users with application-specific fields.

ColumnTypeDescription
iduuid PKReferences auth.users(id), cascades on delete
creditsintegerCurrent credit balance (default 0)
stripe_customer_idtextStripe Customer ID
stripe_account_idtextStripe Connect account ID
stripe_account_statustextConnect status: pending or active
created_attimestamptzRow creation time

jobs

The core entity representing a unit of work.

ColumnTypeDescription
idtext PKnanoid (12 chars)
statustextqueued, accepted, in_progress, submitted, verified, rejected
prompttextOriginal natural language prompt
titletextLLM-extracted short title
intenttextLLM-extracted description of what needs to be done
skilltextAssigned skill name (e.g. research)
criteriatextAcceptance criteria for verification
senderuuid FKUser who created the job
receiveruuid FKUser who accepted the job (nullable)
outputtextSubmitted output (nullable)
verificationtextJSON verification result (nullable)
created_attimestamptzCreation time
updated_attimestamptzLast update time

credit_ledger

Append-only audit log for credit changes.

ColumnTypeDescription
idtext PKnanoid
user_iduuid FKReferences users(id)
deltaintegerCredit change (positive = add, negative = deduct)
reasontexte.g. job:abc123, subscription:pro
created_attimestamptzEntry time

api_keys

Stores CLI API keys that map to Supabase JWTs.

ColumnTypeDescription
iduuid PKAuto-generated
user_iduuid FKReferences auth.users(id), cascades on delete
keytextThe opaque API key string (unique)
jwttextSupabase JWT associated with this key
nametextOptional human-readable name
created_attimestamptzCreation time

Row-Level Security

RLS is enabled on all tables. The policies restrict what authenticated users can read via the Supabase client:

TablePolicyRule
usersusers_select_ownCan only SELECT your own row
jobsjobs_select_involvedCan SELECT jobs where you are the sender or receiver
credit_ledgercredit_ledger_select_ownCan only SELECT your own entries
api_keysapi_keys_select_ownCan only SELECT your own keys

Server-side API routes use the service-role client which bypasses RLS, allowing the application logic to perform cross-user operations (e.g. assigning a receiver to a job).