cipherstash/stack/stash-supabase

Claude Code and agent skill by cipherstash/stack

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Integrate CipherStash encryption with Supabase using @cipherstash/stack-supabase. Covers the encryptedSupabase wrapper over native EQL v3 column domains, transparent encryption/decryption on insert/update/select, encrypted scalar filters (eq, gt/gte/lt/lte, in, or), ordering on encrypted columns, EQL 3.0.5 PostgREST query-domain limitations, identity-aware encryption, and the complete query builder API. Use when adding encryption to a Supabase project, querying encrypted columns, or building se…

Install

npx vskill@latest install cipherstash/stack/stash-supabase

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as cipherstash/stack/stash-supabase.

CipherStash Stack - Supabase Integration

Guide for integrating CipherStash field-level encryption with Supabase using the encryptedSupabase wrapper over native EQL v3 column domains. The wrapper provides transparent encryption on mutations and decryption on selects, with support for equality, range, and ordering.

Naming note. encryptedSupabase is the current EQL v3 factory.
encryptedSupabaseV3 remains as a @deprecated, type-identical alias, so
existing imports keep working — prefer encryptedSupabase in new code. The
old EQL v2 authoring wrapper (`encryptedSupabase({ encryptionClient,
supabaseClient }).from(table, schema)`) has been removed — see
"Legacy: EQL v2" at the end.

When to Use This Skill

  • Adding field-level encryption to a Supabase project
  • Querying encrypted data with Supabase's query builder (eq, gt, in, or, etc.)
  • Understanding encrypted JSON query limitations in PostgREST
  • Inserting, updating, or upserting encrypted data
  • Using identity-aware encryption (lock contexts) with Supabase
  • Building applications where sensitive columns need encryption at rest and in transit
On a managed AI platform — Lovable, v0, Bolt, Replit — read `stash-managed-platforms` first. Two things there are decided before anything on this page applies: server code runs on an edge runtime, so it needs @cipherstash/stack/wasm-inline (@cipherstash/protect is the deprecated predecessor and its native module will not load — that dead end has cost an agent a whole turn), and the database role is not postgres, which changes how EQL gets installed. encryptedSupabase can be constructed inside an edge runtime, but only from the @cipherstash/stack-supabase/wasm-inline entry and only with declared schemas — introspection is what needs a Postgres connection, and declaring your tables is what skips it. Step 5 of Setup has the call shape.
What survives PostgREST, in one line (the full treatment is under Query behaviour on encrypted columns, a long way down): eq / neq / in / match() and the range filters gt / gte / lt / lte do work on capable domains, and so does order() on OPE-backed ordering columns. Encrypted free-text matches() and encrypted-JSON contains() / selectorEq() / selectorNe() do not — they need eql_v3.query_* casts PostgREST cannot emit, and the wrapper fails fast rather than returning wrong rows. Agents guess wrong in both directions on this, so don't infer it; for the predicates that don't survive, use Drizzle, Prisma Next, or SQL in an RPC.

Installation

bash
npm install @cipherstash/stack @cipherstash/stack-supabase @supabase/supabase-js
Version note: npx stash init is the preferred install path — it pins
every @cipherstash/* package to the versions matching your CLI release.
If you install manually as above, verify what actually resolved
(node -p "require('@cipherstash/stack/package.json').version"): bare
dist-tag installs can lag behind a release, and stash init will warn on
the version skew.

The Supabase integration ships as its own first-party package, @cipherstash/stack-supabase, which depends on @cipherstash/stack. Install both.

Setup

Credentials first: for local development run npx stash init (the agent-assisted flow — auth, schema, and database end to end) or npx stash auth login (device code flow; no environment variables needed). CI and production use the CS_* machine-credential environment variables — see the stash-encryption skill's Configuration section. Mint them from your device session with npx stash env --name <name> (no dashboard copy-paste); this is also how Supabase Edge Functions get credentials in local dev — supabase functions serve runs in a container that cannot see ~/.cipherstash, so write the vars to a file with stash env --name edge-dev --write and pass --env-file, or supabase secrets set them for deploys.

**One credential set per environment — but what must match between writers
and query readers is the keyset, not the credential string.** Index terms
come from a per-keyset key, so any client bound to the keyset produces
matching terms. Decrypt is looser — it follows each payload's keyset and
needs only a grant — so a reader granted the writer's keyset but bound to
a different one decrypts fine while its searches silently return zero
rows. stash-zerokms is canonical for keyset scoping, stash-auth for
credentials. Inside an
Edge Function (Deno, no native modules) the wrapper comes from
@cipherstash/stack-supabase/wasm-inline — step 5 below. For encryption
without the Supabase wrapper it is @cipherstash/stack/wasm-inline, see the
stash-edge skill; SQL written by hand in a migration or RPC is covered by
stash-postgres.
1. Install EQL v3 on the database

Install it as a migration, not directly:

bash
stash eql migration --supabase # writes supabase/migrations/<timestamp>_cipherstash_eql.sql
supabase db reset # local — replays every migration
supabase db push # remote/linked project
A bare supabase migration up applies to the local database. The remote
forms are supabase db push and supabase migration up --linked.
⚠️ **Do not use stash eql install --supabase on a project with a local
supabase/ directory.** It applies the SQL straight to the running database,
and supabase db reset — the ordinary local development loop — drops that
database and replays supabase/migrations/. EQL is not in there, so it is
gone, and the next query fails with type "eql_v3_encrypted" does not exist.
stash eql install --supabase is for a hosted project you administer
without the Supabase CLI, where there is no migrations directory to write to.
Connecting as a role that is not `postgres` (or a member of it) — common
on managed AI platforms such as Lovable — is fine: the install proceeds and
is complete. Only the three owner-scoped `ALTER DEFAULT PRIVILEGES FOR ROLE
postgres` statements are skipped, and they are optional: they cover EQL
objects postgres might later create outside stash tooling, and every
stash eql install/eql upgrade re-grants all objects anyway. The CLI
prints them as "Optional SQL — requires postgres" for operators who want
them (Supabase SQL editor / migration tool); on platforms where nobody can
act as postgres, nothing is lost. Check ahead of time with `stash eql
preflight (--json for agents), which reports membership of postgres`
alongside the other role capabilities.
TLS: the CLI bundles the Supabase root CA, so sslmode=verify-full
against Supabase hosts (direct and pooler) verifies out of the box — no
certificate download, and never NODE_TLS_REJECT_UNAUTHORIZED=0 (it is
process-wide and would also disable verification for CipherStash credential
traffic). A supplied sslrootcert=<path> or PGSSLROOTCERT still wins.

The generated file carries three things, in order: the EQL v3 bundle, the role grants, and the cipherstash.cs_migrations tracking schema that stash encrypt records per-column progress in. One supabase db reset therefore provisions everything — no out-of-band stash eql install afterwards.

It refuses to write a second install migration; pass --force to regenerate the existing one in place (same version, so an applied ledger stays consistent). Because the version is unchanged, supabase db push will not re-apply it — the Supabase CLI decides what is pending by version, never by file content, so a version already in the ledger is never re-run and push reports Remote database is up to date. Re-apply with supabase db reset locally; on a remote, clear the ledger row first with supabase migration repair --status reverted <version> (tracking table only — it applies no SQL) and then supabase db push. Add --include-all to that push only if it aborts with Found local migration files to be inserted before the last migration on remote database., which happens when migrations sort after the install; reverting the newest version leaves it at the tail, where a plain push applies it. The flag applies every out-of-order migration you have, so don't reach for it pre-emptively. ⚠️ On a populated database, weigh it first: the EQL bundle opens with DROP SCHEMA IF EXISTS eql_v3 CASCADE (and eql_v3_internal), so re-applying also drops every index, constraint, and RLS policy that references those schemas.

If you already have encrypted-column migrations, note that the generated install is stamped with the current time and therefore sorts after them. A reset replays in version order with no dependency awareness, so those migrations run before EQL exists and supabase db reset fails with type "eql_v3_text_search" does not exist. The command detects this and warns, naming the files; the fix is to rename the install migration to a version below the earliest of them. How that back-dated version reaches a remote depends on what that remote actually has. This case only arises on a project that ran stash eql install directly, so the remote usually has EQL already — but "usually" is not what you want to bet a ledger row on, so check it:

bash
psql "$REMOTE_DATABASE_URL" -Atc "select eql_v3.version()"

eql_v3.version() is created by the bundle's last statements, so it answers "is the whole install there". A probe for the eql_v3 schema does not: that schema is created by the bundle's first statements and survives an install that aborted partway.

If it prints a version, only the ledger row is missing — mark it applied with supabase migration repair --status applied <version>, which writes the row and runs no SQL. ⚠️ Do not push the file there instead: that re-runs the bundle's opening DROP SCHEMA IF EXISTS eql_v3 CASCADE (and eql_v3_internal), dropping every index, constraint, and RLS policy that references those schemas.

If it errors, that remote genuinely still needs the SQL applied: supabase db push --include-all, the flag being required because the back-dated version is a gap in the middle of that history. ⚠️ Never mark it applied there. Every other remedy on this page fails loudly and can be retried; this one fails silently — the ledger row claims SQL that never ran, so no later push installs EQL, and the first query against an encrypted column fails with nothing pointing at the cause.

There is no --out to reach for here: the Supabase CLI's migrations directory is not configurable. supabase db reset and supabase db push read <project>/supabase/migrations and nothing else, config.toml has no key for it, and --workdir / SUPABASE_WORKDIR moves the whole supabase/ directory rather than this subdirectory. stash eql migration --supabase --out <dir> still writes the file, and warns, because a project may have its own step that applies that directory — but the Supabase CLI will not, so EQL is gone again after the next reset.

Since eql-3.0.0 there is one v3 SQL artifact for every target — there is no separate Supabase variant. The bundle's only superuser-requiring statements (the ORE operator class/family) skip themselves when the install role lacks the privilege, and the bundle then disables the ORE-opclass-backed domains it cannot support. --supabase adds the role grants for anon / authenticated / service_role on the two schemas the bundle creates — eql_v3 (the operator-backing functions) and eql_v3_internal (SEM internals). Without the grants, encrypted queries fail loudly with a permission error (e.g. permission denied for schema eql_v3_internal).

No Exposed schemas change is needed: the column domains and their operators live in public, so bare col = term filters resolve under Supabase's default PostgREST configuration. Do not expose eql_v3_internal.

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
169
Repository forks
8
7-day trend score
25

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 19 Mar 2026, 8 months ago.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/cipherstash/stack/stash-supabase/badge)](https://verified-skill.com/skills/cipherstash/stack/stash-supabase)

Something wrong with this skill or its page? Tell us.