narrow-react-prop-types
Qué hace
Guía al agente de IA para eliminar las props opcionales que existen solo para datos de pruebas o de historias. Está pensada para desarrolladores de React que quieren tipos de componente estrictos y precisos.
Cuándo usarla
- ✓Cuando las props de un componente se han vuelto demasiado amplias y opcionales solo para dar soporte a historias o pruebas.
- ✓Cuando quieres eliminar estados que la app real nunca usa.
- ✓Cuando estás refactorizando tipos de React y quieres que se deriven del código en vivo.
Link de la skill
https://github.com/humanlayer/humanlayer/blob/main/.claude/skills/narrow-react-prop-types/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Este componente de tarjeta de React tiene demasiadas props opcionales. Ajusta los tipos a lo que usa la app real.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
El agente busca primero los puntos de llamada reales que no son de prueba, y luego hace que los tipos coincidan con ellos. El código de pruebas e historias se actualiza para encajar con los tipos más estrictos.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de 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
Preguntas frecuentes
¿Romperá mis pruebas?
Las pruebas y las historias pueden necesitar actualizaciones, porque la habilidad las adapta a los tipos más estrictos en lugar de debilitar los tipos.
¿Comprueba primero la app real?
Sí. Encuentra los puntos de llamada reales que no son de prueba antes de cambiar cualquier tipo.
¿Algunas props pueden seguir siendo opcionales?
Sí, pero solo cuando ningún punto de llamada real la proporciona y hay una buena razón.
Detalles
Descripción original del autor
narrow React component prop types to match live code paths
repo: humanlayer/humanlayer
Popularidad
- Estrellas en GitHub
- 13 mil
- Posición en el ranking
- #11388
- Licencia
- Apache-2.0
- Actualizada
- 31/10/2026
Comentarios
- …
Más skills de este repositorio
asd-ste100
13 milEnseña a tu agente a reescribir inglés confuso en frases cortas de un solo significado, fáciles de leer para personas y para otros programas.
better-github-skill
13 milAyuda a tu agente a revisar el estado de una pull request, leer sus comentarios de revisión y averiguar por qué falló una compilación de CI, usando scripts de GitHub ya preparados.
calldiff
13 milAyuda a tu agente a comparar las cadenas de llamadas a funciones de un código entre dos versiones de git, para que una revisión de código vea qué comportamiento cambió.
chrome-devtools-cli
13 milPermite que tu agente controle Chrome desde la terminal para abrir páginas, hacer clic, rellenar formularios y tomar instantáneas de páginas, para automatizar y probar el navegador.
Skills parecidas
angular-developer
280 milAyuda a tu agente con código de Angular y la estructura del proyecto. Útil para empezar proyectos, crear partes de código o mejorar el rendimiento y la accesibilidad.
frontend-a11y
280 milAyuda a tu agente a hacer que las interfaces web sean accesibles para todos. Asegura que sitios y apps funcionen bien con lectores de pantalla y navegación por teclado.
frontend-patterns
280 milHace que tu agente aplique patrones modernos en desarrollo frontend. Optimiza el rendimiento, gestiona el estado y sigue buenas prácticas en React y Next.js.