react-component-design
Skill6 starsChanged 6 months agoMITView on GitHub
When building or refactoring React UI components to ensure reusability and maintainability.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- jaballer/react-claude-skillstheir own version, first seen Jun 23, 2026
- dkprog/claude-skillstheir own version, first seen Feb 18, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- dkprog/claude-skills★ 0same name
- jaballer/react-claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- caching-strategiesSkill
- event-driven-designSkill
- logging-observability-standardsSkill
- api-design-restSkill
- database-query-optimizationSkill
- error-handling-architectureSkill
- code-review-guidelinesSkill
- ci-cd-pipeline-architectureSkill
- debugging-strategiesSkill
- git-workflow-branchingSkill
- dom-security-hardeningSkill
- state-management-patternsSkill
- accessibility-ui-designSkill
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 6 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 50
Define the API: Write the TypeScript interface for props BEFORE the component body.
- Distinctive: line 51
Verify Props: Ensure props contain ONLY what the component needs—no unnecessary inherited types.
- Very specific: line 54
Apply Styles: Use CSS classes via className prop.
- Distinctive: line 59
MUST be a pure function: identical props = identical output
- Very specific: line 60
MUST export a strictly typed TypeScript interface named [ComponentName]Props
- Distinctive: line 61
MUST NOT exceed 150 lines per file (extract sub-components if larger)
- Very specific: line 62
MUST NOT use inline styles (style={{...}})
- Distinctive: line 63
MUST NOT drill props more than 2 levels deep
- Distinctive: line 64
MUST NOT fetch data directly (use hooks or parent component)
- Very specific: line 65
MUST support className prop for customization
- Very specific: line 103
No use of dangerouslySetInnerHTML (violates DOM Security Hardening)
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React Component Design
Purpose
React components MUST be pure, composable, and reusable abstractions. This skill enforces TypeScript-first design, separation of concerns, and deterministic rendering to ensure maintainable, testable UI code that works reliably across different contexts.
When to use
- Building a new UI element from scratch
- Refactoring a large, monolithic React component
- Extracting shared UI patterns into a component library
- Adding new features to an existing component hierarchy
- Preparing components for cross-team reuse
When NOT to use
- Styling implementation details (use DOM Security Hardening skill instead)
- State management architecture decisions (use State Management Patterns skill)
- Performance optimization via memo/useMemo (handle at call site, not in component)
Inputs required
- Existing React codebase with TypeScript
- Clear understanding of component's single responsibility
- Props interface definition (before implementation)
Workflow
- Define the API: Write the TypeScript interface for props BEFORE the component body. This clarifies the contract.
- Verify Props: Ensure props contain ONLY what the component needs—no unnecessary inherited types.
- Isolate Logic: Extract all complex state and side-effects into custom hooks (NEVER in component body).
- Render JSX: Build static JSX structure based solely on props and hook return values.
- Apply Styles: Use CSS classes via
classNameprop. NEVER use inlinestyle={{...}}. - Export Type: Export both the component AND its Props interface for consumers.
- Verify Size: Confirm file does NOT exceed 150 lines. If it does, extract sub-components.
Rules
- MUST be a pure function: identical props = identical output
- MUST export a strictly typed TypeScript interface named
[ComponentName]Props - MUST NOT exceed 150 lines per file (extract sub-components if larger)
- MUST NOT use inline styles (
style={{...}}) - MUST NOT drill props more than 2 levels deep
- MUST NOT fetch data directly (use hooks or parent component)
- MUST support
classNameprop for customization
Anti-patterns
- Prop Drilling: Passing props down more than 2 levels deep (use Context, composition, or compound components)
- Inline Styles: Using
style={{...}}objects instead of CSS classes - God Components: Handling data fetching, business logic, and UI rendering in one file
- State in Props: Copying prop values into local state with
useState(props.val) - Implicit Dependencies: Accessing globals or services without prop parameters
- Class Components: Using class components instead of functional components with hooks
Failure conditions
- Component file exceeds 200 lines
- Props interface is not exported
- Component performs side effects without useEffect
- More than 2 levels of prop drilling detected
Validation checklist
- Props interface is explicitly exported and named
[ComponentName]Props - Component is a pure function with no render-time side effects
- No inline
style={{...}}objects anywhere - No prop drilling beyond 2 levels
- File is ≤ 150 lines
- All complex logic is extracted to custom hooks
- Component supports
classNameprop for customization - TypeScript types are strict (no
any) - No direct API/data fetching in component body
Output format
- File count: 1 primary
.tsxfile (+ additional files if refactored) - Exports: One default export (component) + named export for Props interface
- Structure: Props interface → Component function → Export both
- Styling: CSS classes only, no inline styles
- Size: ≤ 150 lines per component file
Security considerations
- Components do NOT execute arbitrary user input; text content is always escaped
- Props are never used in DOM insertion without sanitization
- Event handlers are never created from strings or user input
- No use of
dangerouslySetInnerHTML(violates DOM Security Hardening)
Agent execution notes
- Agent MAY: Create new components, refactor large components, add TypeScript interfaces
- Agent MUST NEVER: Add inline styles, drill props beyond 2 levels, add data fetching to component
- Agent MUST ASK: Before exceeding 150 lines, before changing prop contracts
- Agent MUST VALIDATE: All TypeScript is strict, no prop drilling, component is pure functional
Example
❌ Anti-pattern (Prop drilling, inline styles, state mirroring):
// Bad: mirrors props, inline styles, multiple responsibilities
export const Modal = ({ title, onClose, userId, userName, isOpen }) => {
const [name, setName] = useState(userName); // ANTI-PATTERN: state from props
return (
<div style={{ position: 'fixed', top: 0 }} onClick={onClose}>
<h1>{title}</h1>
<input value={name} onChange={(e) => setName(e.target.value)} />
<UserProfile userId={userId} name={name} /> {/* 2 levels */}
</div>
);
};
export const UserProfile = ({ userId, name }) => {
return <UserBio userId={userId} name={name} />; {/* 3 levels: VIOLATION */}
};✅ Correct pattern (Pure, CSS classes, no drilling):
interface ModalProps {
title: string;
onClose: () => void;
isOpen: boolean;
children: React.ReactNode;
}
export const Modal = ({ title, onClose, isOpen, children }: ModalProps) => {
if (!isOpen) return null;
return (
<div className="modal-overlay" onClick={onClose}>
<div className="modal-content">
<h1>{title}</h1>
{children}
</div>
</div>
);
};
interface UserProfileProps {
userId: string;
}
export const UserProfile = ({ userId }: UserProfileProps) => {
const user = useUser(userId); // Use hook, not props
return (
<div>
<h2>{user?.name}</h2>
<p>{user?.bio}</p>
</div>
);
};Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

