reactive/data-client / .agents/skills/data-client-react
data-client-react
UnverifiedRead, change and render async and shared state in React with @data-client/react: any data from an API or other async source, and global state shared across components (it has to persist somewhere, which makes it async). Use it for loading and error states, mutations and forms, filtered or derived views, and debugging data that looks wrong or stale on screen. Use it in place of fetch in useEffect, or app-wide useState and context; its main hooks are useSuspense, useQuery and useController.
evals/evals.json
View on GitHub{
"skill_name": "data-client-react",
"evals": [
{
"id": 1,
"name": "csv-import",
"prompt": "Add an `ImportProducts` component (src/components/ImportProducts.tsx) with a file input. When the user picks a CSV, parse it with `parseProductsCsv(file): Promise<{ id: string; name: string; price: number }[]>` from src/lib/csv.ts and put every row into the Data Client store, so `ProductRow` (which calls `useQuery(Product, { id })`) shows them. There is no server call for this. Product is in src/resources/Product.ts and extends Entity with `id`, `name`, `price`.",
"expected_output": "A component that uses useController() and, after parsing, writes all rows with one ctrl.set([Product], rows) call, with no fetch, endpoint, or setResponse.",
"files": [],
"assertions": [
"All parsed rows are written with a single `ctrl.set([Product], rows)` or `ctrl.set(new schema.Array(Product), rows)` call that passes the rows and no args.",
"The rows are not written by calling `ctrl.set(Product, …)` once per row (no loop, forEach, or map over rows that calls set).",
"No endpoint is defined and `setResponse()` is not called to write the rows.",
"No `as any` or other cast is used to make the `ctrl.set` call typecheck.",
"The controller comes from `useController()`."
]
},
{
"id": 2,
"name": "worker-results",
"prompt": "Our pricing Web Worker posts back `{ type: 'prices', rows: Array<{ id: string; price: number }> }` a few thousand rows at a time. In src/components/PricingWorkerBridge.tsx, listen to the worker in an effect and write the rows into the Data Client store so every `useQuery(Product, { id })` gets the new price. Product (src/resources/Product.ts) is an Entity with id, name, price; rows only have id and price, so name must survive. Keep it fast.",
"expected_output": "An effect that subscribes to worker messages, writes each message's rows with one ctrl.set([Product], rows) call so price merges into stored Products while name is kept, and removes the listener on cleanup.",
"files": [],
"assertions": [
"Each worker message's rows are written with a single `ctrl.set([Product], rows)` or `ctrl.set(new schema.Array(Product), rows)` call that passes the rows and no args.",
"The rows are not written by calling `ctrl.set(Product, …)` once per row (no loop, forEach, or map over rows that calls set).",
"No endpoint is defined and `setResponse()` is not called to batch the writes.",
"No `as any` or other cast is used to make the `ctrl.set` call typecheck.",
"The worker listener is removed in the effect cleanup."
]
},
{
"id": 3,
"name": "cold-deep-link",
"prompt": "Add `TodoTitle` (src/components/TodoTitle.tsx): takes `todoId` and shows that todo's title in the /todos/:id page header. The list page already loads every todo, so read it from the cache without another request. Show 'Not found' when the todo doesn't exist. TodoResource is in src/resources/Todo.ts.",
"expected_output": "Warns that a direct or refreshed /todos/:id visit starts with an empty cache, so a cache miss isn't 'not found'; reads with useSuspense or useDLE and shows 'Not found' from the 404.",
"files": [],
"assertions": [
"The todo is read with `useSuspense` or `useDLE`, not only `useCache`/`useQuery`.",
"'Not found' comes from the request's error, not from `undefined`.",
"No `useEffect` calling `ctrl.fetch`, and no fetched data in `useState`."
]
},
{
"id": 4,
"name": "author-avatars",
"prompt": "Show each post's author avatar in `PostList` (src/components/PostList.tsx). Posts come from `PostResource.getList` and have a `userId`; users come from `UserResource.get`. Simplest is to build a usersById map in PostList and pass it to each `PostRow`, right?",
"expected_output": "Pushes back: PostRow (or an Avatar child) reads its user with useSuspense(UserResource.get, { id: userId }); PostList passes only ids.",
"files": [],
"assertions": [
"No lookup map of users is built and passed down.",
"The component rendering the avatar reads the user itself, given the id.",
"`PostList` does not read `UserResource`."
]
},
{
"id": 5,
"name": "load-more",
"prompt": "`TodoResource` has `paginationField: 'page'`. Add a 'Load more' button under `TodoList` that loads the next page below the todos already shown.",
"expected_output": "The click handler calls ctrl.fetch(TodoResource.getList.getPage, { ...args, page }); TodoList keeps rendering useSuspense(TodoResource.getList, args).",
"files": [],
"assertions": [
"The next page is loaded with `TodoResource.getList.getPage`.",
"Pages are not fetched with plain `getList` or accumulated in `useState`.",
"`ctrl.fetch` runs in the click handler, not `useEffect`."
]
},
{
"id": 6,
"name": "parallel-fetch",
"prompt": "Write `PostHeader` (src/components/PostHeader.tsx): one `<header>` showing a post's title (`PostResource.get`) next to its comment count (`CommentResource.getList` with `{ postId }`). The app is on React 18.",
"expected_output": "No waterfall: useFetch for both then useSuspense, a child component per request, or useDLE; no use().",
"files": [],
"assertions": [
"Both requests start in the same render: `useFetch` for each before any `useSuspense`, `useDLE`, or one child component per request.",
"`use()` is not used (React 18)."
]
},
{
"id": 7,
"name": "refresh-all-lists",
"prompt": "After `ctrl.fetch(TodoResource.markAllDone)` (returns no body), refresh every cached todo list. Lists are cached under many `{ userId }` filters. Keep the current lists on screen while they reload. Write the `markAllDone` handler in src/components/MarkAllDone.tsx.",
"expected_output": "Calls ctrl.expireAll(TodoResource.getList) after the mutation.",
"files": [],
"assertions": [
"Uses `ctrl.expireAll(TodoResource.getList)` (or an equivalent testKey on getList).",
"Does not use `invalidate`/`invalidateAll`/`resetEntireStore`, which would drop the shown lists."
]
},
{
"id": 8,
"name": "boundary-reset",
"prompt": "In `TodoMaster`, `<AsyncBoundary><TodoDetail id={selectedId} /></AsyncBoundary>`. After a todo fails to load, picking another todo still shows the error. Fix it in src/components/TodoMaster.tsx.",
"expected_output": "Adds key={selectedId} to the AsyncBoundary.",
"files": [],
"assertions": [
"The boundary gets `key={selectedId}` (or the boundary otherwise resets when `selectedId` changes).",
"No custom error-boundary class is written."
]
},
{
"id": 9,
"name": "anansi-route-preload",
"prompt": "Add an issue detail route to src/routing/routes.tsx. It uses @anansi/router: `export const routes: Route<Controller>[] = [...]`, and each route has `name`, `component` (from `lazyPage()`) and an optional `resolveData(controller, match, searchParams)`. The new route is named 'IssueDetail', renders `lazyPage('IssueDetail')`, and gets `{ id: string }` as its match. The page shows `IssueResource.get` with `{ id }` and, lower down, `CommentResource.getList` with `{ issueId: id }`. Make both requests start as soon as the user navigates, not when each component renders. Write only the new route object.",
"expected_output": "resolveData starts fetchIfStale for the issue and the comments; the comments are not awaited, and the issue is either not awaited or awaited inside Promise.allSettled() so resolveData's Promise never rejects.",
"files": [],
"assertions": [
"`resolveData` calls `controller.fetchIfStale()` for both `IssueResource.get` and `CommentResource.getList` (not `controller.fetch()`).",
"The comments `fetchIfStale()` is not awaited or returned, and is not inside an awaited or returned `Promise.all()`/`Promise.allSettled()` with the issue.",
"`resolveData`'s Promise can't reject from a failed fetch: no bare `await` or `return` of a `fetchIfStale()` call and no `Promise.all()`; awaiting the issue inside `Promise.allSettled()` (or with `.catch()`) is fine."
]
}
]
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |