CipherStashDocs
CipherStash Forge

CipherStash Forge

Dev-time CLI for managing EQL installation, encryption schemas, and database setup

CipherStash Forge

@cipherstash/cli 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. @cipherstash/cli is a devDependency that handles database tooling: installing EQL extensions, checking permissions, validating schemas, and managing schema lifecycle.

Think of it like Prisma CLI or Drizzle Kit. It sets up the database while the main SDK handles runtime operations.

PackageRoleInstall as
@cipherstash/stackRuntime encryption and decryptiondependency
@cipherstash/cliDatabase setup and schema managementdevDependency

Quick start

Run the init wizard

The npx @cipherstash/cli init command authenticates you, generates your encryption schema, and installs dependencies.

npx @cipherstash/cli init

Set up your database

Run the interactive setup to install EQL and configure your database:

npx @cipherstash/cli db setup

EQL is now installed and your encryption schema is ready.

Build your schema with AI (optional)

Use the AI-powered wizard to generate an encryption schema from your database:

npx @cipherstash/cli wizard

Manual setup

Install the CLI

npm install -D @cipherstash/cli

Create stash.config.ts

Create stash.config.ts in your project root:

import { defineConfig } from '@cipherstash/cli'

export default defineConfig({
  databaseUrl: process.env.DATABASE_URL!,
})

Add your database URL

DATABASE_URL=postgresql://user:password@localhost:5432/mydb

Set up your database

npx @cipherstash/cli db setup

Good to know: Using Drizzle? Run npx @cipherstash/cli db install --drizzle to generate a migration directly, then npx drizzle-kit migrate to apply it.

Configuration

The stash.config.ts file is the single source of truth for Forge. Use defineConfig for type safety.

import { defineConfig } from '@cipherstash/cli'

export default defineConfig({
  databaseUrl: process.env.DATABASE_URL!,
  client: './src/encryption/index.ts',
})
OptionRequiredDefaultDescription
databaseUrlYesPostgreSQL connection string
clientNo./src/encryption/index.tsPath to your encryption client file. Used by push and validate.

The CLI automatically loads .env 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.

Next steps

On this page