.claude/skills/react/SKILL.md
React 18 hooks, components, and functional patterns for the Luxia e-commerce SPA. Use when: Building UI components, handling client state, managing forms, or integrating with backend APIs.
npx skillsauth add kaxuna1/ecomsite reactInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This codebase uses React 18 with TypeScript, React Query for server state, Context API for global state, and React Hook Form for forms. Components follow functional patterns with hooks. Entry point: frontend/src/main.tsx → App.tsx.
// src/components/ProductCard.tsx
interface ProductCardProps {
product: Product;
index?: number;
}
export function ProductCard({ product, index = 0 }: ProductCardProps) {
const { addItem } = useCart();
const [isAdding, setIsAdding] = useState(false);
const handleAddToCart = async () => {
setIsAdding(true);
await addItem(product, 1);
setIsAdding(false);
};
return (
<div className="product-card">
<img src={product.imageUrl} alt={product.name} loading="lazy" />
<h3>{product.name}</h3>
<button onClick={handleAddToCart} disabled={isAdding}>
{isAdding ? 'Adding...' : 'Add to Cart'}
</button>
</div>
);
}
// Consumer pattern - use the custom hook
import { useCart } from '../context/CartContext';
import { useAuth } from '../context/AuthContext';
function CheckoutButton() {
const { items, subtotal } = useCart();
const { isAuthenticated, user } = useAuth();
if (!isAuthenticated) return <LoginPrompt />;
return <button>Checkout ({items.length} items - ${subtotal})</button>;
}
| Concept | Usage | Example |
|---------|-------|---------|
| Server State | React Query | useQuery({ queryKey: ['products'], queryFn }) |
| Global State | Context + useReducer | CartContext, AuthContext |
| Local State | useState | Modal open, form inputs |
| Forms | React Hook Form | useForm<CheckoutForm>() |
| Side Effects | useEffect | Sync localStorage, DOM updates |
frontend/src/
├── api/ # Typed API clients (Axios)
├── components/ # Reusable UI (90+ components)
├── context/ # Global state (Cart, Auth, I18n, Theme)
├── hooks/ # Custom hooks (useAutoSave, useDebounce)
├── pages/ # Route components (41 pages)
└── types/ # TypeScript interfaces
const { data: products, isLoading, error } = useQuery({
queryKey: ['products', filters],
queryFn: () => fetchProducts(filters),
staleTime: 5 * 60 * 1000
});
const mutation = useMutation({
mutationFn: createOrder,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['orders'] });
navigate('/order-success');
}
});
tools
Zustand lightweight state management with persistence and middleware. Use when: managing client-side state (cart, auth, UI preferences), replacing React Context with simpler API, accessing state outside React components, implementing localStorage persistence
development
Zod schema validation and TypeScript integration for runtime type safety. Use when: Validating API payloads, form inputs, environment variables, or any external data boundaries where TypeScript types alone cannot guarantee safety.
tools
Configures Vite 5.x build tool, dev server, and frontend asset optimization for the Luxia e-commerce platform. Use when: configuring builds, adding environment variables, optimizing bundle size, setting up testing, debugging HMR issues, or adding Vite plugins.
development
Enforces strict TypeScript types across frontend and backend codebases. Use when: Writing new services, DTOs, interfaces, type guards, debugging type errors, or ensuring type safety at API boundaries.