craft-coder/mobile/offline-first/SKILL.md
Local storage, data sync, and conflict resolution for offline-capable apps.
npx skillsauth add timequity/plugins offline-firstInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| Option | Use Case | |--------|----------| | AsyncStorage | Simple key-value | | MMKV | Fast key-value | | SQLite | Complex queries | | WatermelonDB | Large datasets, sync |
import { MMKV } from 'react-native-mmkv';
const storage = new MMKV();
// Store
storage.set('user', JSON.stringify(user));
storage.set('token', 'abc123');
// Retrieve
const user = JSON.parse(storage.getString('user') || '{}');
const token = storage.getString('token');
// Delete
storage.delete('token');
async function updateItem(id: string, data: Partial<Item>) {
// 1. Update local immediately
await localDb.update(id, { ...data, _synced: false });
// 2. Update UI
queryClient.setQueryData(['item', id], (old) => ({
...old,
...data,
}));
// 3. Sync to server
try {
await api.updateItem(id, data);
await localDb.update(id, { _synced: true });
} catch (error) {
// Queue for retry
await syncQueue.add({ type: 'update', id, data });
}
}
import NetInfo from '@react-native-community/netinfo';
NetInfo.addEventListener((state) => {
if (state.isConnected) {
syncQueue.processAll();
}
});
// Last-write-wins
if (serverItem.updatedAt > localItem.updatedAt) {
await localDb.update(id, serverItem);
} else {
await api.updateItem(id, localItem);
}
// Or: Manual resolution
if (hasConflict) {
showConflictResolver(serverItem, localItem);
}
function useNetworkStatus() {
const [isOnline, setIsOnline] = useState(true);
useEffect(() => {
return NetInfo.addEventListener((state) => {
setIsOnline(state.isConnected ?? false);
});
}, []);
return isOnline;
}
tools
Backup strategies, disaster recovery planning, and business continuity.
devops
Cloud cost management, rightsizing, and FinOps practices.
testing
CI/CD pipeline design with GitHub Actions, GitLab CI, and best practices.
development
Validate idea and create detailed PRD. Saves docs/PRD.md to project. Use when: user describes an app idea, wants to create something new. Triggers: "I want to build", "create app", "make website", "build MVP", "хочу создать", "сделать приложение".