Offline first is an AI agent skill from the GitHub repository rnavarych/alpha-engineer. Expert guidance on offline-first mobile architecture — local database sync (WatermelonDB, Realm, Hive, SQLite), conflict resolution strategies (last-write-wins, CRDT), optimistic UI patterns, background sync (WorkManager, BGTaskScheduler), and connectivity detection. Use when designing apps that mus
Claude Code: save it as .claude/skills/offline-first/SKILL.md
Cursor: save it as .cursor/rules/offline-first.md
Codex: save it as .agents/skills/offline-first/SKILL.md
ChatGPT, Gemini and other assistants: paste it into custom or project instructions
Skill file
Offline-First Architecture
When to use
Designing an app that must function fully without network connectivity
Choosing a local database for offline storage (WatermelonDB, Realm, Hive, SQLite)
Defining conflict resolution rules before a sync feature is built
Implementing optimistic UI updates with mutation queues
Setting up background sync with WorkManager (Android) or BGTaskScheduler (iOS)
Handling connectivity detection, reachability checks, and retry strategies
Core principles
Network is optional — the app is fully usable offline; sync is background enrichment
Local-first reads — always read from local DB; never block UI on a network call
Optimistic writes — apply locally first, queue for server, reconcile on response
Conflict rules before code — LWW is simple; CRDT is correct; decide before building, not after
Partial sync is the norm — background tasks get killed; design every sync step to resume cleanly
Reference Files
references/local-db-conflict.md — WatermelonDB, Realm, Hive, and SQLite comparison for offline storage, last-write-wins strategy, field-level merge, CRDT types and libraries (Automerge, Yjs), Operational Transform tradeoffs
references/sync-connectivity.md — core offline-first principles, optimistic UI pattern and mutation queue implementation, Android WorkManager background sync, iOS BGTaskScheduler, cross-platform background fetch, connectivity detection libraries and best practices, exponential backoff strategy
Use this skill with your AI agent:Open on Skill Issue to copy, download, or add to your library.
Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.