frontend_mastery
SKILL.md
Frontend Mastery Protocol (React + Vite + Tailwind)
1. Performance "Pro" Checklist
Before submitting any UI component, verify:
- Re-renders: Are we re-rendering unnecessarily? Use
React.memooruseCallbackfor stable props. - 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
lodashvslodash/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
staleTimeandcacheTimeappropriately.
- Client State: Use
Zustandfor global,useStatefor local.- 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
childrenprop instead of passing components as props where possible. - Custom Hooks: Extract reusable logic immediately.
useBoolean,useToggle, etc.
4. Code Quality & Formatting
- Naming:
use[Action]for hooks,handle[Event]for handlers. - CSS (Tailwind):
- Group layout (
flex,grid) first, then spacing, then visual (bg,text). - Use
clsxortailwind-mergefor conditional classes. - NO inline styles (
style={{}}) except for dynamic coordinates.
- Group layout (
6. Error Boundaries
- Critical UI parts MUST have an
<ErrorBoundary>. - Async components (Suspense) must handle loading states gracefully.
Weekly Installs
2
Repository
cityfish91159/maihousesFirst Seen
1 day ago
Installed on
opencode2
codex2
claude-code2
antigravity2
gemini-cli2
windsurf1