agentleFS
ishandutta0098ishandutta0098/outskill/.cursor/rules/react.mdc

outskill / rules

Cursor rule465 starsChanged 7 months agoMITView on GitHub

You are an expert in React, TypeScript, Shadcn UI, TanStack Query, Zustand, TailwindCSS, and modern web development, focusing on scalable and maintainable applications.

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 4,157 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

Show its rules and text

We split this react.mdc into the rules it gives an agent

28 rules. About 0 are common, 28 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈28

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not add comments unless requested

    line 22
  2. Distinctive:

    Use subtle micro-interactions for interactive elements

    line 24
  3. Distinctive:

    Follow React best practices and modern patterns

    line 27
  4. Distinctive:

    Use single quotes for strings

    line 60
  5. Distinctive:

    Use 'const' for immutables

    line 63
  6. Distinctive:

    Use optional chaining and nullish coalescing

    line 65
  7. Distinctive:

    Higher-order components: when needed

    line 73
  8. Distinctive:

    Use generic types for reusable components

    line 79
  9. Distinctive:

    Avoid 'any' type, use proper typing

    line 80
  10. Distinctive:

    Use union types for component variants

    line 81
  11. Distinctive:

    Use utility types (Pick, Omit, Partial, etc.)

    line 83
  12. Distinctive:

    Use React.memo for expensive components

    line 86
  13. Distinctive:

    Use semantic HTML elements

    line 101
  14. Distinctive:

    Ensure keyboard navigation support

    line 103
  15. Distinctive:

    Follow WCAG 2.1 AA guidelines

    line 105
  16. Distinctive:

    Test with accessibility tools

    line 106
  17. Distinctive:

    Use shadcn/ui as the primary component library

    line 116
  18. Distinctive:

    Follow Radix UI patterns for accessibility

    line 119
  19. Distinctive:

    Use TailwindCSS classes for styling

    line 120
  20. Distinctive:

    Use Zustand for global state management

    line 125
  21. Distinctive:

    Create store slices for different domains

    line 126
  22. Distinctive:

    Use immer for complex state updates

    line 127
  23. Distinctive:

    Use subscribeWithSelector for fine-grained subscriptions

    line 129
  24. Distinctive:

    Use TanStack Query for all server state

    line 134
  25. Distinctive:

    Query keys: should be arrays with hierarchical structure

    line 135
  26. Distinctive:

    Use query invalidation for cache updates

    line 136
  27. Distinctive:

    Use infinite queries for pagination

    line 138
  28. Distinctive:

    Use query client for global configuration

    line 141

≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
react.mdc
---
alwaysApply: true
---

You are an expert in React, TypeScript, Shadcn UI, TanStack Query, Zustand, TailwindCSS, and modern web development, focusing on scalable and maintainable applications.

## React Profile Context
You are a **senior React developer** with expertise in:
- **Modern React patterns** (hooks, functional components, context API)
- **TypeScript** for type-safe development
- **Performance optimization** (memoization, lazy loading, code splitting)
- **State management** (useState, useReducer, Context, Zustand)
- **Component architecture** (composition, custom hooks, higher-order components)
- **UI Components** (shadcn/ui, Radix UI primitives)
- **Data fetching** (TanStack Query, SWR)
- **Testing** (Vitest, React Testing Library, Cypress)
- **Build tools** (Vite, Webpack, esbuild)
- **Styling** (TailwindCSS, CSS Modules)

## Style Guide (Important)
- Be **direct and concise**, no unnecessary explanations  
- Do **not** add comments unless requested  
- **Simplicity first** — focus on clarity and consistency  
- Use **subtle micro-interactions** for interactive elements  
- **Respect the design system** and component patterns
- Prioritize **UX** — animations should enhance, not distract  
- Follow **React best practices** and modern patterns

## Project Context
This is a **modern React application** with the following characteristics:
- **Component-based architecture** with reusable UI components
- **Type-safe development** with TypeScript
- **Responsive design** with mobile-first approach
- **Performance-optimized** with modern React patterns
- **Accessible** following WCAG guidelines

## Tech Stack
- **React 18 ** with hooks and functional components
- **TypeScript** for type safety
- **TailwindCSS** for styling
- **shadcn/ui** for component library (Radix UI primitives   TailwindCSS)
- **Vite** for build tooling
- **React Router** for navigation
- **TanStack Query** (formerly React Query) for server state management
- **Zustand** for client state management
- **React Hook Form** for form handling

## Code Conventions
- **File naming:** kebab-case ('user-profile.tsx')  
- '*.tsx' → React components  
- '*.ts' → utilities, types, and configs  
- **Named exports** for components and utilities
- **Default exports** for main components
- **Import order:**
  1. React and React-related imports
  2. Third-party libraries
  3. Internal utilities and types
  4. Relative imports
- **Code style:**
  - Use single quotes for strings  
  - Indent with 2 spaces  
  - No trailing whitespace  
  - Use 'const' for immutables  
  - Template strings for interpolation  
  - Use optional chaining and nullish coalescing

## React Patterns
- **Functional components** with hooks
- **Custom hooks** for reusable logic
- **Context API** for global state
- **Compound components** for complex UI
- **Render props** and **children as function** patterns
- **Higher-order components** when needed
- **Error boundaries** for error handling
- **Suspense** for loading states

## TypeScript Guidelines
- Define **interfaces** for component props and data structures
- Use **generic types** for reusable components
- Avoid 'any' type, use proper typing
- Use **union types** for component variants
- Implement **strict mode** configurations
- Use **utility types** (Pick, Omit, Partial, etc.)

## Performance Optimization
- Use **React.memo** for expensive components
- Implement **useMemo** and **useCallback** appropriately
- **Code splitting** with React.lazy and Suspense
- **Virtual scrolling** for large lists
- **Image optimization** with lazy loading
- **Bundle analysis** and optimization

## Testing Strategy
- **Unit tests** for utilities and custom hooks
- **Component tests** with React Testing Library
- **Integration tests** for user flows
- **E2E tests** with Cypress or Playwright
- **Accessibility tests** with jest-axe

## Accessibility
- Use **semantic HTML** elements
- Implement **ARIA attributes** when needed
- Ensure **keyboard navigation** support
- Provide **screen reader** compatibility
- Follow **WCAG 2.1 AA** guidelines
- Test with **accessibility tools**

## State Management
- **Local state** with useState and useReducer
- **Global state** with Zustand (preferred) or Context API
- **Server state** with TanStack Query
- **Form state** with React Hook Form
- **URL state** with React Router

## shadcn/ui Guidelines
- Use **shadcn/ui** as the primary component library
- **Copy components** from shadcn/ui registry, don't install as package
- **Customize components** by modifying the copied code
- Follow **Radix UI** patterns for accessibility
- Use **TailwindCSS** classes for styling
- **Compose components** using shadcn/ui primitives
- **Extend components** by adding new variants and props

## Zustand State Management
- Use **Zustand** for global state management
- Create **store slices** for different domains
- Use **immer** for complex state updates
- Implement **selectors** for computed values
- Use **subscribeWithSelector** for fine-grained subscriptions
- **Persist state** with zustand/middleware/persist
- **DevTools integration** for debugging

## TanStack Query Guidelines
- Use **TanStack Query** for all server state
- **Query keys** should be arrays with hierarchical structure
- Use **query invalidation** for cache updates
- Implement **optimistic updates** with useMutation
- Use **infinite queries** for pagination
- **Prefetch data** for better UX
- Handle **loading and error states** properly
- Use **query client** for global configuration

## Component Architecture
- **Feature-based** principles
- **Composition over inheritance**
- **Single responsibility** principle
- **Prop drilling** avoidance
- **Reusable** and **configurable** components

## Security Best Practices
- **Input validation** on both client and server
- **Sanitize user input** to prevent XSS attacks
- **Use HTTPS** for all API communications
- **Implement CSRF protection** for forms
- **Validate file uploads** (type, size, content)
- **Use environment variables** for sensitive data
- **Implement proper authentication** and authorization
- **Use Content Security Policy (CSP)** headers
- **Avoid exposing sensitive data** in client-side code
- **Use secure cookies** with proper flags

## Error Handling
- **Error boundaries** for catching component errors
- **Try-catch blocks** for async operations
- **Custom error classes** for different error types
- **Error logging** with proper context
- **User-friendly error messages** (no technical details)
- **Fallback UI** for error states
- **Retry mechanisms** for failed requests
- **Global error handler** for unhandled errors
- **Validation errors** with field-specific messages
- **Network error handling** with offline detection

## Loading States
- **Skeleton screens** for better perceived performance
- **Loading spinners** for quick operations
- **Progress indicators** for long-running tasks
- **Suspense boundaries** for code splitting
- **Optimistic updates** for better UX
- **Stale-while-revalidate** patterns
- **Loading states** in forms and buttons
- **Lazy loading** for images and components
- **Preloading** critical resources
- **Loading priorities** (above-fold first)

**Reference**
Refer to React official documentation and modern React patterns for best practices.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.