narrow-react-prop-types
하는 일
이 스킬은 스토리나 테스트 데이터만을 위해 있는 선택적 프롭을 제거하도록 AI 에이전트를 안내합니다. 엄격하고 정확한 컴포넌트 타입을 원하는 React 개발자를 위한 스킬입니다.
사용하는 경우
- ✓스토리나 테스트를 지원하려고 컴포넌트 프롭이 넓어지고 선택적으로 바뀌었을 때.
- ✓실제 앱에서 쓰지 않는 상태를 없애고 싶을 때.
- ✓라이브 코드에서 파생된 타입을 얻고 싶은 React 타입 리팩터링이 있는 경우.
스킬 링크
https://github.com/humanlayer/humanlayer/blob/main/.claude/skills/narrow-react-prop-types/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“이 React 카드 컴포넌트에는 선택적 프롭이 너무 많아요. 실제 앱이 쓰는 것으로 타입을 좁혀 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 타입을 바꾸기 전에 실제 테스트가 아닌 호출 위치를 먼저 찾습니다. 그다음 타입을 그 호출 위치에 맞추고, 테스트와 스토리 코드를 더 엄격한 타입에 맞게 업데이트합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Narrow React Prop Types
Use this skill when a React component's props have been widened for stories, mocks, tests, or demos and now express states the live application does not enter.
The goal is to make component types describe the real live-code-path contract, then require stories/tests/mocks to adapt to that contract instead of weakening it.
Core Requirements
- Find the actual non-test, non-Storybook call sites before changing types.
- Treat live code paths as the source of truth for the prop contract.
- Do not preserve optional props only because they make Storybook, tests, or mock data easier.
- Keep props optional only when there are non-Storybook, non-test call sites which do not provide them and which have a good reason for not doing so.
- Types should not enable expressing states which are not observed in non-test, non-Storybook call sites.
- Types should be as strict as possible so code can be as simple as possible.
- Prefer deriving and extracting types from existing live-code-path values and APIs where possible.
Workflow
1. Identify the suspect component
Look for components with these signals:
- Large props interfaces with many optional fields.
- Optional callback calls such as
onSelect?.(...)oronArchive?.(...). - Fallback state handling such as
items ?? [],count ?? 0, orhandler && ...around values live code likely always supplies. - UI affordances that always render even though their callbacks are optional.
- Props that look demo-oriented, such as
defaultFoo, alternate handler shapes, or display toggles not used by live code.
Do not pick a target from a story or test alone. Use stories/tests only as supporting evidence that the type has been widened, not as evidence that a state is real.
2. Find every live usage
Search for all imports/usages of the component, exported prop type, and shared child primitives.
Classify call sites by whether they are live code paths or support code:
- Live code paths: app routes, wired components, providers, hooks, production package exports, and shared components used by those paths.
- Support code: Storybook stories, test files, fixtures, mocks, demo harnesses, and visual-only examples.
Only live code paths should determine what the component API supports.
3. Derive the real types from the live code paths
Read the live call sites and classify each prop:
- Required: every non-test, non-Storybook call site supplies it.
- Optional: at least one non-test, non-Storybook call site omits it and that omission is a meaningful runtime state.
- Removed: no non-test, non-Storybook call site uses it.
Nullability and optionality are different. If live code always passes a prop but the value can be empty, prefer a required nullable prop such as focusedItem: FocusedItem | null over focusedItem?: FocusedItem | null.
4. Tighten the public prop type
Update exported prop types to match only the states observed in live code paths.
The looser and more optional a type is, the more possible states the component has to reason about. Every optional prop creates another branch the component must handle, test, and keep correct. Prefer strict types that prevent impossible states instead of broad types that require defensive render logic.
If the component always renders an interactive affordance, require the handler that makes it work. Do not allow inert states like a visible menu item that calls onRename?.(...).
5. Derive and extract types where possible
Prefer deriving types from the live APIs instead of restating them manually:
Parameters<typeof fn>[0]for function argument types.ReturnType<typeof fn>for return types.Extract<Union, Shape>for narrowing a union to a real variant.React.Dispatch<React.SetStateAction<T>>for React state setters instead of approximating them as(value: T) => void.
Prefer explicit state type parameters when inference would widen or obscure the intended state shape:
const [dialogState, setDialogState] = useState<DialogState>({
id: null,
isOpen: false,
})
Avoid relying on implicit useState(...) inference when it produces broad nullable object shapes, string literal widening, or callback types that later need hand-written approximations.
6. Tighten internal child props too
Do not stop at the exported component if it passes broad props into child primitives.
If row/menu/button child components receive optional handlers only because the parent props were
자주 묻는 질문
테스트가 깨지나요?
테스트와 스토리를 업데이트해야 할 수 있으며, 스킬은 타입을 느슨하게 하지 않고 더 엄격한 타입에 맞춥니다.
타입을 바꾸기 전에 실제 앱을 확인하나요?
네. 변경하기 전에 실제 테스트가 아닌 호출 위치를 찾습니다.
일부 프롭은 선택적으로 남을 수 있나요?
네. 다만 실제 호출 위치가 그 값을 제공하지 않고 타당한 이유가 있을 때만입니다.
상세 정보
인기도
- GitHub 스타
- 13k
- 순위
- #11388
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 10. 31.
댓글
- …
이 저장소의 다른 스킬
asd-ste100
13k혼동되는 영어를 짧고 뜻이 하나뿐인 문장으로 다시 써서, 사람과 다른 소프트웨어가 쉽게 읽을 수 있게 하도록 에이전트를 가르칩니다.
better-github-skill
13k풀 리퀘스트 상태를 확인하고, 리뷰 댓글을 읽고, 준비된 GitHub 스크립트로 CI 빌드가 실패한 이유를 찾도록 에이전트를 돕습니다.
calldiff
13k두 git 버전 사이 코드베이스의 함수 호출 체인을 비교해, 코드 리뷰에서 어떤 동작이 바뀌었는지 볼 수 있도록 에이전트를 돕습니다.
chrome-devtools-cli
13k에이전트가 터미널에서 Chrome을 제어해 페이지를 열고, 클릭하고, 양식을 채우고, 페이지 스냅숏을 찍어 브라우저 자동화와 테스트를 하도록 돕습니다.
비슷한 스킬
angular-developer
280k에이전트가 Angular 코드를 만들고 프로젝트 구조를 조언하도록 돕습니다. 새 프로젝트 시작, 코드 부분 생성, 성능과 접근성 개선에 유용합니다.
frontend-a11y
280k모든 사람이 웹 인터페이스를 쓸 수 있도록 에이전트를 돕습니다. 웹사이트와 앱이 화면 읽기 프로그램과 키보드 탐색에서 잘 작동하도록 합니다.
frontend-patterns
280k프론트엔드 개발의 현대적인 패턴을 적용하도록 에이전트를 돕습니다. React와 Next.js에서 성능을 최적화하고, 상태를 관리하며, 모범 사례를 따릅니다.