AgentStack
SKILL verified MIT Self-run

Dev Create Hook

skill-herbertjulio-specialist-agent-dev-create-hook · by HerbertJulio

Use when adding server state management to a module - creates React Query hook with caching and error handling.

No reviews yet
0 installs
10 views
0.0% view→install

Install

$ agentstack add skill-herbertjulio-specialist-agent-dev-create-hook

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Dev Create Hook? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Create a custom hook following docs/ARCHITECTURE.md section 4.4.

Hook: $ARGUMENTS

Steps

  1. Read docs/ARCHITECTURE.md section 4.4.
  1. Determine the type:
  • Query (data reading) -> useQuery + service + adapter
  • Mutation (write/delete) -> useMutation + query invalidation
  • Pure logic (no API) -> useState + useMemo + useEffect
  1. Create the hook in hooks/use[Name].ts:

Query Hook Template

import { useQuery, keepPreviousData } from '@tanstack/react-query'
import { xxxService } from '../services/xxx-service'
import { xxxAdapter } from '../adapters/xxx-adapter'

interface UseXxxOptions {
  page: number
  pageSize?: number
}

export function useXxx(options: UseXxxOptions) {
  const { page, pageSize = 20 } = options

  const { data, isLoading, isFetching, error, refetch } = useQuery({
    queryKey: ['xxx', { page, pageSize }],
    queryFn: async () => {
      const response = await xxxService.list({ page, pageSize })
      return xxxAdapter.toXxxList(response.data)
    },
    staleTime: 5 * 60 * 1000,
    placeholderData: keepPreviousData,
  })

  return { data, isLoading, isFetching, error, refetch }
}

Mutation Hook Template

import { useMutation, useQueryClient } from '@tanstack/react-query'
import { xxxService } from '../services/xxx-service'
import { xxxAdapter } from '../adapters/xxx-adapter'

export function useCreateXxx() {
  const queryClient = useQueryClient()

  return useMutation({
    mutationFn: async (input: CreateXxxInput) => {
      const payload = xxxAdapter.toCreatePayload(input)
      const response = await xxxService.create(payload)
      return xxxAdapter.toXxx(response.data)
    },
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['xxx'] })
    },
  })
}
  1. Required: use prefix, staleTime for queries, queryKey as array, adapter in queryFn.
  1. Connect the layers: service -> adapter -> React Query
  1. Validate: npx tsc --noEmit

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.