kysely-orm

kysely-orm is a skill for Claude Code from stonegiantstudio/skills. It costs 42 tokens per session (5,077 once invoked), scanned A, original, Apache-2.0.

Guidance for using Kysely, a TypeScript tool that builds SQL database queries while checking their types.

In plain words
What is it for?
Use it when writing Kysely queries, connecting PostgreSQL, MySQL, or SQL Server, creating manual migrations, or integrating Kysely into a TypeScript project.
Why use it?
It helps keep database queries and schema changes aligned with TypeScript and gives patterns for complex queries and migrations.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is npx kysely-codegen --out-file ./db/types.ts.

Part of the stone-giant plugin — 36 skills shipped together

Good fit Use it when writing Kysely queries, connecting PostgreSQL, MySQL, or SQL Server, creating manual migrations, or integrating Kysely into a TypeScript project.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/stonegiantstudio/skills
agentmods
npx agentmods add skills/stonegiantstudio/skills/kysely-orm

Made for: Claude Code.

Or install stone-giant, the plugin that ships this one along with the rest of its 36 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for kysely-orm

README.md
[![agentmods](https://agentmods.dev/badge/skills/stonegiantstudio/skills/kysely-orm.svg)](https://agentmods.dev/skills/stonegiantstudio/skills/kysely-orm)
Your own site
<a href="https://agentmods.dev/skills/stonegiantstudio/skills/kysely-orm"><img src="https://agentmods.dev/badge/skills/stonegiantstudio/skills/kysely-orm.svg" alt="Measured on agentmods" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,077 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00042 $0.05077
Opus 5 $0.00021 $0.02538
Sonnet 5 $0.00008 $0.01015
Haiku 4.5 $0.00004 $0.00508

Measured 7d ago against content hash 17c910df2a35, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

kysely-orm scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/stone-giant/skills/kysely-orm/SKILL.md · 837 lines

How it starts

The opening of the file, as written. The whole thing — 837 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Kysely ORM

Type-safe TypeScript SQL query builder. This skill covers Kysely-specific patterns—for database-specific syntax (PostgreSQL, SQL Server, MySQL), see the corresponding database skills.

When to Use Kysely vs Drizzle

Aspect Kysely Drizzle
Philosophy Pure query builder with typing Full ORM with schema-first approach
Migration tooling Manual up/down functions Auto-generated with drizzle-kit
Best for Knex.js migrations, complex queries New projects, integrated tooling
Nested queries Built-in helpers (jsonArrayFrom) Manual grouping required
Learning curve Familiar if you know SQL/Knex ORM concepts required

Choose Kysely when:

  • Migrating from Knex.js
  • You want SQL-like syntax with full type safety
  • You need complex nested queries with JSON aggregation
  • You prefer writing migrations manually

Project Setup

Installation

Use the project's package manager (detect from lock file: bun.lockb, pnpm-lock.yaml, yarn.lock, or package-lock.json).

# Core
<pkg> add kysely

# Database driver (choose one)
<pkg> add pg                  # PostgreSQL
<pkg> add mysql2              # MySQL
<pkg> add better-sqlite3      # SQLite
<pkg> add tedious             # SQL Server

Database Instance

// db/index.ts
import { Kysely, PostgresDialect } from 'kysely';
import { Pool } from 'pg';
import { Database } from './types';

export const db = new Kysely<Database>({
  dialect: new PostgresDialect({
    pool: new Pool({
      connectionString: process.env.DATABASE_URL,
    }),
  }),
});

// IMPORTANT: Call db.destroy() on app shutdown
process.on('SIGTERM', async () => {
  await db.destroy();
});

SQL Server Setup

import { Kysely, MssqlDialect } from 'kysely';
import * as Tedious from 'tedious';
import * as Tarn from 'tarn';

export const db = new Kysely<Database>({
  dialect: new MssqlDialect({
    tarn: {
      ...Tarn,
      options: {
        min: 0,
        max: 10,
      },
    },
    tedious: {
      ...Tedious,
      connectionFactory: () =>
        new Tedious.Connection({
          server: process.env.DB_HOST,
          authentication: {
            type: 'default',
            options: {
              userName: process.env.DB_USER,
              password: process.env.DB_PASSWORD,
            },
          },
          options: {
            database: process.env.DB_NAME,
            encrypt: true,
            trustServerCertificate: true,
          },
        }),
    },
  }),
});

Read the full file on GitHub · 837 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 837 lines · 42 tokens per session scan A 17c910df2a35

Subscribe to this mod's changes

kysely-orm is a skill published in the GitHub repository stonegiantstudio/skills (2 stars, last pushed 3d ago), licensed Apache-2.0. It adds 42 tokens to every session and 5,077 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.