
React Component Architecture
Install this when you want reusable React + TypeScript component patterns, hooks, and composition rules for a maintainable UI layer.
Overview
react-component-architecture is an agent skill for the Build phase that designs scalable React components with hooks, composition, and TypeScript.
Install
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill react-component-architectureWhat is this skill?
- Functional components with TypeScript props for variants, sizes, and disabled states
- Composition patterns and custom hooks for scalable libraries and large apps
- Quick-start Button example with variant and size style maps
- Reference guides for performance optimization and reusable UI patterns
- Explicit When to Use list: libraries, large-scale apps, hooks, and perf work
Adoption & trust: 520 installs on skills.sh; 251 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your React codebase is a pile of one-off components with inconsistent props and no pattern for reuse or hooks.
Who is it for?
Solo builders starting a component library or refactoring a React app that has outgrown copy-paste JSX.
Skip if: Non-React stacks, pure CSS-only pages, or teams that already enforce a complete design-system package with frozen APIs.
When should I use this skill?
Building reusable component libraries, large-scale React applications, custom hooks, or performance-focused UI refactors.
What do I get? / Deliverables
You get typed, composable component and hook patterns the agent can follow when adding or refactoring UI modules.
- Typed component modules following documented patterns
- Hook and composition structures aligned to reference guides
Recommended Skills
Journey fit
Component architecture guidance belongs on the Build shelf because it shapes how you structure UI code before ship-ready polish and tests. Content targets functional components, props typing, variants, and hooks—core frontend implementation, not backend APIs or SEO.
How it compares
Skill package for UI structure conventions—not a component generator CLI or Storybook MCP integration.
Common Questions / FAQ
Who is react-component-architecture for?
Solo and indie developers building React and TypeScript products who want the agent to follow consistent component and hook patterns.
When should I use react-component-architecture?
During Build → frontend when designing a library, scaling a large app, adding custom hooks, or optimizing component performance.
Is react-component-architecture safe to install?
Check the Security Audits panel on this Prism page; the skill is instructional patterns and example code, not a remote service.
SKILL.md
READMESKILL.md - React Component Architecture
# React Component Architecture ## Table of Contents - [Overview](#overview) - [When to Use](#when-to-use) - [Quick Start](#quick-start) - [Reference Guides](#reference-guides) - [Best Practices](#best-practices) ## Overview Build scalable, maintainable React components using modern patterns including functional components, hooks, composition, and TypeScript for type safety. ## When to Use - Component library design - Large-scale React applications - Reusable UI patterns - Custom hooks development - Performance optimization ## Quick Start Minimal working example: ```typescript // Button.tsx import React, { useState, useCallback } from 'react'; interface ButtonProps { variant?: 'primary' | 'secondary' | 'danger'; size?: 'sm' | 'md' | 'lg'; disabled?: boolean; onClick?: () => void; children: React.ReactNode; } export const Button: React.FC<ButtonProps> = ({ variant = 'primary', size = 'md', disabled = false, onClick, children }) => { const variantStyles = { primary: 'bg-blue-500 hover:bg-blue-600', secondary: 'bg-gray-500 hover:bg-gray-600', danger: 'bg-red-500 hover:bg-red-600' }; const sizeStyles = { // ... (see reference guides for full implementation) ``` ## Reference Guides Detailed implementations in the `references/` directory: | Guide | Contents | |---|---| | [Functional Component with Hooks](references/functional-component-with-hooks.md) | Functional Component with Hooks | | [Custom Hooks Pattern](references/custom-hooks-pattern.md) | Custom Hooks Pattern | | [Composition Pattern](references/composition-pattern.md) | Composition Pattern | | [Higher-Order Component (HOC)](references/higher-order-component-hoc.md) | Higher-Order Component (HOC) | | [Render Props Pattern](references/render-props-pattern.md) | Render Props Pattern | ## Best Practices ### ✅ DO - Follow established patterns and conventions - Write clean, maintainable code - Add appropriate documentation - Test thoroughly before deploying ### ❌ DON'T - Skip testing or validation - Ignore error handling - Hard-code configuration values # Render Props Pattern ## Render Props Pattern ```typescript // DataFetcher.tsx interface DataFetcherProps<T> { url: string; children: (data: T | null, loading: boolean, error: Error | null) => React.ReactNode; } export const DataFetcher = <T,>({ url, children }: DataFetcherProps<T>) => { const [data, setData] = React.useState<T | null>(null); const [loading, setLoading] = React.useState(true); const [error, setError] = React.useState<Error | null>(null); React.useEffect(() => { fetch(url) .then(r => r.json()) .then(setData) .catch(setError) .finally(() => setLoading(false)); }, [url]); return <>{children(data, loading, error)}</>; }; // Usage <DataFetcher<User[]> url="/api/users"> {(users, loading, error) => ( <>{loading ? <p>Loading...</p> : users?.map(u => <p key={u.id}>{u.name}</p>)}</> )} </DataFetcher> ``` // Component: [Name] // TODO: Customize for your framework (React, Vue, Svelte, etc.) import React from 'react'; interface Props { // TODO: Define props } export function ComponentName({ }: Props) { // TODO: Add state and effects return ( <div> {/* TODO: Add component markup */} </div> ); } # Higher-Order Component (HOC) ## Higher-Order Component (HOC) ```typescript // withLoader.tsx interface WithLoaderProps { isLoading: boolean; error?: Error | null; } function withLoader<P extends object>( Component: React.ComponentType<P> ): React.FC<P & WithLoaderProps> { return ({ isLoading, error, ...props }: P & WithLoaderProps) => { if (isLoading) return <div>Loading...</div>; if (error) return <div className="text-red-500"