Use when writing raw SQL queries with GRDB, complex joins, ValueObservation for reactive queries, DatabaseMigrator patterns, query profiling under performance pressure, or dropping down from SQLiteData for performance - direct SQLite access for iOS/macOS
View on GitHubSelect agents to install to:
npx add-skill https://github.com/CharlesWiltgen/Axiom/blob/main/.claude-plugin/plugins/axiom/skills/axiom-grdb/SKILL.md -a claude-code --skill axiom-grdbInstallation paths:
.claude/skills/axiom-grdb/# GRDB ## Overview Direct SQLite access using [GRDB.swift](https://github.com/groue/GRDB.swift) — a toolkit for SQLite databases with type-safe queries, migrations, and reactive observation. **Core principle** Type-safe Swift wrapper around raw SQL with full SQLite power when you need it. **Requires** iOS 13+, Swift 5.7+ **License** MIT (free and open source) ## When to Use GRDB #### Use raw GRDB when you need - ✅ Complex SQL joins across 4+ tables - ✅ Window functions (ROW_NUMBER, RANK, LAG/LEAD) - ✅ Reactive queries with ValueObservation - ✅ Full control over SQL for performance - ✅ Advanced migration logic beyond schema changes **Note:** SQLiteData now supports GROUP BY (`.group(by:)`) and HAVING (`.having()`) via the query builder — see the `axiom-sqlitedata-ref` skill. #### Use SQLiteData instead when - Type-safe `@Table` models are sufficient - CloudKit sync needed - Prefer declarative queries over SQL #### Use SwiftData when - Simple CRUD with native Apple integration - Don't need raw SQL control **For migrations** See the `axiom-database-migration` skill for safe schema evolution patterns. ## Example Prompts These are real questions developers ask that this skill is designed to answer: #### 1. "I need to query messages with their authors and count of reactions in one query. How do I write the JOIN?" → The skill shows complex JOIN queries with multiple tables and aggregations #### 2. "I want to observe a filtered list and update the UI whenever notes with a specific tag change." → The skill covers ValueObservation patterns for reactive query updates #### 3. "I'm importing thousands of chat records and need custom migration logic. How do I use DatabaseMigrator?" → The skill explains migration registration, data transforms, and safe rollback patterns #### 4. "My query is slow (takes 10+ seconds). How do I profile and optimize it?" → The skill covers EXPLAIN QUERY PLAN, database.trace for profiling, and index creation #### 5. "I need to fetch ta