Offline First Development 标志

Offline First Development

社区
Omar-Obando
offline-first-development

Use when implementing offline-first applications, managing local storage, implementing data synchronization, handling conflicts, and creating offline UI patterns. Includes IndexedDB, localStorage, service workers, and offline state management. Based on offline-first development best practices.

Add to TypingMind

概览

发布者Omar-Obando
代码仓库qwen-orchestrator
技能名称offline-first-development
星标数
53
复刻数
13
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 Omar-Obando 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Offline First Development AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/offline-first-development
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Omar-Obando/qwen-orchestrator.git /tmp/qwen-orchestrator
mkdir -p .claude/skills
cp -r /tmp/qwen-orchestrator/skills/offline-first-development .claude/skills/offline-first-development
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Offline First Development,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Offline First Development。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Offline First Development 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Offline-First Development Skill — Mobile Engineer

Overview

This skill provides comprehensive guidance for implementing offline-first applications. It covers local storage management, data synchronization, conflict resolution, offline UI patterns, and offline state management following offline-first development best practices.

When to Use

Use this skill when:

  • Implementing offline-first applications
  • Managing local storage (IndexedDB, localStorage)
  • Implementing data synchronization
  • Handling synchronization conflicts
  • Creating offline UI patterns
  • Implementing service workers
  • Managing offline state
  • Creating offline data models
  • Implementing offline-first APIs
  • Handling network failures
  • Creating offline indicators
  • Implementing queue for offline actions
  • Managing offline data validation
  • Creating offline sync strategies
  • Implementing conflict resolution
  • Managing offline data consistency
  • Creating offline-first UX patterns
  • Implementing background sync
  • Managing offline data caching
  • Creating offline-first error handling
  • Implementing offline data encryption
  • Managing offline storage limits
  • Creating offline-first testing

Do NOT use this skill when:

  • Writing application business logic (use domain-driven skill)
  • Designing database schemas (use database-design skill)
  • Writing API endpoint specifications (use api-design skill)
  • Performing security audits (use security-auditor skill)
  • Writing SQL queries (use sql-best-practices skill)
  • Designing multi-page website layouts (use design-system skill)
  • Analyzing deployment configurations (use deployment skill)
  • Writing documentation (use documentation-best-practices skill)

Offline-First Principles

Core Principles

┌─────────────────────────────────────────────────────────────┐
│              Offline-First Principles                       │
├─────────────────────────────────────────────────────────────┤
│  1. Always Available:                                       │
│     - Application works offline                             │
│     - Core functionality available                          │
│     - Graceful degradation                                  │
│                                                              │
│  2. Data Persistence:                                       │
│     - Data stored locally                                   │
│     - Data survives app restart                             │
│     - Data survives device restart                          │
│                                                              │
│  3. Automatic Sync:                                         │
│     - Data syncs when online                                │
│     - Sync happens automatically                            │
│     - Sync is transparent to user                           │
│                                                              │
│  4. Conflict Resolution:                                    │
│     - Handle offline changes                                │
│     - Resolve conflicts gracefully                          │
│     - User awareness of conflicts                           │
│                                                              │
│  5. Offline UI:                                             │
│     - Clear offline status                                  │
│     - Offline actions queue                                 │
│     - Offline indicators                                    │
└─────────────────────────────────────────────────────────────┘

Local Storage Options

┌─────────────────────────────────────────────────────────────┐
│              Local Storage Options                          │
├─────────────────────────────────────────────────────────────┤
│  localStorage:                                              │
│  - Key-value storage                                        │
│  - Synchronous API                                          │
│  - Limited to ~5MB                                          │
│  - String values only                                       │
│                                                              │
│  sessionStorage:                                            │
│  - Session-scoped storage                                   │
│  - Synchronous API                                          │
│  - Limited to ~5MB                                          │
│  - Cleared on session end                                   │
│                                                              │
│  IndexedDB:                                                 │
│  - Database-style storage                                   │
│  - Asynchronous API                                         │
│  - Large storage capacity                                   │
│  - Supports complex data structures                         │
│                                                              │
│  Cache API:                                                 │
│  - HTTP response caching                                    │
│  - Service worker integration                               │
│  - Query-based retrieval                                    │
│  - Automatic cache management                               │
│                                                              │
│  Web SQL (deprecated):                                      │
│  - SQL database                                             │
│  - Asynchronous API                                         │
│  - Deprecated in favor of IndexedDB                         │
└─────────────────────────────────────────────────────────────┘

Offline Sync Strategies

Sync Patterns

┌─────────────────────────────────────────────────────────────┐
│              Offline Sync Strategies                        │
├─────────────────────────────────────────────────────────────┤
│  Last Write Wins:                                           │
│  - Simple conflict resolution                               │
│  - Timestamp-based                                          │
│  - May lose data                                            │
│  - Good for: Simple data, low conflict                     │
│                                                              │
│  Operational Transform:                                     │
│  - Collaborative editing                                    │
│  - Transform operations                                    │
│  - Complex implementation                                   │
│  - Good for: Real-time collaboration                       │
│                                                              │
│  CRDT (Conflict-free Replicated Data Types):                │
│  - Automatic conflict resolution                            │
│  - No coordination needed                                   │
│  - Complex data structures                                  │
│  - Good for: Distributed systems                           │
│                                                              │
│  Merge Conflicts:                                           │
│  - User-assisted resolution                                 │
│  - Conflict detection                                       │
│  - User interface for resolution                            │
│  - Good for: User-editable data                            │
│                                                              │
│  Queue-based Sync:                                          │
│  - Queue offline actions                                    │
│  - Process sequentially                                     │
│  - Track sync status                                        │
│  - Good for: Action-based sync                             │
└─────────────────────────────────────────────────────────────┘

Sync Implementation

javascript
// ✅ Good: Offline sync with IndexedDB
class OfflineSync {
  constructor(db, apiClient) {
    this.db = db;
    this.apiClient = apiClient;
  }

  async sync() {
    // Get pending changes
    const pendingChanges = await this.db.getAll('pendingChanges');

    for (const change of pendingChanges) {
      try {
        // Attempt to sync
        const result = await this.apiClient.sync(change);

        // Mark as synced
        await this.db.delete('pendingChanges', change.id);

        // Update local cache
        await this.db.put('cache', result);
      } catch (error) {
        // Handle error
        console.error('Sync failed:', error);

        // Retry later
        if (this.shouldRetry(error)) {
          await this.db.update('pendingChanges', change.id, {
            retryCount: (change.retryCount || 0) + 1,
          });
        }
      }
    }
  }

  async queueChange(record, action) {
    // Queue change for later sync
    await this.db.put('pendingChanges', {
      record,
      action,
      timestamp: Date.now(),
      retryCount: 0,
    });
  }
}

Offline UI Patterns

Offline Indicators

html
<!-- ✅ Good: Offline indicator -->
<div class="offline-indicator" id="offlineIndicator">
  <span class="offline-icon">wifi_off</span>
  <span class="offline-text">You're offline</span>
</div>

<script>
  // Monitor network status
  window.addEventListener('online', () => {
    document.getElementById('offlineIndicator').style.display = 'none';
    // Trigger sync
    offlineSync.sync();
  });

  window.addEventListener('offline', () => {
    document.getElementById('offlineIndicator').style.display = 'block';
  });
</script>

Offline Actions Queue

html
<!-- ✅ Good: Offline action queue -->
<div class="action-queue" id="actionQueue">
  <h3>Pending Actions</h3>
  <ul id="queueList"></ul>
</div>

<script>
  // Display pending actions
  function displayQueue() {
    const queueList = document.getElementById('queueList');
    queueList.innerHTML = '';

    offlineSync.getPendingActions().forEach((action) => {
      const li = document.createElement('li');
      li.textContent = `${action.type}: ${action.description}`;
      queueList.appendChild(li);
    });
  }
</script>

Service Workers

Service Worker Registration

javascript
// ✅ Good: Service worker registration
if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker
      .register('/sw.js')
      .then((registration) => {
        console.log('SW registered:', registration);
      })
      .catch((error) => {
        console.log('SW registration failed:', error);
      });
  });
}

Service Worker Cache Strategy

javascript
// ✅ Good: Service worker cache strategy
self.addEventListener('install', (event) => {
  event.waitUntil(
    caches.open('app-cache').then((cache) => {
      return cache.addAll([
        '/',
        '/styles/main.css',
        '/scripts/app.js',
        '/images/logo.png',
      ]);
    })
  );
});

self.addEventListener('fetch', (event) => {
  event.respondWith(
    caches.match(event.request).then((cachedResponse) => {
      if (cachedResponse) {
        return cachedResponse;
      }

      return fetch(event.request).then((response) => {
        // Cache the response
        const responseClone = response.clone();
        caches.open('app-cache').then((cache) => {
          cache.put(event.request, responseClone);
        });

        return response;
      });
    })
  );
});

Real-World Impact

Before this skill:

  • Applications fail when offline
  • No data persistence
  • Poor user experience
  • Data loss
  • Manual sync required

After this skill:

  • Applications work offline
  • Automatic data persistence
  • Excellent user experience
  • No data loss
  • Automatic sync

Cross-References

  • mobile-performance - For mobile optimization
  • testing-strategy - For offline testing
  • api-design - For offline-first APIs

References

常见问题

Offline First Development AI 技能有什么作用?

Use when implementing offline-first applications, managing local storage, implementing data synchronization, handling conflicts, and creating offline UI patterns. Includes IndexedDB, localStorage, service workers, and offline state management. Based on offline-first development best practices.

为什么在 TypingMind 中使用 Offline First Development?

因为您只需安装一次,就能搭配任何模型使用。Offline First Development 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Offline First Development?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/offline-first-development。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Offline First Development?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Offline First Development 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Offline First Development 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Offline First Development AI 技能免费吗?

是的。Omar-Obando 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇