swift-sql

Construct type-safe SQL queries in Swift using GRDB and swift-structured-queries.

1|Updated Jul 22, 2026
One-click install
npx skills add https://github.com/wyattjoh/skills --skill swift-sql
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-sql
Source: https://github.com/wyattjoh/skills/tree/main/skills/swift-sql
Command: npx skills add https://github.com/wyattjoh/skills --skill swift-sql

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill addresses the complexity of writing type-safe database queries in Swift, providing a unified approach to using the swift-structured-queries DSL, GRDB.swift, and the #sql macro.

Core Features & Use Cases

  • Type-Safe DSL: Build complex queries using Swift closures, ensuring compile-time safety for filters, joins, and ordering.
  • Advanced SQL Support: Utilize the #sql macro for window functions, CTEs, and complex subqueries that exceed standard DSL capabilities.
  • Performance Optimization: Implement covering indexes, WAL mode, and efficient aggregation patterns to ensure high-performance database interactions.

Quick Start

Use the swift-sql skill to generate a type-safe query for fetching active records with a specific filter and ordering.

Frequently Asked Questions about swift-sql

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

FAQPage Schema
How do I write type-safe SQL queries in Swift?

Type-safe SQL queries in Swift are constructed using closures and DSLs to ensure compile-time safety for filters, joins, and ordering. This approach prevents runtime errors by validating query structure during compilation.

Does GRDB support advanced SQL features like window functions and CTEs?

GRDB supports advanced SQL features like window functions and CTEs through the #sql macro. This macro enables complex subqueries that exceed standard DSL capabilities while maintaining type safety.

How do I optimize SQLite performance in iOS Swift applications?

SQLite performance in iOS Swift applications is optimized by implementing covering indexes, enabling WAL mode, and using efficient aggregation patterns. These strategies ensure high-performance database interactions for robust data access layers.

Can I use the swift-structured-queries DSL for server-side Swift projects?

The swift-structured-queries DSL can be used for server-side Swift projects to facilitate complex database operations. It provides robust, performant, and maintainable data access layers suitable for both iOS and server-side environments.

What is the best way to handle complex subqueries in Swift SQL?

Complex subqueries in Swift SQL are best handled using the #sql macro, which allows you to write window functions, CTEs, and complex subqueries that exceed standard DSL capabilities while maintaining type safety.

When should I use the #sql macro instead of the standard Swift SQL DSL?

The #sql macro should be used instead of the standard Swift SQL DSL when you need window functions, CTEs, or complex subqueries that exceed standard DSL capabilities. It bridges the gap between type safety and advanced SQL features.