add-hook
Create a custom React hook with TypeScript and tests
Best use case
add-hook is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Create a custom React hook with TypeScript and tests
Teams using add-hook should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/add-hook/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How add-hook Compares
| Feature / Agent | add-hook | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Create a custom React hook with TypeScript and tests
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# Add Hook: $ARGUMENTS
Create a custom React hook with proper typing and tests.
## Process
### 1. Plan the Hook
Determine:
- What state does it manage?
- What side effects does it handle?
- What does it return?
### 2. Create Hook File
Location: `hooks/use[HookName].ts`
```typescript
import { useState, useEffect, useCallback } from 'react';
interface UseHookNameOptions {
// configuration options
initialValue?: string;
}
interface UseHookNameReturn {
// return type
value: string;
setValue: (value: string) => void;
isLoading: boolean;
error: Error | null;
}
export function useHookName(options: UseHookNameOptions = {}): UseHookNameReturn {
const { initialValue = '' } = options;
const [value, setValue] = useState(initialValue);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<Error | null>(null);
const handleSetValue = useCallback((newValue: string) => {
setValue(newValue);
}, []);
useEffect(() => {
// Side effects here
}, []);
return {
value,
setValue: handleSetValue,
isLoading,
error,
};
}
```
### 3. Add to Exports
```typescript
// hooks/index.ts
export { useHookName } from './useHookName';
```
### 4. Create Tests
```typescript
// hooks/useHookName.test.ts
import { renderHook, act } from '@testing-library/react';
import { useHookName } from './useHookName';
describe('useHookName', () => {
test('returns initial value', () => {
const { result } = renderHook(() => useHookName());
expect(result.current.value).toBe('');
});
test('updates value', () => {
const { result } = renderHook(() => useHookName());
act(() => {
result.current.setValue('new value');
});
expect(result.current.value).toBe('new value');
});
test('accepts initial value option', () => {
const { result } = renderHook(() =>
useHookName({ initialValue: 'custom' })
);
expect(result.current.value).toBe('custom');
});
});
```
### 5. Validate
```bash
npm run build
npm run lint
npm test
```
## Common Hook Patterns
**Data fetching:**
```typescript
export function useFetch<T>(url: string) {
const [data, setData] = useState<T | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
// ...
}
```
**Local storage:**
```typescript
export function useLocalStorage<T>(key: string, initialValue: T) {
const [value, setValue] = useState<T>(() => {
const stored = localStorage.getItem(key);
return stored ? JSON.parse(stored) : initialValue;
});
// ...
}
```
**Debounce:**
```typescript
export function useDebounce<T>(value: T, delay: number): T {
const [debouncedValue, setDebouncedValue] = useState(value);
// ...
}
```
**Media query:**
```typescript
export function useMediaQuery(query: string): boolean {
const [matches, setMatches] = useState(false);
// ...
}
```Related Skills
add-hook-whatifwedigdeeper-application-tracker
Create a custom React hook with TypeScript and tests
add-feature-hook
Creates TanStack Query hooks for API features with authentication. Use when connecting frontend to backend endpoints, creating data fetching hooks.
ac-stop-hook-analyzer
Analyze context and decide on continuation via Stop hook. Use when determining if work should continue, analyzing completion status, making continuation decisions, or implementing the Two-Claude pattern.
ux
This AI agent skill provides comprehensive guidance for creating professional and insightful User Experience (UX) designs, covering user research, information architecture, interaction design, visual guidance, and usability evaluation. It aims to produce actionable, user-centered solutions that avoid generic AI aesthetics.
vly-money
Generate crypto payment links for supported tokens and networks, manage access to X402 payment-protected content, and provide direct access to the vly.money wallet interface.
whisper-transcribe
Transcribes audio and video files to text using OpenAI's Whisper CLI, enhanced with contextual grounding from local markdown files for improved accuracy.
ontopo
An AI agent skill to search for Israeli restaurants, check table availability, view menus, and retrieve booking links via the Ontopo platform, acting as an unofficial interface to its data.
lets-go-rss
A lightweight, full-platform RSS subscription manager that aggregates content from YouTube, Vimeo, Behance, Twitter/X, and Chinese platforms like Bilibili, Weibo, and Douyin, featuring deduplication and AI smart classification.
astro
This skill provides essential Astro framework patterns, focusing on server-side rendering (SSR), static site generation (SSG), middleware, and TypeScript best practices. It helps AI agents implement secure authentication, manage API routes, and debug rendering behaviors within Astro projects.
tech-blog
Generates comprehensive technical blog posts, offering detailed explanations of system internals, architecture, and implementation, either through source code analysis or document-driven research.
modal-deployment
Run Python code in the cloud with serverless containers, GPUs, and autoscaling using Modal. This skill enables agents to generate code for deploying ML models, running batch jobs, serving APIs, and scaling compute-intensive workloads.
chrome-debug
This skill empowers AI agents to debug web applications and inspect browser behavior using the Chrome DevTools Protocol (CDP), offering both collaborative (headful) and automated (headless) modes.