react-query-data-patterns

Enforce a 2-layer API module pattern for React Query server-state management.

Updated Feb 17, 2026
One-click install
npx skills add https://github.com/aidanaden/sg-food-guide --skill react-query-data-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-query-data-patterns
Source: https://github.com/aidanaden/sg-food-guide/tree/main/.agents/skills/react-query-data-patterns
Command: npx skills add https://github.com/aidanaden/sg-food-guide --skill react-query-data-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Optimizes server-state management in admin-ui by enforcing a structured, 2-layer API module pattern for data fetching and mutations.

Core Features & Use Cases

  • Provides a 2-layer API module pattern (client.ts, types.ts, queries.ts) to centralize HTTP calls, types, and query factories.
  • Enforces service-scoped query keys, skipToken handling, and robust cache invalidation to simplify data consistency across admin-ui components.
  • Supports clear mutation workflows and error handling through the query client and factories.

Quick Start

Create a new service API module under api/ and wire up its client, types, and queries to start using the React Query pattern in admin-ui components.

Frequently Asked Questions about react-query-data-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure React Query API modules for admin UI data fetching?

Use a 2-layer API module pattern with client.ts, types.ts, and queries.ts to centralize HTTP calls, types, and query factories for React Query. This enforces consistent cache handling and mutation workflows across admin UI features.

What's the best way to manage service-scoped query keys in React Query?

Enforce a structured API module pattern with typed query factories to manage service-scoped query keys in React Query. This standardizes cache handling and ensures reliable cache invalidation across admin UI components.

How do I handle cache invalidation after mutations with React Query?

Use typed query factories within dedicated service API modules to handle cache invalidation after React Query mutations. This approach provides robust error handling and reliable data consistency across admin UI components.

Why does my React Query skipToken handling break in admin UI components?

React Query skipToken handling breaks when API modules lack a structured 2-layer pattern for conditional data fetching. Enforcing dedicated queries.ts files with typed query factories standardizes skipToken behavior and prevents inconsistent cache states.

Can I use this React Query pattern for existing admin-ui service modules?

Yes, you can apply this React Query pattern to existing admin-ui service modules by refactoring them into the 2-layer client.ts, types.ts, and queries.ts structure. This centralizes HTTP calls and standardizes mutation workflows without changing core logic.