.agents/skills/add-hook/SKILL.md
Step-by-step guide for adding a new React hook to the shadcn-hooks project. Use when the user wants to create, add, or implement a new hook in this repository.
npx skillsauth add debbl/shadcn-hooks add-hookInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Guide for adding a new hook to the shadcn-hooks project. The source of truth is src/registry/hooks/. The packages/shadcn-hooks/ directory is auto-generated and should NOT be edited manually. Do NOT run any sync command as part of this skill; the user will run it manually when needed.
Copy this checklist and track progress:
Add Hook: use-<name>
- [ ] Step 1: Create registry entry (src/registry/hooks/use-<name>/)
- [ ] Step 2: Register in meta.json
- [ ] Step 3: Update introduction.mdx
- [ ] Step 4: Create skill reference doc
- [ ] Step 5: Update skill SKILL.md function table
- [ ] Step 6: Verify (lint + test)
Create directory src/registry/hooks/use-<name>/ with 5 files:
index.ts — Hook implementationRules:
@/registry/hooks/... and @/registry/lib/... import aliasesexport function use<Name>(...)anyuseBoolean, useEventListener, useMemoizedFn)Reference example — simple hook:
// src/registry/hooks/use-previous/index.ts
import { useRef } from 'react'
export type ShouldUpdateFunc<T> = (prev?: T, next?: T) => boolean
const defaultShouldUpdate = <T>(a?: T, b?: T) => !Object.is(a, b)
export default function usePrevious<T>(
state: T,
shouldUpdate: ShouldUpdateFunc<T> = defaultShouldUpdate,
): T | undefined {
const prevRef = useRef<T>()
const curRef = useRef<T>()
if (shouldUpdate(curRef.current, state)) {
prevRef.current = curRef.current
curRef.current = state
}
return prevRef.current
}
Reference example — hook composing other hooks:
// src/registry/hooks/use-hover/index.ts
import { useBoolean } from '@/registry/hooks/use-boolean'
import { useEventListener } from '@/registry/hooks/use-event-listener'
import type { BasicTarget } from '@/registry/lib/create-effect-with-target'
export interface UseHoverOptions {
onEnter?: () => void
onLeave?: () => void
onChange?: (isHovering: boolean) => void
}
export function useHover(
target: BasicTarget,
options?: UseHoverOptions,
): boolean {
const { onEnter, onLeave, onChange } = options || {}
const [state, { setTrue, setFalse }] = useBoolean(false)
useEventListener(
'mouseenter',
() => {
onEnter?.()
setTrue()
onChange?.(true)
},
{ target },
)
useEventListener(
'mouseleave',
() => {
onLeave?.()
setFalse()
onChange?.(false)
},
{ target },
)
return state
}
registry-item.json — Dependencies{
"registryDependencies": [
"@shadcnhooks/use-dependency-a",
"@shadcnhooks/use-dependency-b"
]
}
@shadcnhooks/{ "registryDependencies": [] }demo/demo-01.tsx — Demo component'use client'
import { use<Name> } from '..'
export function Demo01() {
// Interactive demo showcasing the hook
}
Rules:
'use client')'..' (parent directory)~/components/ui/... (e.g. Button, Card, Input)index.mdx — Documentation page---
title: use<Name>
description: A hook to <description>
---
import { Demo01 } from './demo/demo-01'
<Demo01 />
## Installation
<Tabs items={['CLI', 'Manual']}>
<Tab>
<InstallCLI value='use-<name>' />
</Tab>
<Tab>
Copy and paste the following code into your project.
<RegistrySourceCode value='use-<name>' />
</Tab>
</Tabs>
## API
\`\`\`ts
// Full type declarations here
\`\`\`
## Credits
- [use-<name>](credit-link)
Notes:
<RegistrySourceCode> entries under the Manual tab (see use-boolean which includes use-toggle)index.test.ts — Testsimport { act, renderHook } from '@testing-library/react'
import { describe, expect, it } from 'vitest'
import { use<Name> } from './index'
describe('use<Name>', () => {
it('should ...', () => {
const { result } = renderHook(() => use<Name>(...))
expect(result.current).toBe(...)
})
})
Rules:
vitest + @testing-library/react'./index'beforeEach / clean up in afterEachmeta.jsonAdd "use-<name>" to src/registry/hooks/meta.json under the appropriate category:
---State--- — state management hooks---Advanced--- — memoization, refs, advanced patterns---Lifecycle--- — effects, timers, mount/unmount---Browser--- — DOM, events, browser APIs---Dev--- — development/debug utilities---External--- — wrappers around external librariesAdd the new hook to content/docs/introduction.mdx under the appropriate category section:
Add a line in alphabetical order within the category:
- [`use<Name>`](/docs/hooks/use-<name>) - <Short description>
Create skills/shadcn-hooks/references/use<Name>.md:
# use<Name>
<One-line description>.
## Usage
\`\`\`tsx
import { use<Name> } from '@/hooks/use-<name>'
function Component() {
// Minimal usage example
}
\`\`\`
## Type Declarations
\`\`\`ts
// Full type signatures
\`\`\`
## Parameters
| Parameter | Type | Default | Description |
| --------- | ---- | ------- | ----------- |
| ... | ... | ... | ... |
## Returns
| Type | Description |
| ---- | ----------- |
| ... | ... |
Add an entry to the appropriate category table in skills/shadcn-hooks/SKILL.md:
| [`use<Name>`](references/use<Name>.md) | <description> | AUTO |
AUTO for standalone hooksEXTERNAL for hooks that wrap external npm packagespnpm test run src/registry/hooks/use-<name>/index.test.tspackages/shadcn-hooks/ and do not run pnpm run sync or pnpm --dir packages/shadcn-hooks sync; leave that step to the userpackages/shadcn-hooks/ is auto-generated. Never edit files in that directory manually as part of this skill.sync command from this skill. The user will run sync manually after reviewing the changes.packages/shadcn-hooks/src/index.ts exports are also auto-managed — no manual editing needed.development
Apply shadcn-hooks React hooks where appropriate to build concise, maintainable React features.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.
development
Run, watch, debug, and extend OpenClaw QA testing with qa-lab and qa-channel. Use when Codex needs to execute the repo-backed QA suite, inspect live QA artifacts, debug failing scenarios, add new QA scenarios, or explain the OpenClaw QA workflow. Prefer the live OpenAI lane with regular openai/gpt-5.4 in fast mode; do not use gpt-5.4-pro or gpt-5.4-mini unless the user explicitly overrides that policy.