web-data-layer

Generates a React data layer separating TanStack Query server-state from Zustand client-state with Zod contracts.

1|Updated Jul 7, 2026
One-click install
npx skills add https://github.com/codjeremias-cell/Orquestrador-fable --skill web-data-layer-codjeremias-cell
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: web-data-layer
Source: https://github.com/codjeremias-cell/Orquestrador-fable/tree/main/skills/web-data-layer
Command: npx skills add https://github.com/codjeremias-cell/Orquestrador-fable --skill web-data-layer-codjeremias-cell

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-query, zod, zustand, react-hook-form.

What problem does it solve? Frontend code often mixes server data with UI state, causing stale caches, lost filters, and silent breakage when the backend API changes. This Skill builds a typed data layer where TanStack Query owns server-state, Zustand or Jotai owns client-state, and a single Zod schema acts as the API contract, form schema, and type source. ## Core Features & Use Cases - Server-state vs client-state separation: TanStack Query handles cache, refetch, and invalidation; Zustand/Jotai stores only UI state like filters, modals, and wizard steps. - Single Zod schema per resource: one schema mirrors the backend DTO, validates API responses via .parse(), feeds zodResolver in forms, and generates types with z.infer. - Contract enforcement: responses outside the expected shape become explicit error states instead of silent undefined values, protecting the frontend when the Spring Boot backend changes. - Use Case: Given a Spring Boot ClienteDTO with id, nome, email, and ativo, the Skill generates cliente.schema.ts, useClientes and useCriarCliente hooks with key-based invalidation, and an optional client-state store. ## Quick Start Ask the AI to create the data layer for a resource, for example: "Create the data layer for the customers endpoint using TanStack Query with a Zod schema that mirrors the backend DTO."

Frequently Asked Questions about web-data-layer

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

FAQPage Schema
How do I separate server-state from client-state in React?▼

Use TanStack Query for server-state such as API data, cache, loading, and errors, and Zustand or Jotai only for client-state like filters, modals, and theme. Never duplicate API responses in a global store, since that creates synchronization bugs.

How to validate API responses with Zod and TanStack Query?▼

Define a Zod schema mirroring the backend DTO and call schema.parse inside the queryFn before returning data. Invalid responses become handled error states instead of silent undefined values, and z.infer derives the TypeScript types from the same schema.

Zustand vs TanStack Query for global state management?▼

They solve different problems: TanStack Query manages server-state with caching, refetching, and invalidation, while Zustand manages local UI state. Use both together rather than forcing API data into a Zustand store.

Does this data layer pattern work with non-React frameworks?▼

The generated hooks, zodResolver integration, and store patterns target React with Vite. Non-React stacks require a different track, since TanStack Query APIs and react-hook-form integration are React-specific.

Why does my frontend break silently when the backend API changes?▼

Fetching without validating the response lets shape mismatches surface as undefined values deep in the UI. Parsing every response against a Zod schema at the query boundary converts contract violations into explicit, handled error states.