CipherStash CLI
The stash dev-time CLI installs EQL in PostgreSQL, scaffolds an encryption client, and manages schemas with init, plan, and impl commands.
stash is a dev-time CLI and library for managing CipherStash EQL (Encrypted Query Language) in PostgreSQL.
@cipherstash/stack is the runtime encryption SDK. It stays lean with no heavy dependencies like pg. stash is a devDependency that handles database tooling: installing EQL extensions, checking permissions, validating schemas, and managing the schema lifecycle.
Think of it like Prisma CLI or Drizzle Kit. It sets up the database while the main SDK handles runtime operations.
| Package | Role | Install as |
|---|---|---|
@cipherstash/stack | Runtime encryption and decryption | dependency |
stash | Database setup and schema management | devDependency |
Quick start
Interactive (recommended)
The setup lifecycle has three explicit save-points. Each command can be run standalone; the chain prompts after init and plan are convenience for first-time users.
Run init
stash init authenticates you, resolves your database, scaffolds an encryption client, installs dependencies, installs EQL, and writes .cipherstash/context.json.
npx stash initWhen init finishes, it asks (default-yes) whether to continue to stash plan.
Draft an encryption plan
stash plan hands off to a coding agent (Claude Code or Codex), which reads your project and writes .cipherstash/plan.md. The plan lists the tables and columns to encrypt. Review it before proceeding.
npx stash planWhen plan finishes, it asks (default-yes) whether to continue to stash impl.
Execute the plan
stash impl reads the plan, shows a summary panel, asks you to confirm, and dispatches to the agent to make the changes.
npx stash implManual setup
If you prefer to configure things yourself rather than running stash init, you can scaffold the config file manually and run stash db install directly.
Install the CLI
npm install -D stashCreate stash.config.ts
Create stash.config.ts in your project root:
import { defineConfig } from 'stash'
export default defineConfig({
databaseUrl: process.env.DATABASE_URL!,
})Add your database URL
DATABASE_URL=postgresql://user:password@localhost:5432/mydbInstall EQL
npx stash db installGood to know: Using Drizzle? The CLI auto-detects a
drizzle.config.*file ordrizzle-orm/drizzle-kitinpackage.jsonand generates a migration automatically. You can also pass--drizzleexplicitly. Runnpx drizzle-kit migrateafter to apply it.
Configuration
The stash.config.ts file is the single source of truth for the CLI. Use defineConfig for type safety.
import { defineConfig } from 'stash'
export default defineConfig({
databaseUrl: process.env.DATABASE_URL!,
client: './src/encryption/index.ts',
})| Option | Required | Default | Description |
|---|---|---|---|
databaseUrl | Yes | PostgreSQL connection string | |
client | No | ./src/encryption/index.ts | Path to your encryption client file. Used by push and validate. |
The CLI loads .env.local, .env.development.local, .env.development, then .env (first-win, Next.js precedence) before evaluating the config, so process.env references work without any extra setup. The config file is resolved by walking up from the current working directory, similar to how tsconfig.json resolution works.
Wizard
stash wizard (also available as @cipherstash/wizard) is the CipherStash-hosted AI setup tool. It reads your codebase, asks which columns to encrypt, and wires up @cipherstash/stack for you.
The primary setup path is stash init → stash plan → stash impl, which can hand off to Claude Code, Codex, AGENTS.md (Cursor, Windsurf, Cline), or the wizard. The wizard is one handoff target among these options.
Run it directly with:
npx stash wizardOr via the package runner:
npx @cipherstash/wizard # npm / Node
pnpm dlx @cipherstash/wizard # pnpm
bunx @cipherstash/wizard # bun
yarn dlx @cipherstash/wizard # yarnPrerequisites
Before running the wizard, your project should have:
- An authenticated CipherStash session (
npx stash auth login) - A
stash.config.ts(runnpx stash initornpx stash db installto scaffold one) - A reachable database via
DATABASE_URL
What the wizard does
- Detects your framework (Drizzle, Supabase, Prisma, generic) and TypeScript usage.
- Runs health checks against the CipherStash gateway and your database.
- Prompts you to pick the tables and columns to encrypt.
- Sends a prompt to the Claude Agent SDK, which edits your schema and call sites to use
@cipherstash/stack's encryption APIs. The agent runs against a CipherStash-hosted LLM gateway. No Anthropic API key is required. - Runs post-agent steps: package install,
db install,db push, and framework-specific migrations. - Scans for remaining call sites that need
encryptModel/decryptModelwiring and prints a summary. These locations are not edited automatically. - Offers to install integration-appropriate agent skills into
./.claude/skills/.
Wizard log
Each run writes a timestamped log to .cipherstash/wizard-log.md in your project root. The log records phases, decisions, and touched files.
Backfilling existing data
When the wizard adds encryptedType to columns that already have data, you must backfill the existing rows with encryptModel before dropping the old column. The wizard prints a reminder with the recommended pattern. You are responsible for writing and running this backfill.
Experimental commands
env
The env command prints a .env.production.local block with your CipherStash credentials. Pass --write to write it to disk.
STASH_EXPERIMENTAL_ENV_CMD=1 npx stash env
STASH_EXPERIMENTAL_ENV_CMD=1 npx stash env --writeThis command is experimental and gated behind the STASH_EXPERIMENTAL_ENV_CMD=1 environment variable. It is not ready for production use.
Next steps
Init
Use the interactive init command to scaffold your project and generate context.json.
Plan
Draft a reviewable encryption plan before any code changes are made.
Impl
Execute the plan with a local coding agent.
Status
Check where you are in the setup lifecycle at a glance.
Install and upgrade
Install or upgrade EQL in your database.
Programmatic API
Use the CLI as a library in your own scripts and tooling.
Disaster recovery
How ZeroKMS keeps encrypted data recoverable through disaster recovery, separating keys from data so regional outages cause no data loss.
Interactive setup
Run stash init to authenticate, resolve your database, scaffold an encryption client, install dependencies, and add the EQL extension to CipherStash.