Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Custom Hook

ASecurity

비대한 커스텀 훅을 스코프별 서브 훅으로 분리, composer 패턴 적용, 전용 서브디렉토리 구조화

14 stars
0 votes
0 copies
0 views
Added 9/26/2026
developmentreactapi

Works with

api

Security Analysis

A100/100

Scanned 9/26/2026

$npx -y skills add OU9999/codex-webtoon --skill custom-hook --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Custom Hook?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Custom Hook
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ou9999-custom-hook-codex-webtoon/badge)](https://www.skillsdirectory.com/skills/ou9999-custom-hook-codex-webtoon)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: custom-hook
description: 비대한 커스텀 훅을 스코프별 서브 훅으로 분리, composer 패턴 적용, 전용 서브디렉토리 구조화
triggers:
  - custom-hook
  - 훅 분리
  - 커스텀훅 분리
  - split hook
argument-hint: "<hook-file-path>"
quality: high
---

# Custom Hook

비대한 커스텀 훅 로직의 스코프별 서브 훅 분리와 composer 훅 조합 구조 리팩터.

## When to Activate

- 단일 커스텀 훅이 여러 관심사(상태 머신, API 호출, 이펙트, 인증 등)를 포함할 때
- 훅 내부에 독립적으로 테스트/재사용 가능한 로직 덩어리가 보일 때
- `$ARGUMENTS`로 대상 훅 파일 경로가 주어질 때

## Workflow

### 1단계: 분석

1. 대상 훅 파일 읽기
2. 해당 훅의 사용처 Grep 파악
3. 내부 로직의 관심사 식별:
   - 상태 머신 (useState + 전이 함수)
   - API 호출 (fetch 함수 + 결과 처리)
   - 사이드 이펙트 (useEffect)
   - 외부 훅 래핑 (인증, 라우터 등)

### 2단계: 분리 설계

1. 각 관심사를 독립된 서브 훅으로 매핑:
   - 상태 머신 → `use-[name]-state.ts`
   - 인증/외부 서비스 래핑 → `use-[name]-auth.ts` 등
   - 사이드 이펙트 → `use-[name]-callback.ts` 등
2. 여러 관심사를 동시에 건드리는 글루 함수는 composer에 유지
3. 단순 `useState(false)` 수준 상태 분리 금지 — 의미 있는 스코프만 추출

### 3단계: 서브 훅 생성

1. 의존성 없는 서브 훅부터 생성 (leaf → root 순서)
2. 서브 훅 단일 책임:
   - 상태 훅: 상태 + 전이 함수만 반환
   - 이펙트 훅: 콜백 파라미터로 외부 의존성 주입, 반환값 없음
   - 래핑 훅: 외부 훅 + 관련 핸들러 묶어서 반환
3. 순수 async 함수(API 호출 등)는 일반 함수로 유지, composer 파일에 co-locate

### 4단계: Composer 훅 리팩터

1. composer 훅은 서브 훅 조합과 글루 로직만 포함:
   ```ts
   const useComposer = (params) => {
     const state = useSubState(params);
     const auth = useSubAuth();
     useSubCallback({ onSuccess: ... });

     // 글루 로직: 여러 스코프를 연결하는 함수
     const handleResult = (result) => { ... };

     return { ...state, ...auth, handleResult };
   };
   ```
2. 서브 훅으로 이동한 import 정리
3. 타입/인터페이스는 사용 파일에 co-locate

### 5단계: 디렉토리 구조화

1. 컴포넌트 서브디렉토리 내부 훅은 `_hooks/` 폴더에 배치:
   ```
   component/
     _hooks/
       use-action.ts
   ```
2. composer 훅 전용 서브 훅은 동명 서브디렉토리로 이동:
   ```
   _hooks/
     use-hero-action.ts
     use-hero-action/
       use-card-state.ts
       use-hero-auth.ts
       use-rso-callback.ts
   ```
3. 다른 곳에서도 사용되는 범용 훅은 `@/hooks/`에 유지
4. import 경로 업데이트

### 6단계: 검증

1. `pnpm build` 성공 확인
2. `pnpm lint` 통과 확인
3. 기존 동작 변경 없음 확인

## Constraints

- `useMemo`, `useCallback` 사용 금지 (React Compiler 환경)
- 프로젝트 코드 규칙 준수 (CLAUDE.md 참조): arrow function, named export, async/await 등
- 이펙트 훅의 JSDoc 설명 필수
- 글루 함수(여러 스코프를 건드리는 함수)는 composer에 유지 — 억지 분리 금지
- 단순 boolean 토글 등 trivial 상태의 별도 훅 분리 금지

## Success Criteria

- composer 훅의 서브 훅 호출 + 글루 로직만 포함
- 각 서브 훅의 단일 책임
- 전용 서브 훅의 하위 디렉토리 격리
- 빌드/린트 통과
- 기존 동작 변경 없음

Attribution

OU9999OU9999
View sourceSee grades on GitHubMore from OU9999 →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Clean Code

Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

304955 votes

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

286712 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Writing Plans

Use when you have a spec or requirements for a multi-step task, before touching code

2927051 votes
View all in development →