Reactprinciples hook
Skill sindev08/react-principles-skills/skills/reactprinciples-hook
Claude/Cursor/AI skills for React Principles cookbook patterns
npx -y skills add sindev08/react-principles-skills --skill reactprinciples-hookAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Scaffold a custom React hook following React Principles custom-hooks recipe. Invoke when the user says "create a custom hook", "scaffold a hook", or asks for a hook to encapsulate logic. Generates the hook file with proper naming (use prefix), TypeScript types, a stable return shape, and a colocated test file. Places the hook in src/shared/hooks/ for cross-feature use or src/features/<x>/hooks/ for feature-specific.
SKILL.md
3.9 KB, as published. Nobody here has run it
React Principles — Custom Hook Scaffold
You scaffold a custom React hook following the Custom Hooks recipe.
Step 0 — Load the live recipe (required)
Do this before anything else. The cookbook is the single source of truth and changes over time — never scaffold from memory or from the fallback summary below while the live recipe is reachable.
- If the
reactprinciplesMCP server is available, call itsget_recipetool with slugcustom-hooks. - Otherwise fetch: https://www.reactprinciples.dev/cookbook/custom-hooks/llms.txt
The fetched recipe contains the naming, return-shape, and testing rules plus canonical pattern code — treat its rules as requirements, not suggestions. If both sources are unreachable (offline), use the fallback summary at the bottom of this file and tell the user you are working from a potentially outdated summary.
When to invoke
- User asks to "create a custom hook called X"
- User asks to "extract logic into a hook"
- User asks for
useDebounce-style scaffolding
Inputs needed
Ask the user for:
- Hook name — camelCase, must start with
use(e.g.,useDebounce,useMediaQuery) - What it does — brief description, used for inline doc comment
- Inputs (optional) — parameters the hook takes (with types)
- Return shape — single value, object, or tuple? If unclear, default to an object for >1 return value
- Location:
src/shared/hooks/if reusable across features (default for utility hooks like debounce, media query)src/features/<feature>/hooks/if specific to one feature
What to read first
Read an existing hook and its test in the user's project for reference:
src/shared/hooks/useDebounce.ts
src/shared/hooks/useDebounce.test.ts
Match the conventions you find.
How to scaffold
Derive the hook and its colocated test from the pattern code in the recipe you fetched in Step 0, shaped to match the existing hook you read. The test should verify the simplest happy path — don't generate exhaustive tests; leave that to the user.
Route away when a more specific skill applies:
- React Query hooks →
reactprinciples-query - Zustand store hooks →
reactprinciples-store - Form hooks →
reactprinciples-form
After generating
Tell the user:
- The file paths created (hook + test)
- Import path:
import { use<Name> } from "@/shared/hooks"(or feature path) - Whether to add the hook to a barrel
index.ts - A reminder to run the test:
pnpm test use<Name>
What you should NOT do
- Don't generate hooks that wrap a single React API one-to-one without adding value (e.g., a hook that just calls
useState) - Don't put hooks in
src/features/<x>/components/— hooks belong in ahooks/folder - Don't import the hook from outside its feature using relative paths — always use
@/alias
Fallback summary (only if Step 0 fails)
May be outdated — the live recipe always wins.
- Name starts with
use, camelCase; only called from components or other hooks - Stable return shape: single value,
[value, setter] as consttuple, or a named object for 2+ values — never more than 4 - Colocate a
*.test.tsusingrenderHookfrom Testing Library - Document with a one-line JSDoc +
@example
Reference
See Custom Hooks recipe and existing hooks in src/shared/hooks/.
Gives 0 of the 12 instructions most skill authoring skills give
Counted across 521 of the 523 authors here whose files we hold, read 2026-08-06
- keep skill files under 500 linesin 182 of 521, across 89 files
- use imperative form in instructionsin 101 of 521, across 30 files
- draft assertions while test runs are in progressin 88 of 521, across 22 files
- save test cases to evals jsonin 87 of 521, across 21 files
- create two to three realistic test promptsin 85 of 521, across 20 files
- write skill descriptions to be pushyin 84 of 521, across 19 files
- ask questions about edge cases and input formatsin 81 of 521, across 16 files
- save timing data immediately when runs completein 74 of 521, across 9 files
- include all trigger conditions in the skill descriptionin 73 of 521, across 7 files
- capture intent before writing a skillin 70 of 521, across 4 files
- launch all test runs in a single turnin 68 of 521, across 2 files
- write the description in third personin 56 of 521, across 19 files
Said here and by no other author read
- fetch the live recipe before scaffolding
- call get_recipe with slug custom-hooks if MCP is available
- ask the user for the hook name and inputs
- default utility hooks to the shared hooks directory
- place feature-specific hooks in the features directory
- read an existing hook and its test for conventions
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.