room-multiplatform

Configure Room Multiplatform persistence with shared entities, DAOs, and platform-specific database builders.

Updated Sep 12, 2026
One-click install
npx skills add https://github.com/Vierco/citoVisionApp --skill room-multiplatform-vierco
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: room-multiplatform
Source: https://github.com/Vierco/citoVisionApp/tree/main/.claude/skills/room-multiplatform
Command: npx skills add https://github.com/Vierco/citoVisionApp --skill room-multiplatform-vierco

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up Room in a Kotlin Multiplatform project is error-prone: DAOs that compile on Android break on iOS/Desktop, Android-only APIs leak into commonMain, and SQLite drivers behave inconsistently across platforms. This Skill provides a complete, opinionated blueprint for implementing local persistence with Room KMP inside a Clean Architecture Infrastructure layer. ## Core Features & Use Cases - Shared schema definition: Define @Entity classes, @Dao interfaces (suspend/Flow), and the @Database class with @ConstructedBy entirely in commonMain. - Platform-specific builders: Implement getDatabaseBuilder() for Android (Context.getDatabasePath), iOS (NSFileManager/NSDocumentDirectory), and Desktop (java.io.File), with BundledSQLiteDriver as the default driver. - KMP-safe rules: Enforce suspend/Flow DAO functions, SQLiteConnection-based migrations, useWriterConnection/useReaderConnection transactions, and ProGuard rules for minified builds. - Use Case: You are migrating an Android-only Room database to a KMP shared module. Use this Skill to restructure entities and DAOs into commonMain, configure KSP per target, and wire the database into your Repository's LocalDataSource. ## Quick Start Ask the AI to set up Room Multiplatform persistence in the shared module for a given set of entities and queries, following this Skill's architecture.

Frequently Asked Questions about room-multiplatform

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

FAQPage Schema
How do I set up Room in a Kotlin Multiplatform project?▼

Apply the androidx.room and ksp plugins in the shared module, declare entities, DAOs, and the @Database class in commonMain, and add the room-compiler to each KSP target (kspAndroid, kspIosArm64, kspDesktop). Only the RoomDatabase.Builder construction is platform-specific.

How do I create the Room database builder on Android, iOS, and Desktop?▼

Each platform provides its own getDatabaseBuilder(): Android uses Context.getDatabasePath(), iOS resolves NSDocumentDirectory via NSFileManager, and Desktop uses java.io.File. A shared getRoomDatabase(builder) in commonMain then sets the driver and coroutine context.

Which SQLite driver should Room KMP use?▼

BundledSQLiteDriver is the default because it guarantees identical SQLite behavior across Android, iOS, and Desktop. Switch to a native driver (AndroidSQLiteDriver, NativeSQLiteDriver) only for explicit reasons like binary size, and declare it in the platformModule.

Why does my Room DAO fail to compile for iOS or Desktop?▼

Blocking DAO functions (non-suspend, non-Flow) only work on Android and break KMP targets. Every DAO function compiled for commonMain must be suspend or return Flow<T>, and Android-only APIs like withTransaction or SupportSQLiteDatabase must not appear in shared code.

How do Room migrations work in Kotlin Multiplatform?▼

Migrations and callbacks must use the KMP SQLiteConnection APIs, never SupportSQLiteDatabase, which is Android-only. Write transactions use useWriterConnection with immediateTransaction, and read-only transactions use useReaderConnection with deferredTransaction.

When should I not use Room Multiplatform?▼

This Skill does not cover designing the Repository itself, typing persistence errors, Koin injection, or network calls; those belong to repository-pattern, result-pattern, dependency-injection-koin, and ktor-client skills. It also excludes Room 3.0, which is unstable with incompatible package changes.