cipherstash/stack/stash-supabase
Claude Code and agent skill by cipherstash/stack
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
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-supabaseSemi-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.encryptedSupabaseis the current EQL v3 factory.encryptedSupabaseV3remains as a@deprecated, type-identical alias, soexisting imports keep working — preferencryptedSupabasein new code. Theold 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/protectis 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 notpostgres, which changes how EQL gets installed.encryptedSupabasecan be constructed inside an edge runtime, but only from the@cipherstash/stack-supabase/wasm-inlineentry and only with declaredschemas— 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 filtersgt/gte/lt/ltedo work on capable domains, and so doesorder()on OPE-backed ordering columns. Encrypted free-textmatches()and encrypted-JSONcontains()/selectorEq()/selectorNe()do not — they needeql_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
Version note:npx stash initis the preferred install path — it pinsevery@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"): baredist-tag installs can lag behind a release, andstash initwill warn onthe 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 writersand query readers is the keyset, not the credential string.** Index termscome from a per-keyset key, so any client bound to the keyset producesmatching terms. Decrypt is looser — it follows each payload's keyset andneeds only a grant — so a reader granted the writer's keyset but bound toa different one decrypts fine while its searches silently return zerorows.stash-zerokmsis canonical for keyset scoping,stash-authforcredentials. Inside anEdge Function (Deno, no native modules) the wrapper comes from@cipherstash/stack-supabase/wasm-inline— step 5 below. For encryptionwithout the Supabase wrapper it is@cipherstash/stack/wasm-inline, see thestash-edgeskill; SQL written by hand in a migration or RPC is covered bystash-postgres.
1. Install EQL v3 on the database
Install it as a migration, not directly:
A baresupabase migration upapplies to the local database. The remoteforms aresupabase db pushandsupabase migration up --linked.
⚠️ **Do not usestash eql install --supabaseon a project with a localsupabase/directory.** It applies the SQL straight to the running database,andsupabase db reset— the ordinary local development loop — drops thatdatabase and replayssupabase/migrations/. EQL is not in there, so it isgone, and the next query fails withtype "eql_v3_encrypted" does not exist.stash eql install --supabaseis for a hosted project you administerwithout 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) — commonon managed AI platforms such as Lovable — is fine: the install proceeds andis complete. Only the three owner-scoped `ALTER DEFAULT PRIVILEGES FOR ROLEpostgres` statements are skipped, and they are optional: they cover EQLobjectspostgresmight later create outside stash tooling, and everystash eql install/eql upgradere-grants all objects anyway. The CLIprints them as "Optional SQL — requires postgres" for operators who wantthem (Supabase SQL editor / migration tool); on platforms where nobody canact aspostgres, nothing is lost. Check ahead of time with `stash eqlpreflight(--jsonfor agents), which reports membership ofpostgres`alongside the other role capabilities.
TLS: the CLI bundles the Supabase root CA, sosslmode=verify-fullagainst Supabase hosts (direct and pooler) verifies out of the box — nocertificate download, and neverNODE_TLS_REJECT_UNAUTHORIZED=0(it isprocess-wide and would also disable verification for CipherStash credentialtraffic). A suppliedsslrootcert=<path>orPGSSLROOTCERTstill 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:
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
- SKILL.md in the repositoryCheckingskills/stash-supabase/SKILL.md
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
[](https://verified-skill.com/skills/cipherstash/stack/stash-supabase)