mobile-storage
Use when the user asks about local storage on mobile: SQLite, Room, Core Data, SwiftData, DataStore, UserDefaults, Hive, Isar, Drift, file storage or database…
by j4flmao★ 47 GitHub stars
Install mobile-storage in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
Mobile Storage
Purpose
Design mobile local storage architectures selecting the right persistence strategy — SQLite, Room, Core Data, Hive, Isar, key-value, or file storage — with migration planning.
Agent Protocol
Trigger
User request includes: mobile storage, local database, sqlite mobile, room database, core data, hive, isar, sharedpreferences, userdefaults, file storage mobile, migration mobile.
Input Context
- Platform (iOS, Android, Flutter, React Native)
- Data complexity (simple K/V vs relational vs document)
- Storage library (Room, Core Data, Hive, Isar, WatermelonDB)
- Migration requirements
Output Artifact
A markdown document containing:
- Storage layer architecture
- Schema design
- CRUD operations
- Migration plan
Response Format
No preamble. No postamble. No explanations.
Max Response Length
4096 tokens
Decision Trees
Storage Type Selection
What kind of data?
├── Simple key-value (settings, preferences, feature flags)
│ ├── Secure (tokens, auth) → Keychain / EncryptedSharedPrefs / flutter_secure_storage
│ └── Non-sensitive → UserDefaults / SharedPreferences / AsyncStorage
├── Complex queryable (user records, products, orders)
│ ├── Relational with JOINs/aggregations → SQLite (Room, CoreData, sqflite, WatermelonDB)
│ └── Document/NoSQL (nested, simple queries) → Isar, Hive, Realm
├── Large files (images, video, documents)
│ ├── Cache → Temporary directory, LRU eviction
│ └── Permanent → Application documents directory
└── Real-time sync across devices → CloudKit, Firebase, custom API + local cache
Migration Strategy
Is schema likely to change?
├── Yes, planned evolution (most apps)
│ ├── Version schema from v1
│ ├── Write incremental migrations (1→2, 2→3, never skip)
│ ├── Test migration from every previous version
│ └── Have rollback plan (destructive vs non-destructive)
├── Schema rarely changes (utilities, tools)
│ └── Single version, handle via JSON blobs for flexibility
└── Frequent changes (rapid prototyping)
└── Consider destructive migration (delete and recreate) for non-production
Sync Strategy
Does data sync across devices?
├── No sync needed → Local-first, local DB is source of truth
├── Online-first (network authoritative, local is cache)
│ └── Cache API responses, stale-while-revalidate
└── Offline-first (local authoritative, background sync)
└── Local-first writes, sync queue, conflict resolution
Workflow
Step 1: Select Storage Type
Step 2: Design Schema
Define entities/tables with proper column types, indexes for query paths, and relationships.
Step 3: Implement CRUD Operations
Set up DAOs/repositories with insert, read, update, delete operations and query methods.
Step 4: Plan Migrations
Version the schema from day one, write migration scripts for each version change, and test rollback paths.
Storage Selection
| Need | iOS | Android | Flutter | RN |
|---|---|---|---|---|
| Simple K/V | UserDefaults | SharedPreferences | SharedPreferences | AsyncStorage |
| Secure K/V | Keychain | EncryptedSharedPrefs | flutter_secure_storage | react-native-keychain |
| Relational | Core Data | Room | sqflite / drift | WatermelonDB |
| Document | Realm | Realm | Isar / Hive | Realm |
| File | FileManager | Internal Storage | path_provider | react-native-fs |
Implementation — Relational Databases
Android — Room
// Entity
@Entity(
tableName = "orders",
indices = [Index("customer_id"), Index("status", "created_at")]
)
data class OrderEntity(
@PrimaryKey val id: String,
@ColumnInfo(name = "customer_id") val customerId: String,
val status: String,
val total: Double,
@ColumnInfo(name = "created_at") val createdAt: Long
)
// DAO
@Dao
interface OrderDao {
@Query("SELECT * FROM orders WHERE customer_id = :customerId ORDER BY created_at DESC")
fun getOrders(customerId: String): Flow<List<OrderEntity>>
@Query("SELECT COUNT(*) FROM orders WHERE status = :status")
fun countByStatus(status: String): Flow<Int>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun upsertAll(orders: List<OrderEntity>)
@Query("DELETE FROM orders WHERE id = :id")
suspend fun deleteById(id: String)
@Transaction
@Query("SELECT * FROM orders o INNER JOIN customers c ON o.customer_id = c.id WHERE o.status = :status")
fun getOrdersWithCustomer(status: String): Flow<List<OrderWithCustomer>>
}
// Database
@Database(entities = [OrderEntity::class, CustomerEntity::class], version = 2)
abstract class AppDatabase : RoomDatabase() {
abstract fun orderDao(): OrderDao
abstract fun customerDao(): CustomerDao
companion object {
@Volatile private var INSTANCE: AppDatabase? = null
fun getInstance(context: Context): AppDatabase {
return INSTANCE ?: synchronized(this) {
Room.databaseBuilder(context, AppDatabase::class.java, "app.db")
.addMigrations(MIGRATION_1_2)
.build()
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
- references/cloud-storage.md
- references/file-system.md
- references/local-database-guide.md
- references/local-storage.md
- references/mobile-storage-patterns.md
- references/preferences.md
- references/sqlite.md
- references/sync-conflict-resolution.md
FAQ
What does the mobile-storage skill do?
Use when the user asks about local storage on mobile: SQLite, Room, Core Data, SwiftData, DataStore, UserDefaults, Hive, Isar, Drift, file storage or database migrations on device. Produces a storage choice, schema and migration code. Not for sync with a server (use mobile-offline-first) or secrets storage (use mobile-security).
How do I install the mobile-storage skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the mobile-storage skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…