areas/software/mobile/skills/state-sync/SKILL.md
# Skill: Offline State Sync ## When to load When implementing offline-first features, handling optimistic updates, or building sync queues. ## Optimistic Update Pattern ```typescript const mutation = useMutation({ mutationFn: api.createOrder, onMutate: async (newOrder) => { await queryClient.cancelQueries({ queryKey: ['orders'] }); const previousOrders = queryClient.getQueryData<Order[]>(['orders']); queryClient.setQueryData<Order[]>(['orders'], (old = []) => [ { ...new
npx skillsauth add sawrus/agent-guides areas/software/mobile/skills/state-syncInstall 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.
When implementing offline-first features, handling optimistic updates, or building sync queues.
const mutation = useMutation({
mutationFn: api.createOrder,
onMutate: async (newOrder) => {
await queryClient.cancelQueries({ queryKey: ['orders'] });
const previousOrders = queryClient.getQueryData<Order[]>(['orders']);
queryClient.setQueryData<Order[]>(['orders'], (old = []) => [
{ ...newOrder, id: `temp_${Date.now()}`, _isOptimistic: true }, ...old
]);
return { previousOrders };
},
onError: (_, __, context) => {
queryClient.setQueryData(['orders'], context?.previousOrders);
offlineQueue.enqueue({ type: 'CREATE_ORDER', payload: newOrder });
},
});
import { MMKV } from 'react-native-mmkv';
const storage = new MMKV({ id: 'offline-queue' });
export const offlineQueue = {
enqueue(action) {
const queue = this.getAll();
storage.set('queue', JSON.stringify([...queue, { ...action, id: `action_${Date.now()}`, retryCount: 0 }]));
},
getAll(): QueuedAction[] {
return JSON.parse(storage.getString('queue') ?? '[]');
},
async flush() {
for (const action of this.getAll()) {
try { await dispatch(action); this.remove(action.id); }
catch { this.incrementRetry(action.id); }
}
},
};
testing
QA Expert for writing E2E tests, test scenarios, test plans, and ensuring test coverage quality.
development
Expert UI/UX design intelligence for creating distinctive, high-craft, and mobile-first interfaces. Focuses on premium aesthetics, touch-first ergonomics, and Flutter performance.
development
Code Review Expert for static analysis, security auditing, architecture review, and ensuring code quality standards.
development
Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep watching open PRs so fresh review feedback is surfaced promptly. Use when the user asks Codex to monitor a PR, watch CI, handle review comments, or keep an eye on failures and feedback on an open PR.