offline
Skill2 starsChanged 9 months agoMITView on GitHub
Offline-first architecture with local storage, sync, and conflict resolution. Use when adding offline support, data synchronization, local caching, or queue-based sync. Supports fully offline apps and online-first apps with offline fallback.
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 6 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Simple in-memory caching: - Use /data caching patterns instead
- Very specific: line 22
Network connectivity detection: - Use /network-connectivity instead
- Very specific: line 23
Error handling for failed requests: - Use /data NetworkFailure types
- Very specific: line 85
Add dependencies to pubspec.yaml
- Distinctive: line 86
Create local database models/tables
- Distinctive: line 93
Add sync status tracking to models
- Distinctive: line 94
Create sync queue for pending operations
- Distinctive: line 96
Add background sync via WorkManager (optional)
- Distinctive: line 103
Add write-through or write-behind patterns
- Distinctive: line 191
After running this skill:
- Very specific: line 192
Run /network-connectivity for offline banner
- Very specific: line 193
Run /testing for offline scenario tests
- Very specific: line 194
Run /i18n for sync status messages
- Very specific: line 195
Consider /push-notifications for push-based sync
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Offline - Offline-First Architecture
Implement offline-first architecture with local storage, automatic sync, and conflict resolution. Supports multiple patterns from fully offline apps to online-first with offline fallback.
When to Use This Skill
- Adding offline support to existing features
- Building fully offline-first apps
- Implementing data synchronization
- Adding local caching with sync
- User asks "offline mode", "sync data", "work offline", "cache locally"
When NOT to Use This Skill
- Simple in-memory caching - Use
/datacaching patterns instead - Network connectivity detection - Use
/network-connectivityinstead - Error handling for failed requests - Use
/dataNetworkFailure types
Questions to Ask
- Offline mode: Fully offline-first or online-first with offline fallback?
- Data complexity: Simple key-value or structured relational data?
- Sync strategy: Periodic sync, on-demand, or push-based?
- Conflict resolution: Last-write-wins, server-wins, or custom merge?
- Data sensitivity: Does local data need encryption?
Quick Reference
Offline Patterns
| Pattern | Use When | Local DB | Sync |
| Fully Offline | Notes, journals, todo apps | Primary | Optional upload |
| Offline-First | Field apps, travel apps | Primary | Background sync |
| Online-First + Fallback | E-commerce, social apps | Cache | On reconnect |
| Cache-Only | Read-heavy feeds | TTL cache | Refresh on pull |
Storage Options
| Storage | Best For | Encryption | Performance |
| Drift (SQLite) | Relational data, complex queries | AES-256 via SQLCipher | Fast |
| Hive | Key-value, settings, small objects | Built-in AES-256 | Very fast |
| Isar | Large datasets, full-text search | Limited | Fastest |
| SharedPreferences | Flags, simple settings | None | Fast |
| SecureStorage | Tokens, PII | Platform keychain | Slower |
Sync Strategies
| Strategy | Trigger | Best For |
| Periodic | Timer (5-15 min) | Background updates |
| On-Demand | User pull-to-refresh | User-controlled sync |
| On-Reconnect | Connectivity change | Offline queue flush |
| Push-Based | FCM/WebSocket | Real-time apps |
| Delta Sync | Timestamp-based | Large datasets |
Conflict Resolution
| Strategy | How It Works | Best For |
| Last-Write-Wins (LWW) | Latest timestamp wins | Simple apps, non-critical data |
| Server-Wins | Server always authoritative | Multi-user shared data |
| Client-Wins | Local changes preserved | Single-user apps |
| Custom Merge | Field-level merge logic | Complex business rules |
| User Prompt | Ask user to resolve | Important conflicts |
Workflow
Phase 1: Analyze Requirements
- Determine offline pattern (see Quick Reference)
- Identify data that needs offline access
- Choose storage solution based on data complexity
- Define sync strategy and conflict resolution
Phase 2: Setup Local Storage
- Add dependencies to
pubspec.yaml - Create local database models/tables
- Implement local data source
See: storage-guide.md for detailed setup
Phase 3: Implement Sync Layer
- Add sync status tracking to models
- Create sync queue for pending operations
- Implement sync service with conflict resolution
- Add background sync via WorkManager (optional)
See: sync-guide.md for sync patterns
Phase 4: Update Repository
- Modify repository to read local-first
- Add write-through or write-behind patterns
- Handle sync status in domain entities
- Integrate with connectivity monitoring
Phase 5: Verify
dart run .claude/skills/offline/scripts/check.dart --feature {feature}Core API
final items = await repository.getAll(); // Local-first read
await repository.create(item); // Saves locally, queues sync
final isSynced = ref.watch(syncStatusProvider);See: storage-guide.md for dependencies and file structure.
Guides
| File | Content |
| architecture-guide.md | Offline architecture patterns and decisions |
| storage-guide.md | Local storage setup (Drift, Hive) |
| sync-guide.md | Sync strategies and conflict resolution |
Reference Files
See: reference/ for complete implementations:
reference/models/- SyncStatus enum, SyncOperation, OfflineEntity mixinreference/local_storage/- Drift database, Hive local sourcereference/sync/- SyncQueue, SyncService, ConflictResolverreference/repositories/- Offline-first and cache-first patternsreference/providers/- Sync status providers
Checklist
Setup:
- Offline pattern determined (fully offline vs. online-first + fallback)
- Storage solution chosen (Drift/Hive) and added to pubspec.yaml
- Local database/tables created
Models:
- Domain entity has
syncStatusfield - DTO model has sync tracking fields (
localId,updatedAt,isSynced) - Client-generated UUIDs for new entities
Repository:
- Reads from local storage first
- Writes to local storage immediately
- Queues remote sync operations
- Handles sync failures gracefully
Sync:
- Sync queue persists pending operations
- Sync triggers on connectivity restore
- Conflict resolution strategy implemented
- Sync status exposed to UI
Verification:
- Works in airplane mode
- Data persists across app restarts
- Sync completes when online
- Conflicts resolved correctly
Related Skills
/network-connectivity- Connectivity monitoring and offline banner/data- Base repository patterns, caching, error handling/push-notifications- Push-based sync triggers/analytics- Track sync events and failures
Common Issues
| Issue | Solution |
| Data not persisting | Ensure database initialized before use (await AppDatabase.init()) |
| Sync queue grows indefinitely | Implement retry limits and age-based pruning |
| Conflicts overwriting local | Use timestamps for LWW, or user prompts for critical data |
| Slow startup on large datasets | Use pagination, lazy-load details on demand |
See: sync-guide.md for detailed troubleshooting.
Next Steps
After running this skill:
- Run
/network-connectivityfor offline banner - Run
/testingfor offline scenario tests - Run
/i18nfor sync status messages - Consider
/push-notificationsfor push-based sync
In this repository27 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- a11ySkill
- account-deletionSkill
- analyticsSkill
- authSkill
- ci-cdSkill
- coreSkill
- dataSkill
- deep-linkingSkill
- designSkill
- domainSkill
- feature-initSkill
- flavorsSkill
- force-updateSkill
- i18nSkill
- in-app-purchasesSkill
- initSkill
- local-authSkill
- network-connectivitySkill
- phone-authSkill
- planSkill
- presentationSkill
- push-notificationsSkill
- releaseSkill
- skill-createSkill
- social-loginSkill
- testingSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

