From Darkroom Engineering
Creates reusable React hooks (useX pattern) with stack-aware templates for Next.js and React Router projects. Extracts component logic into typed, named custom hooks.
How this skill is triggered — by the user, by Claude, or both
Slash command
/darkroom:hook [hookName][hookName]The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Create a custom React hook following Darkroom conventions. The hook itself is stack-agnostic — what differs between satus and novus is the path alias.
Create a custom React hook following Darkroom conventions. The hook itself is stack-agnostic — what differs between satus and novus is the path alias.
Read package.json:
dependencies.next → satus / Next.js (path alias @/, no lib/hooks/ requires 'use client' boundary)dependencies["react-router"] → novus / React Router (path alias ~/, components isomorphic)| Stack | Hook path |
|---|---|
| satus | lib/hooks/<name>.ts |
| novus | hooks/<name>.ts (novus puts hooks/ at the project root) |
Confirm by checking the existing lib/hooks/ or hooks/ directory structure if either pattern is unclear from package.json alone.
// lib/hooks/<name>.ts
'use client'
import { useState, useEffect } from 'react'
interface Use<Name>Options {
// Hook configuration options
}
interface Use<Name>Return {
// Return type definition
}
export function use<Name>(options?: Use<Name>Options): Use<Name>Return {
// Implementation
return {
// Return values
}
}
// hooks/<name>.ts
// No 'use client' — RR components are isomorphic; the hook runs wherever
// it's called from. If the hook touches browser APIs, guard with
// `typeof window !== 'undefined'` or call from inside `useEffect`.
import { useState, useEffect } from 'react'
interface Use<Name>Options {
// Hook configuration options
}
interface Use<Name>Return {
// Return type definition
}
export function use<Name>(options?: Use<Name>Options): Use<Name>Return {
// Implementation
return {
// Return values
}
}
export function useX, not default.use — React hook naming convention.| satus | novus | |
|---|---|---|
| Directive | 'use client' (hooks live in client boundary) | None (isomorphic) |
| Browser API guard | Only runs after hydration anyway | Guard with typeof window or use useEffect |
| Path alias | @/ | ~/ |
If this hook uses an external library, fetch docs first:
mcp__context7__resolve-library-id → get-library-docs) for the current API.bun info <package> to check the latest version.For common use cases, prefer hamo hooks (fetch hamo docs via Context7 first):
import { useWindowSize, useRect, useIntersectionObserver } from 'hamo'
Only create custom hooks when hamo doesn't cover the use case.
User: "create a useLocalStorage hook" (in satus repo)
→ Creates lib/hooks/use-local-storage.ts with 'use client' directive
User: "create a useLocalStorage hook" (in novus repo)
→ Creates hooks/use-local-storage.ts, no directive, browser-API-guarded
$ARGUMENTS — Hook name (e.g., "useAuth", "useLocalStorage")npx claudepluginhub darkroomengineering/cc-settings --plugin darkroomGuides writing React hooks with conventions for object returns, SSR safety, state design, effect patterns, cleanup, TypeScript, and performance.
Guides extracting shared stateful logic into custom hooks for React components. Useful when multiple components reuse data fetching, form state, or media query logic.
Provides React hooks reference with syntax, patterns for useState/useReducer state, useEffect side effects/cleanup, useRef/useContext, useMemo/useCallback optimization, React 19 hooks, custom hooks, and best practices.