nghyane/vstep/mobile-data-patterns

Claude Code and agent skill by nghyane/vstep

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

TanStack Query + Zustand + API integration patterns. Server state, mutations, local stores, error handling, token refresh. Load when working with data layer.

Install

npx vskill@latest install nghyane/vstep/mobile-data-patterns

SKILL.md

Mobile Data Patterns

QueryClient Setup

ts
// src/lib/query-client.ts
const queryClient = new QueryClient({
defaultOptions: {
queries: { staleTime: 1000 * 60 * 5, retry: false },
mutations: { onError: globalErrorHandler },
},
});
queryClient.getQueryCache().config.onError = globalErrorHandler;
queryClient.getMutationCache().config.onError = globalErrorHandler;
  • Global error handler: 401 → logout, else → toast/Alert
  • staleTime: 5 minutes — reasonable for mobile
  • retry: false — fail fast on mobile, user can retry manually

API Client

ts
// src/lib/api.ts
import { getAccessToken } from "./auth";
const API_URL = process.env.EXPO_PUBLIC_API_URL ?? "https://api.vstepgo.com";
export const api = {
get: <T>(path: string) => request<T>("GET", path),
post: <T>(path: string, body?: unknown) => request<T>("POST", path, body),
put: <T>(path: string, body?: unknown) => request<T>("PUT", path, body),
patch: <T>(path: string, body?: unknown) => request<T>("PATCH", path, body),
delete: <T>(path: string) => request<T>("DELETE", path),
};
  • Key transforms: Laravel snake_case ↔ React Native camelCase
  • Auto-unwrap { data: T } response wrapper
  • Auto-refresh 401 tokens via tryRefresh()

Query Patterns

ts
// src/hooks/use-exams.ts
export function useExams() {
return useQuery({
queryKey: ["exams"],
queryFn: () => api.get<Exam[]>("api/v1/exams"),
});
}
  • queryKey format: ["feature", id?] — flat arrays
  • select option for derived data
  • enabled flag when dependency not ready

Mutation Patterns

ts
// src/hooks/use-auth.ts
export function useLogin() {
return useMutation({
mutationFn: ({ email, password }) => loginApi(email, password),
onSuccess: (data) => {
// side effects here
},
onError: (error) => {
// toast/Alert
},
});
}
  • All API writes through useMutation — global onError catches 401
  • Components call mutation.mutate() — no try/catch
  • onSuccess for side effects (navigation, state update)

Zustand Local Stores

ts
// src/features/coin/coin-store.ts
import { create } from "zustand";
interface CoinStore {
amount: number;
setAmount: (n: number) => void;
addCoins: (n: number) => void;
}
export const useCoinStore = create<CoinStore>((set) => ({
amount: 0,
setAmount: (n) => set({ amount: n }),
addCoins: (n) => set((s) => ({ amount: s.amount + n })),
}));
  • Use Zustand for: coin, streak, notification (local state only)
  • Sync with backend on app launch via loadXxx() functions
  • No async in store — async in loadXxx() functions in api.ts

Auth Flow

ts
// Token storage: expo-secure-store (not AsyncStorage)
await SecureStore.setItemAsync("vstep_access_token", token);
await SecureStore.setItemAsync("vstep_user", JSON.stringify(user));
  • Login → save tokens → update auth state
  • App launch → restore from SecureStore → refresh token
  • 401 → tryRefresh() → if fail → logout → redirect login
  • Logout → clear SecureStore → clear QueryClient cache

Error Handling

  • Never try/catch in components for toast
  • Global QueryClient onError handles 401 → logout
  • Use React Native Alert.alert() for user-facing errors
  • Log errors for debugging, but don't expose raw errors to UI

Data Rules

  • Backend response: { data: T } → ApiResponse<T>
  • Null handling: {value && <Component />} — don't hide null with ?? fallback
  • Types defined in src/types/api.ts — don't inline .json<{...}>

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
3
Repository forks
1
7-day trend score
0

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/nghyane/vstep/mobile-data-patterns/badge)](https://verified-skill.com/skills/nghyane/vstep/mobile-data-patterns)

Something wrong with this skill or its page? Tell us.