# Dev Create Hook

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

- **Type:** Skill
- **Install:** `agentstack add skill-herbertjulio-specialist-agent-dev-create-hook`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [HerbertJulio](https://agentstack.voostack.com/s/herbertjulio)
- **Installs:** 0
- **Category:** [Developer Tools](https://agentstack.voostack.com/c/developer-tools)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [HerbertJulio](https://github.com/HerbertJulio)
- **Source:** https://github.com/HerbertJulio/specialist-agent/tree/main/packs/react/skills/dev-create-hook
- **Website:** https://specialistagent.com.br

## Install

```sh
agentstack add skill-herbertjulio-specialist-agent-dev-create-hook
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

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

Hook: $ARGUMENTS

## Steps

1. Read `docs/ARCHITECTURE.md` section 4.4.

2. Determine the type:
   - **Query** (data reading) -> `useQuery` + service + adapter
   - **Mutation** (write/delete) -> `useMutation` + query invalidation
   - **Pure logic** (no API) -> useState + useMemo + useEffect

3. Create the hook in `hooks/use[Name].ts`:

### Query Hook Template
```typescript
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
```typescript
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'] })
    },
  })
}
```

4. Required: `use` prefix, staleTime for queries, queryKey as array, adapter in queryFn.

5. Connect the layers: service -> adapter -> React Query

6. 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.

- **Author:** [HerbertJulio](https://github.com/HerbertJulio)
- **Source:** [HerbertJulio/specialist-agent](https://github.com/HerbertJulio/specialist-agent)
- **License:** MIT
- **Homepage:** https://specialistagent.com.br

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

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-herbertjulio-specialist-agent-dev-create-hook
- Seller: https://agentstack.voostack.com/s/herbertjulio
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
