narrow-react-prop-types
O que ela faz
Ele orienta o agente de IA a remover props opcionais que existem só para dados de teste ou de stories. É para desenvolvedores React que querem tipos de componente estritos e precisos.
Quando usar
- ✓Quando as props de um componente ficaram largas e opcionais só para dar suporte a stories ou testes.
- ✓Quando você quer remover estados que o app real nunca usa.
- ✓Quando você está refatorando tipos React e quer que eles sejam derivados do código em produção.
Link da skill
https://github.com/humanlayer/humanlayer/blob/main/.claude/skills/narrow-react-prop-types/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Este componente de card em React tem props opcionais demais. Aperte os tipos para o que o app real usa.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente primeiro encontra as chamadas reais fora de testes e depois ajusta os tipos para combinarem com elas. Em seguida, o código de teste e de stories é atualizado para caber nos tipos mais estritos.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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
Perguntas frequentes
Ele vai quebrar meus testes?
Testes e stories podem precisar de ajustes, pois a skill os adapta aos tipos mais estritos em vez de enfraquecer os tipos.
Ele verifica o app real primeiro?
Sim. Ele encontra as chamadas reais fora de testes antes de mudar qualquer tipo.
Algumas props podem continuar opcionais?
Sim, mas só quando nenhuma chamada real as fornece e há um bom motivo.
Detalhes
Descrição original do autor
narrow React component prop types to match live code paths
repo: humanlayer/humanlayer
Popularidade
- Estrelas no GitHub
- 13 mil
- Posição no ranking
- #11388
- Licença
- Apache-2.0
- Atualizada em
- 31/10/2026
Comentários
- …
Mais skills deste repositório
asd-ste100
13 milEnsina seu agente a reescrever textos confusos em inglês, usando frases curtas e com um único sentido, fáceis de ler para pessoas e outros softwares.
better-github-skill
13 milAjuda seu agente a checar o status de um pull request, ler os comentários de revisão e descobrir por que um build de CI falhou, com scripts prontos do GitHub.
calldiff
13 milAjuda seu agente a comparar as cadeias de chamadas de funções em um código entre duas versões do git, para que a revisão veja o que mudou no comportamento.
chrome-devtools-cli
13 milPermite que seu agente controle o Chrome pelo terminal para abrir páginas, clicar, preencher formulários e tirar capturas da página, para automação e testes de navegador.
Skills parecidas
angular-developer
280 milAjuda seu agente a criar código Angular e a dar conselhos sobre a estrutura do projeto. É útil para iniciar novos projetos, criar partes do código ou melhorar a performance e acessibilidade.
frontend-a11y
280 milAjuda seu agente a tornar interfaces web acessíveis para todos. Ele garante que sites e apps funcionem bem com leitores de tela e navegação por teclado.
frontend-patterns
280 milFaz seu agente aplicar padrões modernos no desenvolvimento frontend. Ele otimiza performance, gerencia estado e segue boas práticas em React e Next.js.