state-management
Skill117 starsChanged 10 days agoMITView on GitHub
CoreAI Sandbox's TanStack Query + mock-JSON data layer. USE WHEN: editing data-fetching hooks (`app/hooks/use*.ts`), adding mock data in `app/data/`, or wiring a component to query state.
We split this skill into the rules it gives an agent
5 rules. 0 are common, 5 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 21 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 306
Low Complexity: - No backend needed
- Distinctive: line 311
When moving components to production:
- Distinctive: line 314
Add resolver pattern and authentication
- Distinctive: line 315
Add SSR/loader prefetching
- Distinctive: line 317
Add proper error handling and retry logic
“Common” is measured: kept by at least 6 in 10 of the 21 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
State Management Instructions — CoreAI Sandbox Demo
Paths below are relative to this app's directory.
Overview
The app uses TanStack Query v5 hooks over local JSON data to provide client-side loading, filtering, and caching for prototypes.
Architecture
1. QueryProvider Setup
The app is wrapped with QueryProvider in app/root.tsx:
import { QueryProvider } from './core/datafetching/QueryProvider';
export default function App() {
return (
<QueryProvider>
<AppContent>
<Outlet />
</AppContent>
</QueryProvider>
);
}Configuration (app/core/datafetching/QueryProvider.tsx):
staleTime: 5 minutes- Data is considered freshgcTime: 10 minutes- Garbage collection timeretry: false- Don't retry failed requestsrefetchOnWindowFocus: false- Don't refetch on focus
2. Mock Data Layer
Location: app/data/
Files:
agents.json- agents with varied lifecycle statusestools.json- tools with categories and publish statusmodels.json- models with provider and category metadatahome.json- Home page endpoints, model actions, carousel models, and recent workindex.ts- TypeScript interfaces and utility functions
Data Types:
export interface Agent {
id: string;
name: string;
description: string;
status: 'draft' | 'published' | 'deployed';
tags: string[];
owner: string;
createdDate: string; // ISO 8601
updatedDate: string; // ISO 8601
version: string; // Semantic version
}
export interface Tool {
mark: string;
initialsColor: string;
id: string;
name: string;
description: string;
category: ToolCategory;
isPublished: boolean;
}Utility Functions:
// Filter agents by status
filterAgentsByStatus(agents: Agent[], status: AgentStatus): Agent[]
// Filter tools by category
filterToolsByCategory(tools: Tool[], category: ToolCategory): Tool[]
// Filter tools by published status
filterToolsByPublished(tools: Tool[], isPublished: boolean): Tool[]3. Custom Hooks Pattern
Location: app/hooks/
Custom hooks wrap TanStack Query's useQuery and import JSON data directly.
Example — useAgents.ts:
import type { Agent, AgentStatus } from '~/data';
import { useQuery } from '@tanstack/react-query';
import { agents, filterAgentsByStatus } from '~/data';
async function delay(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export interface UseAgentsOptions {
status?: AgentStatus;
}
export function useAgents(options?: UseAgentsOptions) {
return useQuery({
queryKey: ['agents', options?.status],
queryFn: async (): Promise<Agent[]> => {
// Simulate network delay (400ms)
await delay(400);
// Return filtered or all agents
if (options?.status) {
return filterAgentsByStatus(agents, options.status);
}
return agents;
},
});
}Available Hooks:
useAgents(options?)- Fetch agents, optionally filtered by statususeTools(options?)- Fetch tools, optionally filtered by category/publish statususeHomeData()- Fetch mock home page content
Query Keys:
['agents', status?] // e.g., ['agents', 'draft']
['tools', category?, isPublished?] // e.g., ['tools', 'Data', true]
['home'] // Home page mock content4. Component Usage Pattern
Components use custom hooks directly in route components:
import { useAgents } from '~/hooks/useAgents';
import { CollectionPage } from '~/components/common';
import type { TableColumnDefinition } from '~/components/common';
import type { Agent } from '~/data';
export default function BuildAgents() {
const { data: agents, isLoading } = useAgents({ status: 'draft' });
const columns: TableColumnDefinition<Agent>[] = [
{
columnId: 'name',
renderHeaderCell: () => 'Name',
renderCell: (agent) => agent.name,
compare: (first, second) => first.name.localeCompare(second.name),
},
];
return (
<CollectionPage
headerProps={{ title: 'Agents' }}
dataGridProps={{
items: agents ?? [],
isLoading,
columns,
getRowId: (agent) => agent.id,
}}
/>
);
}5. Route-Specific Filtering
Different routes show different subsets of the same data:
| Route | Hook Usage | Filter |
/build/agents | useAgents() via AgentList | All agents (50) |
/build/agents/drafts | useAgents() via AgentList, then local status filtering | Draft agents (14) |
/build/agents/published | useAgents() via AgentList, then local status filtering | Published agents (19) |
/operate/agents | useAgents({ status: 'deployed' }) | Deployed agents (17) |
/build/tools | useTools() | All tools (35) |
/discover/tools | Direct tools import mapped into catalog items | All tools (35; 29 published) |
6. Loading States
TanStack Query provides automatic loading state management:
import { DataGridWithFilters } from '~/components/common';
const { data, isLoading, error } = useAgents();
// The app-owned grid handles loading state; columns are defined by the consuming component.
<DataGridWithFilters columns={columns} isLoading={isLoading} items={data ?? []} />;States Available:
isLoading- Initial fetch in progressisFetching- Any fetch in progress (including background refetch)isError- Query failederror- Error object if query faileddata- Query result data
Best Practices
DO:
- ✅ Use TanStack Query for ALL data fetching
- ✅ Use custom hooks (
useAgents,useTools) in components - ✅ Pass query results to the app-owned
DataGridWithFilters(or a page composition'sdataGridProps) withisLoading; the underlying CoreAIDataGriddoes not supply this app-owned loading API - ✅ Provide sensible empty states
- ✅ Use consistent query keys for caching
- ✅ Filter data via hook options when possible
DON'T:
- ❌ Don't fetch data in
useEffect - ❌ Don't use
useStatefor server data - ❌ Don't call TanStack Query's
useQuerydirectly - use custom hooks - ❌ Don't mutate imported JSON data
- ❌ Don't add SSR/loader patterns (this is client-only)
- ❌ Don't add real API calls or authentication
Simulated Delays
The mock query hooks useAgents, useTools, and useHomeData include a 400ms simulated delay:
async function delay(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}This creates realistic loading states without actual network requests.
Adding New Data
1. Create JSON File
// app/data/newentity.json
[
{ "id": "entity-001", "name": "Example", ... }
]2. Add Type to app/data/index.ts
export interface NewEntity {
id: string;
name: string;
// ...
}
import newEntityData from './newentity.json';
export const newEntities: NewEntity[] = newEntityData as NewEntity[];3. Create Custom Hook
// app/hooks/useNewEntity.ts
import { useQuery } from '@tanstack/react-query';
import { newEntities } from '~/data';
async function delay(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export function useNewEntity() {
return useQuery({
queryKey: ['newEntity'],
queryFn: async () => {
await delay(400);
return newEntities;
},
});
}4. Use in Component
import { useNewEntity } from '~/hooks/useNewEntity';
const { data, isLoading } = useNewEntity();Architecture Benefits
This simplified architecture provides:
- Consistent Patterns - Easy to port components to production
- Realistic UX - Loading states, caching behavior
- Type Safety - TypeScript throughout
- Low Complexity - No backend needed
- Fast Iteration - Change JSON, see results immediately
Migration to Production
When moving components to production:
- Custom hooks stay similar but fetch from real APIs
- Add resolver pattern and authentication
- Add SSR/loader prefetching
- Replace JSON imports with HTTP calls
- Add proper error handling and retry logic
- Configure appropriate
staleTimeper query
Related Files
app/core/datafetching/QueryProvider.tsx- TanStack Query providerapp/data/index.ts- Type definitions and exportsapp/data/agents.json- Mock agent dataapp/data/tools.json- Mock tool dataapp/data/models.json- Mock model dataapp/data/home.json- Mock home contentapp/hooks/useAgents.ts- Agents data hookapp/hooks/useTools.ts- Tools data hookapp/hooks/useHomeData.ts- Home content data hook
Other versions27 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 27
- compozy/compozy★ 2.8ksame name
- conorluddy/xclaude-plugin★ 186same name
- cohen-liel/hivemind★ 108same name
- TheBeardedBearSAS/claude-craft★ 108same name
- EmeaAppGbb/spec2cloud★ 100same name
- statelyai/skills★ 48same name
- komluk/scaffolding★ 15same name
- darknecrocities/SkillBuilder★ 13same name
- PMDevSolutions/Aurelius★ 9same name
- YepAPI/skills★ 8same name
17 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use css-architecture, error-handling and 6 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Piyush8296Skillcss-architecture
CSS architecture, Tailwind patterns, responsive design, design tokens, and styling best practices. Use when implementing designs, setting up styling infrastructure, or debugging layout issues.
Also in 3 projects that use this
MicrosoftSkillerror-handling
统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。
Also in 6 projects that use this
lbednerSkilli18n
Use when a code or template change introduces a new translation message key, in either the framework CLI (aegis/i18n/locales/) or a generated project's CLI (the app/i18n/locales/ template tree). Covers adding the real English string, stubbing the same key into every other locale for parity, and the separate translation PR that later replaces placeholders with reviewed native text.
Also in 3 projects that use this
genomewalkerSkillresume
Resume a thread by loading its ~800-token context capsule
Also in 3 projects that use this
NVIDIASkilltesting
Run Python and Rust tests for physicsnemo-curator using uv + pytest with coverage reporting via pytest-cov, and cargo-nextest for Rust tests. Includes benchmark workflows with pytest-benchmark and criterion.
Also in 5 projects that use this
0xSeroSkillsecurity
Also in 3 projects that use this
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- hub/AGENTS.mdAGENTS.md
- starters/coreai/AGENTS.mdAGENTS.md
- starters/minimal/AGENTS.mdAGENTS.md
- replica-pick-and-polishSkill
- replica-publish-prototypeSkill
- review-hub-feedbackSkill
- code-reviewSkill
- write-testsSkill
- coreai-ds-fluentui-reactSkill
- css-stylingSkill
- features-variantsSkill
- iconsSkill
- interpreting-htmlSkill
- lintSkill
- new-variantSkill
- react-componentsSkill
- routingSkill
- start-appSkill
- context-templatesSkill
- accessibility-auditSkill
- add-seed-dataSkill
- agent-browserSkill
- browser-canvas-validationSkill
- component-design-system-reviewSkill
- create-prototypeSkill
- developer-handoffSkill
- prepare-feedback-proposalsSkill
- product-designSkill
- prototype-controlsSkill
- responsive-auditSkill
- review-hub-feedbackSkill
- setup-skillsSkill
- visual-design-reviewSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

