Command Palette

Search for a command to run...

Назад к скиллам
скилл № 55867

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…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить mobile-storage в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

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()
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • 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

Что делает скилл 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 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).

Как установить скилл mobile-storage?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл mobile-storage запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить mobile-storage с