web-pwa-offline-first-2b8e5a — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited web-pwa-offline-first-2b8e5a (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Quick Guide: Build applications that work primarily with local data, treating network connectivity as an enhancement. Use IndexedDB (via Dexie.js 4.x or idb 8.x) as the single source of truth. Implement sync queues for reliable background synchronization. Use optimistic UI patterns for instant feedback. Note: Background Sync API is experimental with limited browser support (Chrome/Edge only).
<critical_requirements>
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering, import type, named constants)(You MUST use IndexedDB (via wrapper library) as the single source of truth for all offline data)
(You MUST implement sync metadata (\_syncStatus, \_lastModified, \_localVersion) on ALL entities that need synchronization)
(You MUST queue mutations during offline and process them when connectivity returns)
(You MUST use soft deletes (tombstones) for deletions to enable proper sync across devices)
(You MUST implement exponential backoff with jitter for ALL sync retry logic)
(You MUST NOT await non-IndexedDB operations mid-transaction - transactions auto-close when control returns to event loop)
</critical_requirements>
Auto-detection: offline-first, IndexedDB, Dexie, idb, sync queue, local-first, offline storage, background sync, optimistic UI offline, conflict resolution, CRDT, last-write-wins
When to use:
When NOT to use:
Storage Considerations:
Detailed Resources:
<philosophy>
Offline-first is a design philosophy where applications are built to work primarily with local data, treating network connectivity as an enhancement rather than a requirement.
Core Principles:
The Offline-First Data Flow:
User Action
|
Local Database (IndexedDB) <-- Single Source of Truth
|
UI Updates Immediately (Optimistic)
|
Sync Queue (Background)
|
Server (When Online)
|
Conflict Resolution (If Needed)
|
Local Database Updated</philosophy>
<patterns>
Every entity that needs synchronization must include metadata for tracking sync state. This is the foundational pattern - all other patterns depend on it.
interface SyncableEntity {
id: string;
_syncStatus: "synced" | "pending" | "conflicted";
_lastModified: number;
_serverTimestamp?: number;
_localVersion: string;
_serverVersion?: string;
_deletedAt?: number; // Soft delete tombstone
}Why this matters: Without sync metadata, you cannot track what needs syncing, detect conflicts, or implement soft deletes. See examples/core.md Pattern 1 for full implementation with factory functions.
Use a repository as the single access point for all data operations, encapsulating local storage and sync queue logic. All reads come from local DB, all writes save locally first then queue for sync.
interface DataRepository<T extends SyncableEntity> {
get(id: string): Promise<T | null>;
getAll(): Promise<T[]>;
save(item: T): Promise<void>; // Local write + queue sync
delete(id: string): Promise<void>; // Soft delete + queue sync
getPendingCount(): Promise<number>;
}Why this matters: Encapsulates the local-first write pattern (save locally, queue for sync) so consumers don't need to manage both operations. See examples/core.md Pattern 2 for full implementation.
Queue operations when offline, process reliably with exponential backoff when connectivity returns.
const MAX_RETRY_ATTEMPTS = 5;
const INITIAL_BACKOFF_MS = 1000;
const MAX_BACKOFF_MS = 30000;
function calculateBackoff(attempt: number): number {
const exponentialDelay = Math.min(
INITIAL_BACKOFF_MS * Math.pow(2, attempt),
MAX_BACKOFF_MS,
);
const jitter = exponentialDelay * 0.5 * (Math.random() * 2 - 1);
return Math.floor(exponentialDelay + jitter);
}Why this matters: Without retry logic, transient network failures cause permanent data loss. Jitter prevents thundering herd when many clients reconnect simultaneously. See examples/core.md Pattern 3 for full queue implementation.
Don't rely solely on navigator.onLine (returns true behind captive portals, dead WiFi). Verify with actual health check requests.
async function checkConnectivity(): Promise<boolean> {
if (!navigator.onLine) return false;
try {
const response = await fetch("/api/health", {
method: "HEAD",
cache: "no-store",
});
return response.ok;
} catch {
return false;
}
}Why this matters: navigator.onLine only checks for a network interface, not actual internet connectivity. See examples/core.md Pattern 4 for full status manager with slow connection detection.
Update UI immediately, store previous value for rollback if sync fails. Return a rollback function from each optimistic update.
See examples/core.md Pattern 5 for full implementation with rollback support.
Fetch from network when online, fall back to cache when offline. Return source metadata ("network" | "cache") so UI can indicate data freshness.
See examples/core.md Pattern 6 for full implementation with timeout and cache fallback.
Three strategies ordered by complexity:
For collaborative text editing, use a CRDT library (separate concern from this skill).
</patterns>
<red_flags>
High Priority:
navigator.onLine alone - verify with actual network requestfetch() or setTimeout() inside an IndexedDB transaction - transaction auto-closesMedium Priority:
Gotchas & Edge Cases:
navigator.storage.persist() and encourage home screen installnavigator.storage.estimate() requires HTTPS; returns { usage: 0, quota: 0 } in unsecured contextsonline event listener as fallback.where("[userId+completed]").equals([userId, 1]) (1 = true)useLiveQuery returns undefined while loading, not null - check with === undefinedBroadcastChannel for coordination (see examples/indexeddb.md Pattern 16)</red_flags>
<critical_reminders>
All code must follow project conventions in CLAUDE.md
(You MUST use IndexedDB (via wrapper library) as the single source of truth for all offline data)
(You MUST implement sync metadata (\_syncStatus, \_lastModified, \_localVersion) on ALL entities that need synchronization)
(You MUST queue mutations during offline and process them when connectivity returns)
(You MUST use soft deletes (tombstones) for deletions to enable proper sync across devices)
(You MUST implement exponential backoff with jitter for ALL sync retry logic)
(You MUST NOT await non-IndexedDB operations mid-transaction - transactions auto-close when control returns to event loop)
Failure to follow these rules will result in data loss, sync conflicts, and poor offline user experience.
</critical_reminders>
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.