agentleFS
launch52-ailaunch52-ai/flutter-template/.claude/skills/offline/SKILL.md

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
  1. Very specific:

    Simple in-memory caching: - Use /data caching patterns instead

    line 21
  2. Very specific:

    Network connectivity detection: - Use /network-connectivity instead

    line 22
  3. Very specific:

    Error handling for failed requests: - Use /data NetworkFailure types

    line 23
  4. Very specific:

    Add dependencies to pubspec.yaml

    line 85
  5. Distinctive:

    Create local database models/tables

    line 86
  6. Distinctive:

    Add sync status tracking to models

    line 93
  7. Distinctive:

    Create sync queue for pending operations

    line 94
  8. Distinctive:

    Add background sync via WorkManager (optional)

    line 96
  9. Distinctive:

    Add write-through or write-behind patterns

    line 103
  10. Distinctive:

    After running this skill:

    line 191
  11. Very specific:

    Run /network-connectivity for offline banner

    line 192
  12. Very specific:

    Run /testing for offline scenario tests

    line 193
  13. Very specific:

    Run /i18n for sync status messages

    line 194
  14. Very specific:

    Consider /push-notifications for push-based sync

    line 195

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 /data caching patterns instead
  • Network connectivity detection - Use /network-connectivity instead
  • Error handling for failed requests - Use /data NetworkFailure types

Questions to Ask

  1. Offline mode: Fully offline-first or online-first with offline fallback?
  2. Data complexity: Simple key-value or structured relational data?
  3. Sync strategy: Periodic sync, on-demand, or push-based?
  4. Conflict resolution: Last-write-wins, server-wins, or custom merge?
  5. Data sensitivity: Does local data need encryption?

Quick Reference

Offline Patterns

PatternUse WhenLocal DBSync
Fully OfflineNotes, journals, todo appsPrimaryOptional upload
Offline-FirstField apps, travel appsPrimaryBackground sync
Online-First + FallbackE-commerce, social appsCacheOn reconnect
Cache-OnlyRead-heavy feedsTTL cacheRefresh on pull

Storage Options

StorageBest ForEncryptionPerformance
Drift (SQLite)Relational data, complex queriesAES-256 via SQLCipherFast
HiveKey-value, settings, small objectsBuilt-in AES-256Very fast
IsarLarge datasets, full-text searchLimitedFastest
SharedPreferencesFlags, simple settingsNoneFast
SecureStorageTokens, PIIPlatform keychainSlower

Sync Strategies

StrategyTriggerBest For
PeriodicTimer (5-15 min)Background updates
On-DemandUser pull-to-refreshUser-controlled sync
On-ReconnectConnectivity changeOffline queue flush
Push-BasedFCM/WebSocketReal-time apps
Delta SyncTimestamp-basedLarge datasets

Conflict Resolution

StrategyHow It WorksBest For
Last-Write-Wins (LWW)Latest timestamp winsSimple apps, non-critical data
Server-WinsServer always authoritativeMulti-user shared data
Client-WinsLocal changes preservedSingle-user apps
Custom MergeField-level merge logicComplex business rules
User PromptAsk user to resolveImportant conflicts

Workflow

Phase 1: Analyze Requirements

  1. Determine offline pattern (see Quick Reference)
  2. Identify data that needs offline access
  3. Choose storage solution based on data complexity
  4. Define sync strategy and conflict resolution

Phase 2: Setup Local Storage

  1. Add dependencies to pubspec.yaml
  2. Create local database models/tables
  3. Implement local data source

See: storage-guide.md for detailed setup

Phase 3: Implement Sync Layer

  1. Add sync status tracking to models
  2. Create sync queue for pending operations
  3. Implement sync service with conflict resolution
  4. Add background sync via WorkManager (optional)

See: sync-guide.md for sync patterns

Phase 4: Update Repository

  1. Modify repository to read local-first
  2. Add write-through or write-behind patterns
  3. Handle sync status in domain entities
  4. 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

FileContent
architecture-guide.mdOffline architecture patterns and decisions
storage-guide.mdLocal storage setup (Drift, Hive)
sync-guide.mdSync strategies and conflict resolution

Reference Files

See: reference/ for complete implementations:

  • reference/models/ - SyncStatus enum, SyncOperation, OfflineEntity mixin
  • reference/local_storage/ - Drift database, Hive local source
  • reference/sync/ - SyncQueue, SyncService, ConflictResolver
  • reference/repositories/ - Offline-first and cache-first patterns
  • reference/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 syncStatus field
  • 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

IssueSolution
Data not persistingEnsure database initialized before use (await AppDatabase.init())
Sync queue grows indefinitelyImplement retry limits and age-based pruning
Conflicts overwriting localUse timestamps for LWW, or user prompts for critical data
Slow startup on large datasetsUse pagination, lazy-load details on demand

See: sync-guide.md for detailed troubleshooting.

Next Steps

After running this skill:

  1. Run /network-connectivity for offline banner
  2. Run /testing for offline scenario tests
  3. Run /i18n for sync status messages
  4. Consider /push-notifications for push-based sync

Download now (ZIP)

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.