kysely

Build type-safe SQL queries for TypeScript applications with Kysely generics.

Updated May 20, 2026
One-click install
npx skills add https://github.com/Hollowvyn/cognipace-v2 --skill kysely-hollowvyn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kysely
Source: https://github.com/Hollowvyn/cognipace-v2/tree/main/.agents/skills/kysely
Command: npx skills add https://github.com/Hollowvyn/cognipace-v2 --skill kysely-hollowvyn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kysely eliminates the tedium and risk of writing database code without reliable TypeScript guarantees by keeping query inputs and results strongly typed end-to-end, from your schema to executed SQL.

Core Features & Use Cases

  • Full Type Inference (Schema → Queries → Results): prevents common type mismatches by inferring the return shape from your table definitions and selected fields.
  • Plain SQL with Raw Escape Hatch: supports complex SQL constructs (CTEs, window functions, subqueries) while still allowing targeted raw SQL with types when needed.
  • Safe Migrations and Transactions: helps you evolve schemas with reversible up/down migrations and wrap multi-step operations in typed transactions.

Use it when you’re building a production-grade data layer in TypeScript, especially for complex querying and schema evolution where you want SQL control without ORM overhead (e.g., migrating an existing codebase, implementing advanced reporting queries, or adding transactional writes).

Quick Start

Use the kysely skill to generate a type-safe SELECT and INSERT flow for your database by defining your Database interface, creating a Kysely instance with the correct dialect/driver, and writing queries with execute to obtain correctly typed results.

Frequently Asked Questions about kysely

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build type-safe SQL queries in TypeScript without ORM overhead?

Type-safe SQL queries in TypeScript are built by mapping schema-defined table types to compile-time checked query results using a query builder, preventing common type mismatches from schema to executed SQL without ORM overhead.

What is the best way to manage SQL migrations and transactions in a TypeScript backend?

Managing SQL migrations and transactions in a TypeScript backend is handled through reversible up/down migrations for schema evolution and wrapping multi-step operations in typed transactions to ensure data integrity.

Can I use raw SQL for complex constructs like CTEs and window functions while maintaining type safety?

Raw SQL for complex constructs like CTEs and window functions is supported through typed raw SQL via sql template tags, allowing targeted raw SQL execution while maintaining end-to-end static type requirements.

How does type inference work for SQL query results in TypeScript?

Type inference for SQL query results works by inferring the return shape directly from your table definitions and selected fields, ensuring that CRUD operations, joins, and aggregations return strongly typed data end-to-end.

Does this type-safe query builder approach work for local-first apps and common SQL databases?

This type-safe query builder approach works for local-first apps and backend services by supporting dialect-specific execution across common SQL databases, applying typed generics to satisfy static type requirements.