New api hook
Scaffold a TanStack Query hook and API fetch function for a .NET BFF endpointFrom its SKILL.md
npx -y skills add dqube/frondend --skill new-api-hookAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.4 KB, as published. Nobody here has run it
Scaffold a typed TanStack Query hook that calls the ModernStores .NET Core BFF API.
Arguments
$ARGUMENTS format: <app> <domain> <operation> [method]
<app>:store|admin<domain>: e.g.products,orders,cart,inventory,promotions<operation>: camelCase, e.g.list,getById,create,update,delete[method]:GET(default) |POST|PUT|PATCH|DELETE
Examples:
/new-api-hook store products list→useProductsListquery/new-api-hook store cart addItem POST→useCartAddItemmutation/new-api-hook admin orders updateStatus PATCH→useOrdersUpdateStatusmutation
Files to create
apps/<app>/hooks/use-<domain>-<operation>.ts
For GET (useQuery):
import { useQuery } from '@tanstack/react-query'
import { fetch<Domain><Operation> } from '@/lib/api/<domain>'
import type { <Domain>ListParams } from '@modernstores/types'
export function use<Domain><Operation>(params?: <Domain>ListParams) {
return useQuery({
queryKey: ['<domain>', '<operation>', params],
queryFn: () => fetch<Domain><Operation>(params),
})
}
For mutations (POST/PUT/PATCH/DELETE):
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { <domain><Operation> } from '@/lib/api/<domain>'
export function use<Domain><Operation>() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: <domain><Operation>,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['<domain>'] })
},
})
}
apps/<app>/lib/api/<domain>.ts (create or update)
import { apiClient } from '@/lib/api-client'
import type { <DomainType> } from '@modernstores/types'
export async function fetch<Domain><Operation>(params?: unknown): Promise<<DomainType>[]> {
const { data } = await apiClient.get<<DomainType>[]>('/<domain>')
return data
}
Rules
- Never use
any— checkpackages/typesfor existing types before creating new ones - Use
snake_casearray segments for query keys that mirror the API route - Always invalidate related queries on mutation success
- Do not catch errors locally — the global
apiClientinterceptor handles them