Claude-skill-registry frontend_mastery
Advanced React patterns, performance optimization, and state management rules.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/frontend-mastery-cityfish91159-maihouses" ~/.claude/skills/majiayu000-claude-skill-registry-frontend-mastery && rm -rf "$T"
manifest:
skills/data/frontend-mastery-cityfish91159-maihouses/SKILL.mdsource content
Frontend Mastery Protocol (React + Vite + Tailwind)
1. Performance "Pro" Checklist
Before submitting any UI component, verify:
- Re-renders: Are we re-rendering unnecessarily? Use
orReact.memo
for stable props.useCallback - Lazy Loading: Are strict routes lazy-loaded? (
)React.lazy - Image Optimization: Are images using proper formats (WebP/AVIF) and
?loading="lazy" - Zustand Selectors: Are we selecting only what we need?
- ❌
const { user, token } = useAuthStore() - ✅
const user = useAuthStore((s) => s.user)
- ❌
- Bundle Size: Did we import a huge library for one function? (e.g. import
vslodash
)lodash/debounce
2. State Management Rules (Zustand + React Query)
- Server State: MUST use
.React Query- NEVER store server data in global Zustand store manually (unless caching for UI sync).
- Use
andstaleTime
appropriately.cacheTime
- Client State: Use
for global,Zustand
for local.useState- Avoid "Prop Drilling" > 2 levels. Use Context or Zustand.
3. Architectectural Patterns
- Container/Presenter: Separate logic (Hooks) from View (JSX).
- Complex components should have a custom hook (e.g.,
).useComponentLogic.ts
- Complex components should have a custom hook (e.g.,
- Composition: Use
prop instead of passing components as props where possible.children - Custom Hooks: Extract reusable logic immediately.
,useBoolean
, etc.useToggle
4. Code Quality & Formatting
- Naming:
for hooks,use[Action]
for handlers.handle[Event] - CSS (Tailwind):
- Group layout (
,flex
) first, then spacing, then visual (grid
,bg
).text - Use
orclsx
for conditional classes.tailwind-merge - NO inline styles (
) except for dynamic coordinates.style={{}}
- Group layout (
6. Error Boundaries
- Critical UI parts MUST have an
.<ErrorBoundary> - Async components (Suspense) must handle loading states gracefully.