Command Palette

Search for a command to run...

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

mobile-offline-first

Use when the user asks about offline-first mobile apps, offline mode, syncing local data when the phone comes back online, an outbox queue, conflict…

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

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

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

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

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

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

Mobile Offline First

Purpose

Guide for building mobile apps with offline-first architecture: local-first data, background sync, conflict resolution, and connectivity-aware UX.

Agent Protocol

Trigger

Phrases: "offline-first", "offline mode", "offline sync", "local storage", "offline cache", "sync strategy", "conflict resolution", "offline queue", "mobile offline", "local database"

Input Context

  • Data models and entity relationships
  • API endpoints and data flow patterns
  • Conflict resolution requirements per entity
  • Sync frequency and triggers

Output Artifact

Offline architecture: local DB schema, repository pattern with cache-first strategy, sync engine with queue/retry, conflict resolution rules, connectivity detection.

Response Format

<offline-first>
<local-db>{schema, repository, cache-first reads}</local-db>
<sync>{triggers, queue, replay, idempotency}</sync>
<conflicts>{strategy per entity, manual resolution}</conflicts>
<connectivity>{detection, UI states}</connectivity>
</offline-first>

No preamble. No postamble. No explanations.

Completion Criteria

  • Local DB reads return data without network call (cache hit)
  • Offline writes queued and replayed on connectivity restore
  • Conflict resolution produces deterministic result per entity
  • User sees clear offline/online status indicator
  • Sync progress is visible during background sync

Max Response Length

8000 tokens

Decision Trees

Offline Architecture Selection

What kind of data?
├── Reference data (product catalog, settings) → Cache-first, pull-only
│   └── No conflict risk. Just stale data.
├── User-generated (notes, photos, orders) → Local-first with sync queue
│   └── Conflict possible. Need idempotency + resolution.
├── Collaborative (shared docs, lists, boards) → CRDT or OT
│   └── Concurrent edits likely. Need merge strategy.
└── Financial/legal (transactions, signatures) → Optimistic local, server authority
    └── Conflicts must be manually resolved. No auto-merge.

Local Database Selection

Cross-platform need?
├── Single platform
│   ├── Android → Room (compile-time SQL, Flow, migrations)
│   └── iOS → CoreData (SwiftUI integration, iCloud sync)
├── KMP (Kotlin Multiplatform) → SQLDelight (type-safe, cross-platform)
├── Hybrid/React Native → WatermelonDB (SQLite-based, lazy loading)
└── Simple key-value → MMKV (fast, no schema needed)

Sync Trigger Strategy

How fresh does data need to be?
├── Seconds (chat, live collab) → WebSocket real-time push
├── Minutes (feeds, notifications) → Silent push + foreground sync
├── Hours (reference, catalog) → Periodic background sync (WorkManager / BGTaskScheduler)
└── On demand (user action required) → Pull-to-refresh only

Workflow

1. Offline-First Architecture

The local database is the single source of truth. All reads go to local DB first. All writes go to local DB first, then sync to server. The network is a sync mechanism, not a data source.

Three layers:

  • Local data layer: Room, CoreData, SQLDelight, or SQLite with repository pattern
  • Sync engine: Monitors connectivity, replays queued writes, pulls remote changes, resolves conflicts
  • UI layer: Observes local DB via reactive streams (Flow, Combine), displays connectivity state, shows staleness indicators

2. Local Database Selection

  • Room (Android): compile-time SQL verification, Flow-based reactive queries, migrations
  • SQLDelight (KMP): cross-platform, type-safe, generates drivers for Android/iOS/JVM
  • CoreData (iOS native): SwiftUI @FetchRequest, iCloud sync, lightweight migration
  • Realm: local object database; MongoDB's Atlas Device Sync reached end of life in September 2025, so plan your own sync or another backend (e.g. PowerSync, Ditto) for new apps
  • WatermelonDB: SQLite lazy loading for React Native
  • MMKV: Fast key-value, no schema, ideal for settings/cache

3. Repository Pattern with Cache-First Strategy

Read flow: return cached → check staleness TTL → if stale+online: fetch, update local DB, notify → if offline: return cached with staleness indicator. Write flow: validate → write to local DB → enqueue sync op → if online, trigger immediate sync → UI reacts to local DB change.

4. Sync Triggers and Frequency

  • App foreground: immediate sync
  • Periodic: WorkManager (15 min min) / BGTaskScheduler
  • Silent push: wake app for sync
  • Pull-to-refresh: user gesture
  • After queue drain: replay writes, then fetch remote changes
  • Adaptive: WiFi = frequent, cellular = reduced, battery low = pause

5. Conflict Resolution Strategies

  • Last-write-wins: simplest, server timestamp authority
  • Timestamp-based: client timestamp, server keeps latest (vulnerable to clock skew; prefer server-assigned versions or hybrid logical clocks)
  • CRDT: mathematically guaranteed convergence
  • Three-way merge: base + local + remote = merged
  • Manual: surface conflict to user, let them choose

6. Offline Queue Managem

Полный SKILL.md на GitHub

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

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

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

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

  • references/conflict-resolution.md
  • references/local-storage.md
  • references/mobile-database.md
  • references/offline-first-architecture.md
  • references/offline-sync.md
  • references/sync-strategies.md

FAQ

Что делает скилл mobile-offline-first?

Use when the user asks about offline-first mobile apps, offline mode, syncing local data when the phone comes back online, an outbox queue, conflict resolution or connectivity detection. Produces a local-first data layer and sync protocol. Not for collaborative CRDT merging (use architecture-crdts) or choosing a local database (use mobile-storage).

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

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

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

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

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

Сравнить mobile-offline-first с