new-hook

A guide for creating a new React hook in the @reactuses/core package. A React hook is a reusable piece of code that adds behavior or state to a component.

In plain words
What is it for?
Use it when adding a hook, checking whether a similar hook already exists, and connecting the implementation, types, documentation, and tests.
Why use it?
It helps a new hook match the repository's file layout, browser and server behavior, documentation style, and public exports.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/childrentime/reactuse/new-hook
Any agent
npx skills add childrentime/reactuse --skill new-hook
Clone the repo
git clone --depth 1 https://github.com/childrentime/reactuse

Made for: Claude Code, Codex.

Per session 82 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,137 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00082 $0.01137
Opus 5 $0.00041 $0.00568
Sonnet 5 $0.00016 $0.00227
Haiku 4.5 $0.00008 $0.00114

Measured 2d ago against content hash 35ddc8e59129, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

new-hook scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/new-hook/SKILL.md · 110 lines

How it starts

The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.

new-hook — scaffold a hook the ReactUse way

Use this when adding a new hook to @reactuses/core. It encodes how hooks are actually built in this repo today. Pair it with hook-test and hook-docs afterward.

There is no scaffolding script — hooks are created by hand. Follow the steps below.

Step 0 — Understand before writing (don't skip)

  1. Confirm the hook doesn't already exist: ls packages/core/src/useX.
  2. Read 1-2 similar existing hooks end to end (not just their names) to match style — e.g. a state hook like useCounter, a browser hook like useClipboard, an element hook like useEventListener. Note their return shape and which utils they reuse.
  3. Check the knowledge base reuse cheat-sheet — much of what you need (useLatest, useUnmount, useEventListener, defaultWindow, isBrowser) is already written. Reuse before writing.

Step 1 — Create the hook folder

packages/core/src/useX/ with two (then three) files:

  • index.ts — the implementation, named export export const useX: UseX = ….
  • interface.ts — the public type UseX with multilingual JSDoc.
  • index.spec.ts — tests (hand off to the hook-test skill).

interface.ts template

Types live here (not inline), so the API-doc generator can read them. JSDoc is trilingual:

/**
 * @title useX
 * @returns_en What the hook returns, described for docs.
 * @returns 返回值说明(简体)。
 * @returns_zh-Hant 返回值說明(繁體)。
 */
export type UseX = (
  /**
   * @en The first argument, described.
   * @zh 第一个参数说明。
   * @zh-Hant 第一個參數說明。
   * @defaultValue 0
   */
  initial?: number,
) => readonly [number, (n: number) => void]

(See packages/core/src/useCounter/interface.ts for a full real example.)

index.ts template

import { useState, useCallback } from 'react'
import { isDev, isFunction } from '../utils/is'
import type { UseX } from './interface'

export const useX: UseX = (initial = 0) => {
  if (isDev && initial != null && !isFunction(initial) && typeof initial !== 'number') {
    console.error(`useX: \`initial\` expected number, got "${typeof initial}".`)
  }

  const [value, setValue] = useState(initial)
  const set = useCallback((n: number) => setValue(n), [])

  return [value, set] as const
}

Read the full file on GitHub · 110 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 110 lines · 82 tokens per session scan A 35ddc8e59129

Subscribe to this mod's changes

new-hook is a skill published in the GitHub repository childrentime/reactuse (1,048 stars, last pushed 12d ago), licensed Unlicense. It adds 82 tokens to every session and 1,137 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

fluencyloop

FluencyLoop — stay fluent in code as AI writes it. Router/overview for the per-feature loop (design → build+teach → review), the optional up-front planning stage for large chunks, the woven-in constitution that grows from decisions, plus post-merge backfill. Use when the user mentions FluencyLoop, "fluency", the…

baokhang83/fluencyloop · 98 tokens

react-hooks-composition

Advanced React hooks composition patterns - SWR integration, debounced search, memoized contexts, state machines, and performance optimization.

bobmatnyc/claude-mpm-skills · 29 tokens

migrate-radix-to-base

Migrates React projects and components from Radix UI to Base UI. Use when asked to migrate from radix, move to base-ui, convert radix primitives, or switch a shadcn project's base library. Handles single components ("migrate accordion") and whole projects.

shadcn-ui/ui · 61 tokens

flags

How to add or modify Next.js experimental feature flags end-to-end. Use when editing config-shared.ts, config-schema.ts, define-env-plugin.ts, next-server.ts, export/worker.ts, or module.compiled.js. Covers type declaration, zod schema, build-time injection, runtime env plumbing, and the decision between runtime…

vercel/next.js · 77 tokens

openspec-update-change

Update an OpenSpec change by revising its existing planning artifacts and keeping them coherent with one another. Use when the user wants to revise a change's plan, fold new decisions into it, or reconcile its artifacts after an edit. Never edits code.

Fission-AI/OpenSpec · 55 tokens

openspec-verify-change

Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving.

Fission-AI/OpenSpec · 32 tokens