Awesome-omni-skill frontend-dev-guidelines
Frontend development guidelines for React/TypeScript applications. Modern patterns including Suspense, lazy loading, useSuspenseQuery, file organization with features directory, shadcn/ui components, Tailwind CSS styling, TanStack Router, performance optimization, and TypeScript best practices. Use when creating components, pages, features, fetching data, styling, routing, or working with frontend code.
git clone https://github.com/diegosouzapw/awesome-omni-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/development/frontend-dev-guidelines-fredpope" ~/.claude/skills/diegosouzapw-awesome-omni-skill-frontend-dev-guidelines-aa5336 && rm -rf "$T"
skills/development/frontend-dev-guidelines-fredpope/SKILL.mdFrontend Development Guidelines
Purpose
Comprehensive guide for modern React development, emphasizing Suspense-based data fetching, lazy loading, proper file organization, and performance optimization.
When to Use This Skill
- Creating new components or pages
- Building new features
- Fetching data with TanStack Query
- Setting up routing with TanStack Router
- Styling components with shadcn/ui and Tailwind CSS
- Performance optimization
- Organizing frontend code
- TypeScript best practices
Quick Start
New Component Checklist
Creating a component? Follow this checklist:
- Use
pattern with TypeScriptReact.FC<Props> - Lazy load if heavy component:
React.lazy(() => import()) - Wrap in
for loading states<SuspenseLoader> - Use
for data fetchinguseSuspenseQuery - Import aliases:
,@/
,~types
,~components~features - Use shadcn/ui components from
@/components/ui - Style with Tailwind CSS classes and
utilitycn() - Use
for event handlers passed to childrenuseCallback - Default export at bottom
- No early returns with loading spinners
- Use
toast for user notificationssonner
New Feature Checklist
Creating a feature? Set up this structure:
- Create
directoryfeatures/{feature-name}/ - Create subdirectories:
,api/
,components/
,hooks/
,helpers/types/ - Create API service file:
api/{feature}Api.ts - Set up TypeScript types in
types/ - Create route in
routes/{feature-name}/index.tsx - Lazy load feature components
- Use Suspense boundaries
- Export public API from feature
index.ts
Import Aliases Quick Reference
| Alias | Resolves To | Example |
|---|---|---|
| | |
| | |
| | |
| | |
Defined in: vite.config.ts lines 180-185
Common Imports Cheatsheet
// React & Lazy Loading import React, { useState, useCallback, useMemo } from 'react'; const Heavy = React.lazy(() => import('./Heavy')); // shadcn/ui Components import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { cn } from '@/lib/utils'; // TanStack Query (Suspense) import { useSuspenseQuery, useQueryClient } from '@tanstack/react-query'; // TanStack Router import { createFileRoute } from '@tanstack/react-router'; // Project Components import { SuspenseLoader } from '~components/SuspenseLoader'; // Hooks import { useAuth } from '@/hooks/useAuth'; import { toast } from 'sonner'; // Types import type { Post } from '~types/post';
Topic Guides
🎨 Component Patterns
Modern React components use:
for type safetyReact.FC<Props>
for code splittingReact.lazy()
for loading statesSuspenseLoader- Named const + default export pattern
Key Concepts:
- Lazy load heavy components (DataGrid, charts, editors)
- Always wrap lazy components in Suspense
- Use SuspenseLoader component (with fade animation)
- Component structure: Props → Hooks → Handlers → Render → Export
📖 Complete Guide: resources/component-patterns.md
📊 Data Fetching
PRIMARY PATTERN: useSuspenseQuery
- Use with Suspense boundaries
- Cache-first strategy (check grid cache before API)
- Replaces
checksisLoading - Type-safe with generics
API Service Layer:
- Create
features/{feature}/api/{feature}Api.ts - Use
axios instanceapiClient - Centralized methods per feature
- Route format:
(NOT/form/route
)/api/form/route
📖 Complete Guide: resources/data-fetching.md
📁 File Organization
features/ vs components/:
: Domain-specific (posts, comments, auth)features/
: Truly reusable (SuspenseLoader, CustomAppBar)components/
Feature Subdirectories:
features/ my-feature/ api/ # API service layer components/ # Feature components hooks/ # Custom hooks helpers/ # Utility functions types/ # TypeScript types
📖 Complete Guide: resources/file-organization.md
🎨 Styling
Tailwind CSS with shadcn/ui:
- Use Tailwind utility classes directly
- Use
utility for conditional classescn() - Use CSS variables for theming
Primary Method:
- Tailwind classes in
propclassName
for merging classes conditionallycn()- shadcn/ui components handle base styling
Example:
<div className="flex flex-col gap-4 p-6"> <Card className={cn("w-full", isActive && "border-primary")}> <CardContent className="grid grid-cols-1 md:grid-cols-2 gap-4"> {/* Content */} </CardContent> </Card> </div>
📖 Complete Guide: resources/styling-guide.md
🛣️ Routing
TanStack Router - Folder-Based:
- Directory:
routes/my-route/index.tsx - Lazy load components
- Use
createFileRoute - Breadcrumb data in loader
Example:
import { createFileRoute } from '@tanstack/react-router'; import { lazy } from 'react'; const MyPage = lazy(() => import('@/features/my-feature/components/MyPage')); export const Route = createFileRoute('/my-route/')({ component: MyPage, loader: () => ({ crumb: 'My Route' }), });
📖 Complete Guide: resources/routing-guide.md
⏳ Loading & Error States
CRITICAL RULE: No Early Returns
// ❌ NEVER - Causes layout shift if (isLoading) { return <LoadingSpinner />; } // ✅ ALWAYS - Consistent layout <SuspenseLoader> <Content /> </SuspenseLoader>
Why: Prevents Cumulative Layout Shift (CLS), better UX
Error Handling:
- Use
toast for user feedbacksonner - NEVER
react-toastify - TanStack Query
callbacksonError
📖 Complete Guide: resources/loading-and-error-states.md
⚡ Performance
Optimization Patterns:
: Expensive computations (filter, sort, map)useMemo
: Event handlers passed to childrenuseCallback
: Expensive componentsReact.memo- Debounced search (300-500ms)
- Memory leak prevention (cleanup in useEffect)
📖 Complete Guide: resources/performance.md
📘 TypeScript
Standards:
- Strict mode, no
typeany - Explicit return types on functions
- Type imports:
import type { User } from '~types/user' - Component prop interfaces with JSDoc
📖 Complete Guide: resources/typescript-standards.md
🔧 Common Patterns
Covered Topics:
- React Hook Form with Zod validation
- DataGrid wrapper contracts
- Dialog component standards
hook for current useruseAuth- Mutation patterns with cache invalidation
📖 Complete Guide: resources/common-patterns.md
📚 Complete Examples
Full working examples:
- Modern component with all patterns
- Complete feature structure
- API service layer
- Route with lazy loading
- Suspense + useSuspenseQuery
- Form with validation
📖 Complete Guide: resources/complete-examples.md
Navigation Guide
| Need to... | Read this resource |
|---|---|
| Create a component | component-patterns.md |
| Fetch data | data-fetching.md |
| Organize files/folders | file-organization.md |
| Style components | styling-guide.md |
| Set up routing | routing-guide.md |
| Handle loading/errors | loading-and-error-states.md |
| Optimize performance | performance.md |
| TypeScript types | typescript-standards.md |
| Forms/Auth/DataGrid | common-patterns.md |
| See full examples | complete-examples.md |
Core Principles
- Lazy Load Everything Heavy: Routes, DataGrid, charts, editors
- Suspense for Loading: Use SuspenseLoader, not early returns
- useSuspenseQuery: Primary data fetching pattern for new code
- Features are Organized: api/, components/, hooks/, helpers/ subdirs
- shadcn/ui + Tailwind: Use shadcn components with Tailwind classes
- Import Aliases: Use @/, ~types, ~components, ~features
- No Early Returns: Prevents layout shift
- sonner toast: For all user notifications
Quick Reference: File Structure
src/ features/ my-feature/ api/ myFeatureApi.ts # API service components/ MyFeature.tsx # Main component SubComponent.tsx # Related components hooks/ useMyFeature.ts # Custom hooks useSuspenseMyFeature.ts # Suspense hooks helpers/ myFeatureHelpers.ts # Utilities types/ index.ts # TypeScript types index.ts # Public exports components/ SuspenseLoader/ SuspenseLoader.tsx # Reusable loader CustomAppBar/ CustomAppBar.tsx # Reusable app bar routes/ my-route/ index.tsx # Route component create/ index.tsx # Nested route
Modern Component Template (Quick Copy)
import React, { useState, useCallback } from 'react'; import { useSuspenseQuery } from '@tanstack/react-query'; import { Card, CardContent } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; import { featureApi } from '../api/featureApi'; import type { FeatureData } from '~types/feature'; interface MyComponentProps { id: number; onAction?: () => void; } export const MyComponent: React.FC<MyComponentProps> = ({ id, onAction }) => { const [state, setState] = useState<string>(''); const { data } = useSuspenseQuery({ queryKey: ['feature', id], queryFn: () => featureApi.getFeature(id), }); const handleAction = useCallback(() => { setState('updated'); onAction?.(); }, [onAction]); return ( <div className="p-4"> <Card className="p-6"> <CardContent className="space-y-4"> {/* Content */} </CardContent> </Card> </div> ); }; export default MyComponent;
For complete examples, see resources/complete-examples.md
Related Skills
- error-tracking: Error tracking with Sentry (applies to frontend too)
- backend-dev-guidelines: Backend API patterns that frontend consumes
Skill Status: Modular structure with progressive loading for optimal context management