重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
sqlite-data by johnrogers/claude-swift-engineering
npx skills add https://github.com/johnrogers/claude-swift-engineering --skill sqlite-data广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
使用带 FetchKeyRequest 的 @Fetch、动态查询、递归 CTE 或直接读取时 |
| 写入操作 | 插入、更新、更新插入、删除记录或管理事务时 |
| 视图 - SwiftUI | 在 SwiftUI 视图中使用 @FetchAll/@FetchOne、@Observable 模型或动画时 |
| 视图 - 集成 | UIKit 集成、动态查询加载、TCA 集成或使用 observe {} 时 |
| 迁移 | 使用 DatabaseMigrator 或 #sql() 宏创建数据库迁移时 |
| CloudKit 同步 | 设置 CloudKit 私有数据库同步、共享或同步委托时 |
| 依赖项 | 通过 @Dependency 注入数据库/同步引擎、引导模式或 TCA 集成时 |
| 测试 | 设置测试数据库、填充数据或为 SQLite 代码编写断言时 |
| 高级 - 查询 | 实现触发器、自定义数据库函数或全文搜索 (FTS5) 时 |
| 高级 - 优化 | 性能调优、索引、自定义聚合、JSON 聚合或自连接时 |
| 模式组合 | 使用 @Selection 列组、单表继承或数据库视图时 |
使用 SQLiteData 时:
@Table 宏定义表模型@Observable 模型中使用 @FetchAll/@FetchOne 属性包装器@Dependency(\.defaultDatabase) 访问数据库database.write { } 事务中执行写入操作N+1 查询模式 — 在循环中逐个加载记录(例如,先获取用户,再分别获取其所有帖子)会严重影响性能。应改用连接或批量获取。
模式变更时缺少迁移 — 修改 @Table 而不创建迁移会导致运行时崩溃。部署前务必为模式变更创建迁移。
事务处理不当 — 在 database.write { } 代码块之外进行长时间运行的事务可能导致死锁或数据丢失。保持写入代码块简短且专注。
忽略 CloudKit 同步委托 — 设置 CloudKit 同步而不实现 SyncDelegate 意味着您会错过错误处理和冲突解决。在生产环境中应实现所有委托方法。
在 SwiftUI 视图中过度获取 — 使用 @FetchAll 而不进行过滤/限制可能会加载数千条记录,导致 UI 冻结。使用谓词、限制和排序来保持较小的内存占用。
每周安装量
58
代码仓库
GitHub 星标数
179
首次出现
2026年1月24日
安全审计
安装于
codex43
opencode41
gemini-cli40
github-copilot38
claude-code37
cursor36
SQLiteData provides type-safe SQLite access through Swift macros, simplifying database modeling and queries while handling CloudKit sync, migrations, and async patterns automatically.
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 |
|---|---|
| Table Models | Defining tables with @Table, setting up primary keys, columns, or enums |
| Queries - Basics | Using @FetchAll, @FetchOne, @Selection, filtering, ordering, or joins |
| Queries - Advanced | Using @Fetch with FetchKeyRequest, dynamic queries, recursive CTEs, or direct reads |
| Writes | Inserting, updating, upserting, deleting records, or managing transactions |
| Views - SwiftUI | Using @FetchAll/@FetchOne in SwiftUI views, @Observable models, or animations |
| Views - Integration | UIKit integration, dynamic query loading, TCA integration, or observe {} |
| Migrations | Creating database migrations with DatabaseMigrator or #sql() macro |
| CloudKit Sync | Setting up CloudKit private database sync, sharing, or sync delegates |
| Dependencies | Injecting database/sync engine via @Dependency, bootstrap patterns, or TCA integration |
| Testing | Setting up test databases, seeding data, or writing assertions for SQLite code |
| Advanced - Queries | Implementing triggers, custom database functions, or full-text search (FTS5) |
| Advanced - Optimization | Performance tuning, indexes, custom aggregates, JSON aggregation, or self-joins |
| Schema Composition | Using @Selection column groups, single-table inheritance, or database views |
When working with SQLiteData:
@Table macro@FetchAll/@FetchOne property wrappers in views or @Observable models@Dependency(\.defaultDatabase)database.write { } transactionsN+1 query patterns — Loading records one-by-one in a loop (e.g., fetching user then fetching all their posts separately) kills performance. Use joins or batch fetches instead.
Missing migrations on schema changes — Modifying @Table without creating a migration causes crashes at runtime. Always create migrations for schema changes before deploying.
Improper transaction handling — Long-running transactions outside of database.write { } block can cause deadlocks or data loss. Keep write blocks short and focused.
Ignoring CloudKit sync delegates — Setting up CloudKit sync without implementing SyncDelegate means you miss error handling and conflict resolution. Implement all delegate methods for production.
Over-fetching in SwiftUI views — Using @FetchAll without filtering/limiting can load thousands of records, freezing the UI. Use predicates, limits, and sorting to keep in-memory footprint small.
Weekly Installs
58
Repository
GitHub Stars
179
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex43
opencode41
gemini-cli40
github-copilot38
claude-code37
cursor36
Kotlin Exposed ORM 模式指南:DSL查询、DAO、事务管理与生产配置
1,200 周安装