Mobile Offline Storage

Cross-platform offline-first data management

509 stars

Best use case

Mobile Offline Storage is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Cross-platform offline-first data management

Teams using Mobile Offline Storage should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/offline-storage/SKILL.md --create-dirs "https://raw.githubusercontent.com/a5c-ai/babysitter/main/library/specializations/mobile-development/skills/offline-storage/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/offline-storage/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How Mobile Offline Storage Compares

Feature / AgentMobile Offline StorageStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Cross-platform offline-first data management

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Mobile Offline Storage Skill

## Overview

This skill provides cross-platform offline-first data management capabilities. It enables configuration of WatermelonDB, Realm, MMKV, and other offline storage solutions with sync queue architectures.

## Allowed Tools

- `bash` - Execute package managers and build tools
- `read` - Analyze storage configurations and schemas
- `write` - Generate models and sync logic
- `edit` - Update storage implementations
- `glob` - Search for storage files
- `grep` - Search for patterns

## Capabilities

### WatermelonDB (React Native)

1. **Schema Definition**
   - Define table schemas
   - Configure column types
   - Set up relations
   - Handle migrations

2. **Sync Engine**
   - Implement sync adapters
   - Handle conflict resolution
   - Configure batch operations
   - Manage sync state

### Realm (Cross-Platform)

3. **Object Schemas**
   - Define Realm objects
   - Configure primary keys
   - Set up relationships
   - Handle embedded objects

4. **Realm Sync**
   - Configure Device Sync
   - Handle flexible sync
   - Manage subscriptions
   - Handle conflicts

### MMKV

5. **Key-Value Storage**
   - Configure MMKV instances
   - Handle encryption
   - Implement migrations
   - Manage namespaces

### Sync Architecture

6. **Offline-First Patterns**
   - Design sync queues
   - Handle network state
   - Implement retry logic
   - Manage pending operations

7. **Conflict Resolution**
   - Last-write-wins strategy
   - Merge strategies
   - User resolution UI
   - Audit logging

## Target Processes

- `offline-first-architecture.js` - Offline patterns
- `rest-api-integration.js` - API sync
- `graphql-apollo-integration.js` - GraphQL sync

## Dependencies

- WatermelonDB (React Native)
- Realm SDK
- MMKV
- SQLite

## Usage Examples

### WatermelonDB Schema

```typescript
// database/schema.ts
import { appSchema, tableSchema } from '@nozbe/watermelondb';

export const schema = appSchema({
  version: 1,
  tables: [
    tableSchema({
      name: 'posts',
      columns: [
        { name: 'title', type: 'string' },
        { name: 'body', type: 'string' },
        { name: 'is_published', type: 'boolean' },
        { name: 'author_id', type: 'string', isIndexed: true },
        { name: 'created_at', type: 'number' },
        { name: 'updated_at', type: 'number' },
      ],
    }),
    tableSchema({
      name: 'comments',
      columns: [
        { name: 'body', type: 'string' },
        { name: 'post_id', type: 'string', isIndexed: true },
        { name: 'author_id', type: 'string' },
        { name: 'created_at', type: 'number' },
      ],
    }),
  ],
});
```

### WatermelonDB Model

```typescript
// database/models/Post.ts
import { Model, Q } from '@nozbe/watermelondb';
import { field, date, children, relation } from '@nozbe/watermelondb/decorators';

export class Post extends Model {
  static table = 'posts';

  static associations = {
    comments: { type: 'has_many', foreignKey: 'post_id' },
    author: { type: 'belongs_to', key: 'author_id' },
  };

  @field('title') title!: string;
  @field('body') body!: string;
  @field('is_published') isPublished!: boolean;
  @field('author_id') authorId!: string;
  @date('created_at') createdAt!: Date;
  @date('updated_at') updatedAt!: Date;

  @children('comments') comments!: Query<Comment>;
  @relation('users', 'author_id') author!: Relation<User>;
}
```

### Sync Queue Implementation

```typescript
// sync/SyncQueue.ts
interface SyncOperation {
  id: string;
  type: 'create' | 'update' | 'delete';
  entity: string;
  payload: any;
  timestamp: number;
  retryCount: number;
}

class SyncQueue {
  private queue: SyncOperation[] = [];
  private isProcessing = false;

  async enqueue(operation: Omit<SyncOperation, 'id' | 'timestamp' | 'retryCount'>) {
    const op: SyncOperation = {
      ...operation,
      id: uuid(),
      timestamp: Date.now(),
      retryCount: 0,
    };
    this.queue.push(op);
    await this.persistQueue();
    this.processQueue();
  }

  private async processQueue() {
    if (this.isProcessing || this.queue.length === 0) return;

    const isOnline = await NetInfo.fetch().then(state => state.isConnected);
    if (!isOnline) return;

    this.isProcessing = true;

    while (this.queue.length > 0) {
      const operation = this.queue[0];
      try {
        await this.executeOperation(operation);
        this.queue.shift();
        await this.persistQueue();
      } catch (error) {
        operation.retryCount++;
        if (operation.retryCount >= 3) {
          this.queue.shift();
          await this.logFailedOperation(operation, error);
        }
        break;
      }
    }

    this.isProcessing = false;
  }

  private async executeOperation(operation: SyncOperation) {
    switch (operation.type) {
      case 'create':
        return api.post(`/${operation.entity}`, operation.payload);
      case 'update':
        return api.put(`/${operation.entity}/${operation.payload.id}`, operation.payload);
      case 'delete':
        return api.delete(`/${operation.entity}/${operation.payload.id}`);
    }
  }
}
```

## Quality Gates

- Data integrity verified on sync
- Conflict resolution tested
- Offline functionality verified
- Migration tests passing

## Related Skills

- `ios-persistence` - iOS Core Data
- `android-room` - Android Room
- `graphql-mobile` - GraphQL offline

## Version History

- 1.0.0 - Initial release

Related Skills

Appium Mobile Testing

509
from a5c-ai/babysitter

Appium mobile testing framework for iOS and Android automation

Mobile Testing Frameworks

509
from a5c-ai/babysitter

Comprehensive mobile testing framework expertise

mobile-security

509
from a5c-ai/babysitter

Mobile application security skill for implementing OWASP MASVS compliance, secure storage, certificate pinning, biometric authentication, and security hardening across iOS and Android platforms.

Mobile Performance Profiling

509
from a5c-ai/babysitter

Mobile app performance analysis and optimization

Mobile Analytics

509
from a5c-ai/babysitter

Mobile app analytics and crash reporting integration

GraphQL Mobile

509
from a5c-ai/babysitter

GraphQL client integration for mobile applications

Firebase Mobile

509
from a5c-ai/babysitter

Firebase backend services integration for mobile apps

Fastlane/Mobile CI-CD

509
from a5c-ai/babysitter

Automated mobile build, test, and deployment with Fastlane

mobile-optimization

509
from a5c-ai/babysitter

Mobile GPU optimization skill for thermal management.

mobile-ads

509
from a5c-ai/babysitter

Ad mediation skill for rewarded video.

process-builder

509
from a5c-ai/babysitter

Scaffold new babysitter process definitions following SDK patterns, proper structure, and best practices. Guides the 3-phase workflow from research to implementation.

Workflow & Productivity

babysitter

509
from a5c-ai/babysitter

Orchestrate via @babysitter. Use this skill when asked to babysit a run, orchestrate a process or whenever it is called explicitly. (babysit, babysitter, orchestrate, orchestrate a run, workflow, etc.)