Agent skill

Tsh Writing Hooks

by TheSoftwareHouse in TheSoftwareHouse/copilot-collections

Custom hook and composable patterns — naming, composition, stable return shapes, lifecycle cleanup, and testing strategies.

MITAuto-check passedDevelopment

Install Tsh Writing Hooks

skills CLI
$ npx skills add TheSoftwareHouse/copilot-collections --skill tsh-writing-hooks -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install TheSoftwareHouse/copilot-collections tsh-writing-hooks --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/TheSoftwareHouse/copilot-collections.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/skills/tsh-writing-hooks .claude/skills/tsh-writing-hooks && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
tsh-writing-hooks
GitHub stars
284
Token cost
~3k tokens
SKILL.md length
983 words
Files
2 (incl. references)
Skills in repo
21
Repo updated
First seen
Licence
MIT

At a glance

Custom hook and composable patterns — naming, composition, stable return shapes, lifecycle cleanup, and testing strategies.

  • Works in 4 steps: Initial state — Verify the hook returns… → State transitions — Trigger actions and… → Effect cleanup — Unmount the hook and… → …
  • Writing reusable logic units (React hooks
  • SKILL.md covers Hook Development Process, Return Shape Guidelines, Anti-Patterns and Hook Quality Checklist, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Tsh Writing Hooks is an agent skill from TheSoftwareHouse/copilot-collections. Custom hook and composable patterns — naming, composition, stable return shapes, lifecycle cleanup, and testing strategies. Use when writing reusable logic units (React hooks, Vue composables), refactoring logic into hooks, debugging hook behavior, or reviewing hook implementations.

Its SKILL.md is about 3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/react-patterns.md`).

It sits in Development, covering React components, Test strategy and Hooks and plugins. It works with React and Vue.js. The repository describes itself as: Opinionated AI-enabled workflows for product engineering. The licence is MIT.

When your agent uses it

  • Writing reusable logic units (React hooks
  • Vue composables)
  • Refactoring logic into hooks
  • Debugging hook behavior

Example prompts

  • “/tsh-writing-hooks”

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Initial state — Verify the hook returns the expected default values on first render.
  2. State transitions — Trigger actions and assert the return value updates correctly.
  3. Effect cleanup — Unmount the hook and verify all resources are released (timers cleared, listeners removed, subscriptions cancelled).
  4. Error states — Simulate failures and verify the hook surfaces errors via its return value.

What it can do on your machine

Read from SKILL.md and the folder at commit 2fbe51e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Tsh Writing Hooks loads about 3k tokens when it runs, and up to ~4.3k if it reads all its reference files. Until then it costs about 75 tokens; SKILL.md has 983 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~75
When it runs · the whole SKILL.md, loaded when a task matches
~3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from TheSoftwareHouse/copilot-collections at commit 2fbe51e, republished under its MIT licence (© TheSoftwareHouse). 983 words, ~2,969 tokens.

Download SKILL.mdSave it as .claude/skills/tsh-writing-hooks/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
tsh-writing-hooks
description
Custom hook and composable patterns — naming, composition, stable return shapes, lifecycle cleanup, and testing strategies. Use when writing reusable logic units (React hooks, Vue composables), refactoring logic into hooks, debugging hook behavior, or reviewing hook implementations.
user-invocable
false

Writing Hooks

Provides patterns for writing composable, testable custom hooks with stable APIs, proper effect lifecycle management, and clear responsibility boundaries.

This skill uses "hook" to refer to any reusable, composable logic unit — React hooks, Vue composables, or equivalent framework abstractions. Adapt naming conventions and specific APIs to the project's framework.

<principles>
<single-responsibility>
Each hook does one thing. Compose complex behavior by calling multiple hooks, not by adding optional parameters to a single hook. A hook with 5+ configuration options is a sign it needs decomposition.
</single-responsibility>
<stable-api-surface>
Prefer returning an object (rather than a tuple) once the hook returns more than 1–2 values, and keep references stable. Memoize callbacks and derived values using the framework's memoization primitives when consumers may pass them to memoized children. The hook's return shape is its public API — treat it as a contract.
</stable-api-surface>
<cleanup-everything>
Every subscription, timer, event listener, or async operation created in an effect must have a corresponding cleanup. Leaked resources cause memory leaks and stale state bugs that are hard to diagnose.
</cleanup-everything>
</principles>

Hook Development Process

Use the checklist below and track progress:

Progress:
- [ ] Step 1: Define the hook's contract
- [ ] Step 2: Classify the hook tier
- [ ] Step 3: Implement with lifecycle discipline
- [ ] Step 4: Test the hook

Step 1: Define the hook's contract

Define the hook's public API before writing implementation code.

Naming: Follow the project's framework convention for reusable logic units. In React and Vue, the convention is use prefix + descriptive verb or noun. The name reflects behavior, not implementation details.

PatternExampleUse case
use + nounuseDebounce, useMediaQueryReturns a derived or observed value
use + verbuseToggle, useFetchReturns value + action(s)
use + domainuseAuth, useCartDomain-specific composition hook

Good: useLocalStorage — describes what it does. Bad: useBrowserEffect — describes how it works.

Inputs: Prefer a single options object when the hook accepts 3+ parameters. This makes the API extensible without breaking existing call sites.

typescript
// Prefer — single options object
const useDebounce = ({ value, delay, leading }: UseDebounceOptions) => {
  // ...
};

// Avoid — positional args are fragile past 2 params
const useDebounce = (value: string, delay: number, leading?: boolean) => {
  // ...
};

Outputs: Return an object with clear field names. Document what the hook returns and when it triggers effects.

typescript
interface UseAsyncReturn<T> {
  data: T | undefined;
  error: Error | null;
  isPending: boolean;
  refetch: () => void;
}

Step 2: Classify the hook tier

Determine where the hook fits in the dependency hierarchy. This classification constrains what a hook may depend on and prevents circular or inappropriate coupling.

TierNameScopeDependenciesExamples
AtomUI hooksLocal state, DOM events, media queries, keyboardNo remote data. No data-fetching libraries.useToggle, useMediaQuery, useKeyPress
MoleculeCoordination hooksCompose atom hooks with light coordination logicOther atom hooks only. No remote data.useFormField, usePagination
OrganismData hooksWrap data-fetching/mutation libraries. Domain logic.May call UI hooks internally. Interact with server cache.useUserProfile, useSearchResults

Rules:

  • Atom hooks must never import data-fetching or state management libraries.
  • Molecule hooks compose atoms — they do not call data hooks.
  • Organism hooks may call any tier but are the only tier that touches remote data.

Composability example — molecule hook composing atoms:

typescript
// Atom: single-purpose, no data fetching
const useDebounce = (value: string, delay: number) => {
  /* ... */
};
const useLocalStorage = <T>(key: string, initial: T) => {
  /* ... */
};

// Molecule: composes atoms into a higher-level behavior
const useDebouncedSearch = (storageKey: string) => {
  const { value, setValue } = useLocalStorage(storageKey, "");
  const debouncedValue = useDebounce(value, 300);
  return { query: value, setQuery: setValue, debouncedQuery: debouncedValue };
};

Step 3: Implement with lifecycle discipline

Follow these rules during implementation:

Call rules:

  • Call hooks/composables at the top level only — never inside conditions, loops, or nested functions.
  • Ensure all reactive dependencies are properly tracked — whether through explicit dependency arrays or automatic reactivity tracking, depending on the framework. Suppressing framework lint rules for dependency tracking is a last resort, not a shortcut.
  • Avoid object or array literals in dependency declarations — they create new identities every render/update cycle. Lift constants to module scope or memoize them.

Lifecycle cleanup — every effect that creates a resource must clean it up:

ResourceSetupRequired cleanup
TimersetTimeout(cb, delay)clearTimeout(id)
Event listeneraddEventListener(event, handler)removeEventListener(event, handler)
Async operationCancellable operation with AbortController signalcontroller.abort()
Subscriptionsource.subscribe(handler)subscription.unsubscribe()

The cleanup must execute when the hook unmounts or when dependencies change. See the framework reference for the exact cleanup syntax.

Error handling:

  • Don’t throw for expected runtime errors from the render/setup phase — surface those via the return value ({ error }).
  • It is acceptable to throw during render/setup for programmer errors (for example, a useX hook used outside its Provider) or when integrating with Error Boundaries / Suspense.
  • Catch async errors inside effects and store them in state.
Show full SKILL.md (343 more words)Show less

Conditional execution:

  • Data hooks should support an enabled flag to prevent wasteful operations when preconditions are not met.
typescript
const useUserProfile = ({ userId, enabled = true }: Options) => {
  // Skip data fetching when disabled — delegate to data fetching library's enabled/skip option
  // Return idle state: { data: undefined, isPending: false, error: null }
};

Step 4: Test the hook

Use the framework's hook/composable testing utility. Structure tests around four areas:

  1. Initial state — Verify the hook returns the expected default values on first render.
  2. State transitions — Trigger actions and assert the return value updates correctly.
  3. Effect cleanup — Unmount the hook and verify all resources are released (timers cleared, listeners removed, subscriptions cancelled).
  4. Error states — Simulate failures and verify the hook surfaces errors via its return value.

For data hooks: wrap the test in required providers (query client, context providers) and mock network responses.

For timer-dependent hooks: use fake timers to control time progression without real delays.

typescript
it("cleans up the timer on unmount", () => {
  // Enable fake timers (syntax varies by test runner)
  // Render the hook using the framework's testing utility
  // Unmount
  // Advance all pending timers — verify no leaked side effects
  // Restore real timers after test
});

Return Shape Guidelines

Return typeWhenExample
Single valueHook computes one thinguseDebounce(value, delay) → debouncedValue
ObjectMultiple related values or actions{ data, error, isPending, refetch }
Object (prefer over tuple)Readability and evolvability matter{ count, increment, decrement, reset }

Prefer objects over tuples for hooks returning more than one value. Objects are self-documenting, allow consumers to destructure only what they need, and evolve without breaking existing call sites.

Anti-Patterns

Anti-PatternInstead Do
Tuple return [value, setter] for complex hooksObject return { value, setValue, reset }
Effect with suppressed dependency trackingInclude all deps; restructure if cycle occurs
New object/array identity every renderMemoize or lift to module scope
Side effects in render phaseMove to lifecycle effect or event handler
Swallowing errors silentlyReturn { error } so consumer can handle
One mega-hook with 10 optionsCompose from smaller single-purpose hooks
Timer without cleanupAlways return () => clearTimeout(id)
Data hook without enabled flagSupport conditional fetching to avoid waste

Hook Quality Checklist

Hook:
- [ ] Name follows framework convention (e.g., `use` prefix), describes behavior (not implementation)
- [ ] Single responsibility — does one thing well
- [ ] Inputs: single options object for 3+ params
- [ ] Output: object with stable references (memoized where framework supports it)
- [ ] All dependency tracking complete — no linting suppression
- [ ] Effects clean up: timers, listeners, subscriptions, abort controllers
- [ ] Errors surfaced via return value, never thrown from render
- [ ] Tested: initial state, transitions, cleanup, error states

Framework-Specific Patterns

The patterns above are framework-agnostic. For framework-specific hook/composable syntax, load the appropriate reference:

  • React: See ./references/react-patterns.md — useEffect, useMemo, useCallback, dependency arrays, rules of hooks.

Connected Skills

  • tsh-implementing-frontend — hooks are used within components; this skill covers component patterns
  • tsh-optimizing-frontend — for memoization strategies and performance patterns in hooks
  • tsh-reviewing-frontend — for hook-specific code review criteria
  • tsh-implementing-forms — for form-related custom hooks (field state, validation triggers)

© TheSoftwareHouse, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in .github/skills/tsh-writing-hooks of TheSoftwareHouse/copilot-collections.

  • SKILL.md
  • references/react-patterns.md

Open the folder on GitHubat commit 2fbe51e

Compare with similar skills

Tsh Writing Hooks next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Tsh Writing Hooks compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Tsh Writing Hooks this skillTheSoftwareHouse/copilot-collections284—~3kAutomated safety check: PassMIT
No Use Effectmattiacerutti/supernova1852 repos~1.7kAutomated safety check: PassMIT
React Best Practicesshapeshift/web2061 repos~2kAutomated safety check: PassMIT
Migrate Componentasyncapi/generator1.1k—~3kAutomated safety check: PassApache-2.0
Project Form PatternsAkaraChen/aghub272—~1.1kAutomated safety check: PassMIT
React Refactor Tournamentragnar-pwninskjold/tech-snacks137—~1.3kAutomated safety check: PassMIT

Similar skills

  • No Use Effect

    mattiacerutti/supernova

    Enforce the no-useEffect rule when writing or reviewing React code.

    185 GitHub starsUsed in 2 repos~1.7k tokens
    DevelopmentAuto-check passed
  • React Best Practices

    shapeshift/web

    Comprehensive React and Next.js performance optimization guide with 40+ rules for eliminating waterfalls, optimizing bundles, and improving rendering.

    206 GitHub starsUsed in 1 repo~2k tokens
    DevelopmentAuto-check passed
  • Migrate Component

    asyncapi/generator

    Promote a duplicated React/JSX template-local component into the shared @asyncapi/generator-components package.

    1.1k GitHub stars~3k tokensUpdated today
    DevelopmentAuto-check passed
  • Project Form Patterns

    AkaraChen/aghub

    Form implementation guidance for the aghub desktop app. An agent skill from AkaraChen/aghub.

    272 GitHub stars~1.1k tokensUpdated 4 days ago
    DevelopmentAuto-check passed
  • React Refactor Tournament

    ragnar-pwninskjold/tech-snacks

    Review React/Next.js code against the real vercel-react-best-practices skill, backlog the performance findings keyed to actual rule ids + impact tiers, rank the most over-subscribed tiers, then fix…

    137 GitHub stars~1.3k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Omk Coding

    KaimingWan/oh-my-kiro

    Enforces coding best practices: deep-read before modify, LSP-first navigation, TDD red-green-refactor, minimal changes, self-review, verification.

    107 GitHub stars~2.4k tokensUpdated 6 mo ago
    DevelopmentAuto-check passed

More from TheSoftwareHouse/copilot-collections

All 21 skills in this repo
  • Tsh Creating Skills

    TheSoftwareHouse/copilot-collections

    Create new skills (SKILL.md) for GitHub Copilot. An agent skill from TheSoftwareHouse/copilot-collections.

    284 GitHub stars~4.1k tokensUpdated 4 days ago
    Auto-check passed
  • Tsh Implementing Frontend

    TheSoftwareHouse/copilot-collections

    Frontend component patterns, composition, design token integration, barrel file organization, error handling, and Figma-to-code workflow.

    284 GitHub stars~2.6k tokensUpdated 4 days ago
    Auto-check passed
  • Tsh Implementing Terraform Modules

    TheSoftwareHouse/copilot-collections

    Build reusable Terraform modules for AWS, Azure, and GCP infrastructure following infrastructure-as-code best practices.

    284 GitHub stars~1.6k tokensUpdated 4 days ago
    Auto-check passed
  • Tsh Optimizing Frontend

    TheSoftwareHouse/copilot-collections

    Frontend rendering optimization, code splitting, memoization strategies, bundle size control, asset optimization, and memory management.

    284 GitHub stars~4.1k tokensUpdated 4 days ago
    Auto-check passed
  • Tsh Reviewing Frontend

    TheSoftwareHouse/copilot-collections

    Frontend-specific code review criteria, component anti-patterns, hooks quality, rendering correctness, accessibility and performance spot-checks, and module organization issues.

    284 GitHub stars~4.4k tokensUpdated 4 days ago
    Auto-check passed
  • Tsh Creating Instructions

    TheSoftwareHouse/copilot-collections

    Creates custom instruction files (.instructions.md) for GitHub Copilot in VS Code.

    284 GitHub stars~2.9k tokensUpdated 4 days ago
    Auto-check passed

Works with

Categories

Questions about Tsh Writing Hooks

What does Tsh Writing Hooks do?

Custom hook and composable patterns — naming, composition, stable return shapes, lifecycle cleanup, and testing strategies. Tsh Writing Hooks is an agent skill from TheSoftwareHouse/copilot-collections. Custom hook and composable patterns — naming, composition, stable return shapes, lifecycle cleanup, and testing strategies.

When should I use Tsh Writing Hooks?

Tsh Writing Hooks fits situations like: writing reusable logic units (React hooks; vue composables); refactoring logic into hooks; debugging hook behavior.

How do I install Tsh Writing Hooks in Claude Code?

Run `npx skills add TheSoftwareHouse/copilot-collections --skill tsh-writing-hooks -a claude-code`. Or copy the skill folder (.github/skills/tsh-writing-hooks in TheSoftwareHouse/copilot-collections) into .claude/skills/tsh-writing-hooks in your project. Claude Code loads it when a task matches its description.

How do I install Tsh Writing Hooks in Codex?

Run `npx skills add TheSoftwareHouse/copilot-collections --skill tsh-writing-hooks -a codex`. Or copy the skill folder (.github/skills/tsh-writing-hooks in TheSoftwareHouse/copilot-collections) into .agents/skills/tsh-writing-hooks in your project. Codex loads it when a task matches its description.

Can I use Tsh Writing Hooks in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add TheSoftwareHouse/copilot-collections --skill tsh-writing-hooks -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/tsh-writing-hooks, .gemini/skills/tsh-writing-hooks, .github/skills/tsh-writing-hooks and .opencode/skills/tsh-writing-hooks in your project.

What does Tsh Writing Hooks need to run?

SKILL.md names no scripts, command-line tools or credentials: Tsh Writing Hooks is instructions for the agent only.

Does Tsh Writing Hooks access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Tsh Writing Hooks safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Tsh Writing Hooks use?

Tsh Writing Hooks is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Tsh Writing Hooks use?

About 3k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.4k tokens, read only when the agent opens those files.

What are the alternatives to Tsh Writing Hooks?

Skills that share tags, products or a category with Tsh Writing Hooks: No Use Effect (mattiacerutti/supernova, 185 stars), React Best Practices (shapeshift/web, 206 stars), Migrate Component (asyncapi/generator, 1.1k stars) and Project Form Patterns (AkaraChen/aghub, 272 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Tsh Writing Hooks?

TheSoftwareHouse (a GitHub organization) maintains it in TheSoftwareHouse/copilot-collections, which has 284 GitHub stars. The repository holds 21 skills in this directory. The repository was last updated on October 5, 2026.

Source: TheSoftwareHouse/copilot-collections on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.