Skip to content
Development
Skill

/grdb

Use when writing raw SQL with GRDB, complex joins across 4+ tables, window functions, ValueObservation for reactive queries, or dropping down from SQLiteData for performance. Direct SQLite access for iOS/macOS with type-safe queries and migrations.

From plugin
claude-swift-engineering
23317 skills11 agents3 commands

Claude Code

$ npx -y skills add johnrogers/claude-swift-engineering --skill grdb --agent claude-code

SKILL.md

grdb.SKILL.md
name: grdb
description: Use when writing raw SQL with GRDB, complex joins across 4+ tables, window functions, ValueObservation for reactive queries, or dropping down from SQLiteData for performance. Direct SQLite access for iOS/macOS with type-safe queries and migrations.

GRDB

Direct SQLite access using [GRDB.swift](https://github.com/groue/GRDB.swift) - type-safe Swift wrapper with full SQLite power when you need it.

Reference Loading Guide

**ALWAYS load reference files if there is even a small chance the content may be required.** It's better to have the context than to miss a pattern or make a mistake.

| Reference | Load When | |-----------|-----------| | **[Getting Started](references/getting-started.md)** | Setting up DatabaseQueue or DatabasePool | | **[Queries](references/queries.md)** | Writing raw SQL, Record types, type-safe queries | | **[Value Observation](references/value-observation.md)** | Reactive queries, SwiftUI integration | | **[Migrations](references/migrations.md)** | DatabaseMigrator, schema evolution | | **[Performance](references/performance.md)** | EXPLAIN QUERY PLAN, indexing, profiling |

When to Use GRDB vs SQLiteData

| Scenario | Use | |----------|-----| | Type-safe @Table models | SQLiteData | | CloudKit sync needed | SQLiteData | | Complex joins (4+ tables) | GRDB | | Window functions (ROW_NUMBER, RANK) | GRDB | | Performance-critical raw SQL | GRDB | | Reactive queries (ValueObservation) | GRDB |

Core Workflow

1. Choose DatabaseQueue (single connection) or DatabasePool (concurrent reads) 2. Define migrations with DatabaseMigrator 3. Create Record types (Codable, FetchableRecord, PersistableRecord) 4. Write queries with raw SQL or QueryInterface 5. Use ValueObservation for reactive updates

Requirements

  • iOS 13+, macOS 10.15+
  • Swift 5.7+
  • GRDB.swift 6.0+

Common Mistakes

1. **Performance assumptions without EXPLAIN PLAN** — Assuming your query is fast or slow without checking `EXPLAIN QUERY PLAN` is guessing. Always profile queries with EXPLAIN before optimizing.

2. **Missing indexes on WHERE clauses** — Queries filtering on non-indexed columns scan the entire table. Index any column used in WHERE, JOIN, or ORDER BY clauses for large tables.

3. **Improper migration ordering** — Running migrations out of order or skipping intermediate versions breaks schema consistency. Always apply migrations sequentially; never jump versions.

4. **Record conformance shortcuts** — Not conforming Record types to `PersistableRecord` or `FetchableRecord` correctly leads to silent data loss or deserialization failures. Always implement all required protocols correctly.

5. **ValueObservation without proper cleanup** — Forgetting to cancel ValueObservation when views disappear causes memory leaks and stale data subscriptions. Store the cancellable and clean up in deinit.

Read more
@johnrogers
Ships withclaude-swift-engineering

Claude Code plugin marketplace for modern Swift/SwiftUI development A specialized AI toolkit for building professional iOS/macOS features with modern Swift 6.2, TCA (The Composable Architecture), and SwiftUI.

23317 skills11 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
233
Star history of johnrogers/claude-swift-engineering on GitHub, a chart by star-history.com

Other skills on claude-swift-engineering.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills2w309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc3w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react10d252k
@facebook@facebookInstall Skill

Questions about grdb.

Which coding agents can use grdb?
grdb installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.