Keel by ChimpLabs
Jump to page or section Esc
Getting Started

Quickstart

Start Keel in 60 seconds using the plain TypeScript SDK or Effect v4.

Keel requires Node.js >= 22.14.0 with ESM "type": "module" and Effect v4 (effect@^4.0.0). Node 22.18+ runs .ts files directly. On Node 22.14 to 22.17, pass --experimental-strip-types.

pnpm init && npm pkg set type=module
pnpm add @chimp-labs/keel effect pg

# Optional: Durable saga workflows & signals (plugs into createKeel via Open Plugin Protocol)
pnpm add @chimp-labs/keel-workflow

# Optional: NestJS TC39 Stage 3 adapter & static AppModule topology inference
pnpm add @chimp-labs/keel-nestjs

# Optional: Automatic Cloudflare Workers / Docker IaC inference (Alchemy v2)
pnpm add -D @chimp-labs/keel-alchemy alchemy

Option A. Plain TypeScript SDK (@chimp-labs/keel/sdk)

This SDK wraps Effect so you do not write Effect.gen, Layer, Option, or Scope code.

1. Declare resources, write atomically, and process jobs

Create index.ts. Setting backend: "sqlite" runs on Node’s built-in node:sqlite in memory by default, or persists on disk when you pass sqlite: { filename: "./keel.db" }. Both tx.users.insert and tx.welcomeEmails.enqueue commit or roll back in one SQL transaction:

import { createKeel, k } from "@chimp-labs/keel/sdk"

const resources = {
  users: k.table("users", {
    id: k.uuid().primaryKey(),
    email: k.text().unique(),
    createdAt: k.datetime().defaultNow(),
  }),
  welcomeEmails: k.queue("emails.welcome", k.object({ to: k.string() })),
}

const keel = await createKeel({
  backend: "sqlite", // "memory" | "sqlite" | "postgres" | "surreal"
  // Persist locally on disk:
  // sqlite: { filename: "./keel.db" },
  // Or swap to PostgreSQL 17 with zero domain code changes:
  // backend: "postgres",
  // postgres: { fromEnv: true }, // or { url: "postgresql://keel:[email protected]:5439/keel" }
  resources,
  ensureAll: true,
})

try {
  // Insert the user and enqueue the welcome email in one atomic transaction
  const user = await keel.transaction(async (tx) => {
    const created = await tx.users.insert({ email: "[email protected]" })
    await tx.welcomeEmails.enqueue({ to: created.email })
    return created
  })

  const fetched = await keel.users.findById(user.id)
  console.log("Created user:", fetched)

  // Process the queued job
  await keel.welcomeEmails.processOne(async (job) => {
    console.log("Sending welcome email to:", job.payload.to)
  })
} finally {
  await keel.close()
}

Run the file with Node:

node index.ts
Created user: {
  id: '...',
  email: '[email protected]',
  createdAt: '2026-...'
}
Sending welcome email to: [email protected]

2. Wrap in a bounded-context Service with closed errors

In production, group owned resources behind a Service. Undeclared storage or transport errors cannot leak across the service boundary. Only declared Schema.TaggedError types cross to callers, and the same Service descriptor drives infrastructure inference in Alchemy IaC.

Create users.service.ts:

import { Schema } from "effect"
import { createKeel, k, tryKeel } from "@chimp-labs/keel/sdk"

class EmailTakenError extends Schema.TaggedError<EmailTakenError>()(
  "EmailTakenError",
  { email: Schema.String }
) {}

const Users = k.table("users", {
  id: k.uuid().primaryKey(),
  email: k.text().unique(),
  createdAt: k.datetime().defaultNow(),
})

const WelcomeEmails = k.queue("emails.welcome", k.object({ to: k.string() }))

const UsersService = k.service("users", {
  resources: [Users, WelcomeEmails],
  operations: {
    signup: {
      input: k.object({ email: k.string() }),
      output: k.object({ id: k.string(), email: k.string() }),
      errors: [EmailTakenError],
    },
  },
})

const keel = await createKeel({
  backend: "sqlite",
  resources: {
    users: Users,
    welcomeEmails: WelcomeEmails,
    usersService: UsersService,
  },
  ensureAll: true,
})

try {
  const service = await keel.usersService.live({
    signup: async ({ email }) => {
      const existing = await keel.users.select({ email })
      if (existing.length > 0) {
        throw new EmailTakenError({ email })
      }
      return keel.transaction(async (tx) => {
        const user = await tx.users.insert({ email })
        await tx.welcomeEmails.enqueue({ to: user.email })
        return { id: user.id, email: user.email }
      })
    },
  })

  const created = await service.signup({ email: "[email protected]" })
  console.log("Signed up:", created)

  // Declared domain errors come back typed via tryKeel (no leaky DB errors)
  const duplicate = await tryKeel(() =>
    service.signup({ email: "[email protected]" })
  )
  if (!duplicate.ok) {
    console.log("Duplicate rejected:", duplicate.error)
  }

  await keel.welcomeEmails.processOne(async (job) => {
    console.log("Sending welcome email to:", job.payload.to)
  })
} finally {
  await keel.close()
}
node users.service.ts
Signed up: { id: '...', email: '[email protected]' }
Duplicate rejected: { _tag: 'EmailTakenError', email: '[email protected]' }
Sending welcome email to: [email protected]

3. Test in memory with zero external services

Switch to backend: "memory" in tests to run the same descriptors in milliseconds with Node’s built-in test runner, node --test users.test.ts:

import assert from "node:assert/strict"
import test from "node:test"
import { createKeel, k } from "@chimp-labs/keel/sdk"

const resources = {
  users: k.table("users", {
    id: k.uuid().primaryKey(),
    email: k.text().unique(),
  }),
  welcomeEmails: k.queue("emails.welcome", k.object({ to: k.string() })),
}

test("creates a user and queues a welcome email", async () => {
  const keel = await createKeel({
    backend: "memory",
    resources,
    ensureAll: true,
  })

  try {
    const user = await keel.users.insert({ email: "[email protected]" })
    await keel.welcomeEmails.enqueue({ to: user.email })

    const sent: Array<string> = []
    await keel.welcomeEmails.processOne(async (job) => {
      sent.push(job.payload.to)
    })

    assert.equal(
      (await keel.users.findById(user.id))?.email,
      "[email protected]"
    )
    assert.deepEqual(sent, ["[email protected]"])
  } finally {
    await keel.close()
  }
})

Option B. Native Effect v4 (@chimp-labs/keel)

The core package exposes compile-time capability tracking in R and typed errors in E:

import { Effect, Schema } from "effect"
import { Table, ensureTable, insertRow, KeelMemoryLive } from "@chimp-labs/keel"

class UsersTable extends Table("users", {
  select: Schema.Struct({ id: Schema.String, email: Schema.String }),
  insert: Schema.Struct({ email: Schema.String }),
  primaryKey: "id",
  columns: {
    id: { type: "text", generated: "uuid" },
    email: { type: "text" },
  },
}) {}

const program = Effect.gen(function* () {
  yield* ensureTable(UsersTable)
  return yield* insertRow(UsersTable, { email: "[email protected]" })
}).pipe(Effect.provide(KeelMemoryLive))

const user = await Effect.runPromise(program)
console.log("Created user:", user)

Install the keel CLI

If @chimp-labs/keel is installed in your project, run the bundled CLI via pnpm exec keel (or npx keel).

For CI runners, containers, or machines without Node.js or pg/surrealdb installed, install the standalone binary (verified via SHA256SUMS.txt from GitHub Releases):

# macOS & Linux
curl -fsSL https://chimplabs.run/keel/install.sh | sh

# Pin a specific version
KEEL_VERSION=v0.1.0 curl -fsSL https://chimplabs.run/keel/install.sh | sh
# Windows (PowerShell)
irm https://chimplabs.run/keel/install.ps1 | iex

Verify the installation:

keel --version
keel --help

Install the Keel Agent Skill

Keel bundles a version-matched coding-agent skill (SKILL.md, modular reference guides, and runnable blueprints) inside both @chimp-labs/keel and the standalone keel CLI binary:

# Inside a Keel project (writes .agents/skills/keel/)
pnpm exec keel skill install

# Or one-shot from npm without installing globally
npx @chimp-labs/keel skill install

# Or install across multiple agent conventions (.agents, .claude, .cursor)
keel skill install --agent all

Inspect the bundled skill at any time with keel skill list or keel skill show.

Next steps

  • Plain TypeScript SDK covers k.* builders, Standard Schema v1 for Zod, Valibot, and ArkType, and keel.runEffect(...).
  • Bounded-context services and topology covers closed error contracts, inferKeelTopology, and Rust and Go contract generation.
  • Primitives overview lists all 18 core primitives across storage, messaging, services, security, coordination, and topologies, plus durable workflows in @chimp-labs/keel-workflow.
  • Backends overview shows how to swap Memory, SQLite, PostgreSQL 17, SurrealDB 4, Garage S3, and NATS or S2 without changing domain code.
  • Alchemy IaC shows how to infer Cloudflare Workers or self-hosted Docker stacks from Service definitions.