Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Standardized guidelines and patterns for Frontend React Hooks Custom.
.claude/skills/valec3-frontend-react-hooks-custom/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 10% | 0% |
| case-07 | ✓→✗ | ▼ Worse | 76% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 72% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 73% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 62% | 0% |
use prefixAll hooks MUST start with use:
typescript// ✅ Good useUser useLocalStorage usePrevious // ❌ Bad getUser localStorage previous
typescriptexport function useToggle(initialValue = false) { const [value, setValue] = useState(initialValue); const toggle = useCallback(() => { setValue(v => !v); }, []); const setTrue = useCallback(() => setValue(true), []); const setFalse = useCallback(() => setValue(false), []); return { value, toggle, setTrue, setFalse }; } // Usage function Component() { const modal = useToggle(); return ( <> <button onClick={modal.setTrue}>Open</button> {modal.value && <Modal onClose={modal.setFalse} />} </> ); }
typescriptinterface UseQueryOptions<T> { enabled?: boolean; refetchOnMount?: boolean; onSuccess?: (data: T) => void; onError?: (error: Error) => void; } export function useQuery<T>( key: string, fetcher: () => Promise<T>, options: UseQueryOptions<T> = {} ) { const [data, setData] = useState<T | null>(null); const [error, setError] = useState<Error | null>(null); const [isLoading, setIsLoading] = useState(false); const execute = useCallback(async () => { setIsLoading(true); setError(null); try { const result = await fetcher(); setData(result); options.onSuccess?.(result); } catch (err) { const error = err as Error; setError(error); options.onError?.(error); } finally { setIsLoading(false); } }, [fetcher, options]); useEffect(() => { if (options.enabled !== false) { execute(); } }, [key, options.enabled, execute]); const refetch = useCallback(() => { return execute(); }, [execute]); return { data, error, isLoading, refetch }; } // Usage function UserProfile({ userId }: { userId: string }) { const { data: user, isLoading, error, refetch } = useQuery( `user-${userId}`, () => fetchUser(userId), { onSuccess: (user) => console.log('User loaded:', user), onError: (err) => console.error('Failed:', err) } ); if (isLoading) return <div>Loading...</div>; if (error) return <div>Error: {error.message}</div>; return <div>{user?.name}</div>; }
typescriptexport function useForm<T extends Record<string, any>>(initialValues: T) { const [values, setValues] = useState(initialValues); const [errors, setErrors] = useState<Partial<Record<keyof T, string>>>({}); const [touched, setTouched] = useState<Partial<Record<keyof T, boolean>>>({}); const handleChange = useCallback((name: keyof T, value: any) => { setValues(prev => ({ ...prev, [name]: value })); }, []); const handleBlur = useCallback((name: keyof T) => { setTouched(prev => ({ ...prev, [name]: true })); }, []); const setFieldError = useCallback((name: keyof T, error: string) => { setErrors(prev => ({ ...prev, [name]: error })); }, []); const reset = useCallback(() => { setValues(initialValues); setErrors({}); setTouched({}); }, [initialValues]); return { values, errors, touched, handleChange, handleBlur, setFieldError, reset }; } // Usage function LoginForm() { const form = useForm({ email: '', password: '' }); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!form.values.email) { form.setFieldError('email', 'Email is required'); return; } // Submit logic }; return ( <form onSubmit={handleSubmit}> <input value={form.values.email} onChange={e => form.handleChange('email', e.target.value)} onBlur={() => form.handleBlur('email')} /> {form.errors.email && <span>{form.errors.email}</span>} </form> ); }
typescriptexport function useLocalStorage<T>(key: string, initialValue: T) { const [storedValue, setStoredValue] = useState<T>(() => { try { const item = window.localStorage.getItem(key); return item ? JSON.parse(item) : initialValue; } catch (error) { console.error(error); return initialValue; } }); const setValue = useCallback((value: T | ((val: T) => T)) => { try { const valueToStore = value instanceof Function ? value(storedValue) : value; setStoredValue(valueToStore); window.localStorage.setItem(key, JSON.stringify(valueToStore)); } catch (error) { console.error(error); } }, [key, storedValue]); return [storedValue, setValue] as const; } // Usage function ThemeSwitcher() { const [theme, setTheme] = useLocalStorage('theme', 'light'); return ( <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}> Current: {theme} </button> ); }
typescriptexport function useDebounce<T>(value: T, delay: number): T { const [debouncedValue, setDebouncedValue] = useState(value); useEffect(() => { const handler = setTimeout(() => { setDebouncedValue(value); }, delay); return () => { clearTimeout(handler); }; }, [value, delay]); return debouncedValue; } // Usage function SearchInput() { const [search, setSearch] = useState(''); const debouncedSearch = useDebounce(search, 500); useEffect(() => { if (debouncedSearch) { // Fetch results console.log('Searching for:', debouncedSearch); } }, [debouncedSearch]); return <input value={search} onChange={e => setSearch(e.target.value)} />; }
typescriptexport function usePrevious<T>(value: T): T | undefined { const ref = useRef<T>(); useEffect(() => { ref.current = value; }, [value]); return ref.current; } // Usage function Counter() { const [count, setCount] = useState(0); const prevCount = usePrevious(count); return ( <div> <p>Current: {count}</p> <p>Previous: {prevCount}</p> <button onClick={() => setCount(count + 1)}>Increment</button> </div> ); }
use@testing-library/react-hooks| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 16,478 | 12,534 | -24% | 1 | 1 | 0% | 3,804 | 4,192 | +10% | 0 | 0 | — |
case-02 | pass→pass | 9,308 | 4,433 | -52% | 1 | 1 | 0% | 1,659 | 2,849 | +72% | 0 | 0 | — |
case-03 | pass→pass | 10,129 | 6,782 | -33% | 1 | 1 | 0% | 1,822 | 3,160 | +73% | 0 | 0 | — |
case-04 | fail→fail | 16,410 | 9,813 | -40% | 1 | 1 | 0% | 1,896 | 3,619 | +91% | 0 | 0 | — |
case-05 | pass→pass | 8,164 | 4,101 | -50% | 1 | 1 | 0% | 1,667 | 2,693 | +62% | 0 | 0 | — |
case-06 | pass→pass | 12,248 | 10,713 | -13% | 1 | 1 | 0% | 2,239 | 4,103 | +83% | 0 | 0 | — |
case-07 | pass→fail | 9,873 | 6,816 | -31% | 1 | 1 | 0% | 1,666 | 2,933 | +76% | 0 | 0 | — |
case-08 | pass→pass | 8,817 | 6,141 | -30% | 1 | 1 | 0% | 1,738 | 2,873 | +65% | 0 | 0 | — |
case-09 | pass→pass | 9,213 | 7,239 | -21% | 1 | 1 | 0% | 1,519 | 3,237 | +113% | 0 | 0 | — |
case-10 | pass→pass | 11,384 | 9,592 | -16% | 1 | 1 | 0% | 2,130 | 3,857 | +81% | 0 | 0 | — |
case-11 | fail→fail | 4,612 | 3,859 | -16% | 1 | 1 | 0% | 845 | 2,620 | +210% | 0 | 0 | — |
case-12 | pass→pass | 13,237 | 10,803 | -18% | 1 | 1 | 0% | 2,238 | 3,879 | +73% | 0 | 0 | — |
case-13 | pass→pass | 8,652 | 6,398 | -26% | 1 | 1 | 0% | 1,717 | 3,152 | +84% | 0 | 0 | — |
case-14 | pass→pass | 10,572 | 8,977 | -15% | 1 | 1 | 0% | 2,008 | 3,743 | +86% | 0 | 0 | — |
case-15 | pass→pass | 8,443 | 6,332 | -25% | 1 | 1 | 0% | 1,497 | 3,139 | +110% | 0 | 0 | — |
case-16 | pass→pass | 9,760 | 8,911 | -9% | 1 | 1 | 0% | 1,823 | 3,605 | +98% | 0 | 0 | — |
case-17 | pass→pass | 7,758 | 6,082 | -22% | 1 | 1 | 0% | 1,540 | 2,894 | +88% | 0 | 0 | — |
case-18 | pass→pass | 13,197 | 8,084 | -39% | 1 | 1 | 0% | 2,275 | 3,382 | +49% | 0 | 0 | — |
case-19 | fail→fail | 11,237 | 10,571 | -6% | 1 | 1 | 0% | 2,145 | 3,848 | +79% | 0 | 0 | — |
case-20 | pass→pass | 11,958 | 9,760 | -18% | 1 | 1 | 0% | 2,041 | 3,732 | +83% | 0 | 0 | — |
case-21 | pass→pass | 11,144 | 10,889 | -2% | 1 | 1 | 0% | 2,727 | 4,370 | +60% | 0 | 0 | — |
case-22 | pass→pass | 7,486 | 8,891 | +19% | 1 | 1 | 0% | 1,509 | 3,359 | +123% | 0 | 0 | — |
case-23 | pass→pass | 8,377 | 7,215 | -14% | 1 | 1 | 0% | 1,742 | 3,392 | +95% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of 0 percentage points is the difference between those two pass rates over the 23 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.