Generate a React Query hook for data fetching and mutations
Generates a React Query hook module with useQuery for fetching and
useMutation hooks for create/update/delete operations. Follows the project's
query key factory pattern and integrates with Drizzle ORM query functions.
/new-query useTransactions # queries/useTransactions.ts
/new-query useBudgets # queries/useBudgets.ts
/new-query useCategories # queries/useCategories.ts
| Argument | Required | Description |
|----------|----------|-------------|
| name | Yes | Hook name starting with use in camelCase |
Place the hook at:
queries/<hookName>.ts
Look for corresponding query functions in db/queries/. If they do not exist,
create them or inform the user they need to be created first.
Add query keys for the new entity to queries/queryKeys.ts:
export const queryKeys = {
// ... existing keys
<entity>: {
all: ['<entity>'] as const,
lists: () => [...queryKeys.<entity>.all, 'list'] as const,
list: (filters: Record<string, unknown>) =>
[...queryKeys.<entity>.lists(), filters] as const,
details: () => [...queryKeys.<entity>.all, 'detail'] as const,
detail: (id: string) =>
[...queryKeys.<entity>.details(), id] as const,
},
};
Create the module with:
useQuery hook for fetching all itemsuseQuery hook for fetching a single item by IDuseMutation hooks for create, update, and deletestaleTime valuesSee references/query-examples.md for templates.
Create a test at:
__tests__/queries/<hookName>.test.ts
npx tsc --noEmit
queryKeys factory in queries/queryKeys.tsall > lists > list(filters) > details > detail(id) hierarchyChoose based on data volatility:
30 * 60 * 1000 (30 minutes)5 * 60 * 1000 (5 minutes)2 * 60 * 1000 (2 minutes)0Always invalidate relevant queries on mutation success:
isError and error from the hookonError or at the call siteSearch for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer