react-native-boilerplate / rules
Cursor rule517 starsChanged 15 months agoMITView on GitHub
React Native Expo SDK 54 project with TypeScript, Expo Router v6, Redux Toolkit, and modern development practices.
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 1,533 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 repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this coding-guidelines.mdc into the rules it gives an agent
25 rules. About 0 are common, 22 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈22
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Never hardcode environment values, always go through config
- Very specific: line 23
Use
@/theme/colors: instead of hardcoded color values - Distinctive: line 38
Keep local state minimal, prefer global state for shared data
- Distinctive: line 43
Never make direct API calls from components
- Distinctive: line 44
Use the services layer for data transformation
- Distinctive: line 80
Use function declarations, not arrow functions for components
- Distinctive: line 81
Keep hooks at the top of components
- Distinctive: line 82
Use early returns for conditional rendering
- Very specific: line 87
Always use StyleSheet.create for performance
- Distinctive: line 88
Import colors from theme, never hardcode
- Distinctive: line 89
Use platform-specific styles when needed
- Distinctive: line 90
Keep styles at component bottom
- Distinctive: line 95
Test component behavior, not implementation
- Distinctive: line 96
Use descriptive test names
- Very specific: line 138
Use utils/config.ts for all config access
- Distinctive: line 163
Always handle loading and error states
- Distinctive: line 165
Keep functions focused and small
- Distinctive: line 169
Always check existing components before creating new ones
- Distinctive: line 170
Use built-in utilities instead of reinventing
- Distinctive: line 172
Follow established patterns in the codebase
- Distinctive: line 176
Write tests for all new components
- Distinctive: line 177
Ensure tests pass before committing
- Distinctive: line 178
Test both happy path and error scenarios
- Distinctive: line 179
Use React Native Testing Library patterns
- Distinctive: line 190
Reuse existing built-in features: before creating new ones
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 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.
Files
--- description: globs: alwaysApply: true --- # React Native Expo Project - Coding Guidelines ## Project Overview React Native Expo SDK 54 project with TypeScript, Expo Router v6, Redux Toolkit, and modern development practices. ## Built-in Features to Always Use ### Configuration Management - **Use `utils/config.ts`** for all environment variables and app configuration - **Use `utils/deviceInfo.ts`** for platform detection and device dimensions - Never hardcode environment values, always go through config ### Theme System - **Always import from `@/theme`** for colors, fonts, and images - **Use `@/theme/colors`** instead of hardcoded color values - **Use theme system** for consistent dark/light mode support - **Load assets through `@/theme/images` and `@/theme/fonts`** ### Custom Hooks - **Use `useColorScheme` from `@/hooks`** for theme detection - **Use `useDataPersist` from `@/hooks`** for local storage operations - **Use `useKeyboard` from `@/hooks`** for keyboard state management - **Use `useAppSlice` from `@/slices`** for global state management ### State Management - **Use Redux Toolkit slices** in `@/slices` for global state - **Import from `@/slices`** for all state operations - Keep local state minimal, prefer global state for shared data ### Services Layer - **Use `@/services`** for all API calls and external integrations - Never make direct API calls from components - Use the services layer for data transformation ### Type Safety - **Use types from `@/types`** for all interfaces - **Define component props interfaces** for all components - **Use TypeScript strict mode** - project is configured for it ## Directory Structure Rules ### Component Organization - **`components/elements`** - Reusable UI components (Button, Image, etc.) - **`components/layouts`** - Layout-specific components (headers, navigation) - **`scenes`** - Screen components (renamed from pages) - **`app`** - Expo Router routes only, delegate to scenes ### File Naming - **Components**: PascalCase (`Button.tsx`, `NavigationHeader.tsx`) - **Hooks**: camelCase with "use" prefix (`useColorScheme.ts`) - **Utils**: camelCase (`deviceInfo.ts`, `config.ts`) - **Types**: PascalCase (`User.ts`, `ApiResponse.ts`) ## Code Standards ### Import Organization 1. React and React Native imports first 2. Third-party library imports 3. Internal imports using `@/` paths 4. Relative imports last ### Component Structure - Define TypeScript interfaces for all props - Use function declarations, not arrow functions for components - Keep hooks at the top of components - Use early returns for conditional rendering - Export default at the bottom ### Styling Rules - Always use `StyleSheet.create` for performance - Import colors from theme, never hardcode - Use platform-specific styles when needed - Keep styles at component bottom ### Testing Requirements - One test file per component - Test component behavior, not implementation - Use descriptive test names - Mock external dependencies ### SafeAreaView Usage - **Import from `react-native-safe-area-context`**, not React Native - React Native's SafeAreaView is deprecated as of SDK 54 ### Required Peer Dependencies - **@expo/metro-runtime** - Required for Expo Router - **react-native-worklets** - Required for React Native Reanimated ## Built-in Architecture Patterns ### Navigation (Expo Router v5) - **Use flat config format** as project is configured - **Keep route files minimal** - delegate to scene components - **Use `<Redirect>` for programmatic navigation** - **Handle deep linking through router** ### Error Handling - **Use try-catch for async operations** - **Provide user-friendly error messages** - **Log errors appropriately for debugging** - **Implement fallback UI states** ### Performance - **Use React.memo for expensive components** - **Implement proper useCallback/useMemo** - **Optimize lists with proper keys** - **Lazy load components when possible** ## Project-Specific Features ### Environment Configuration - Project uses `expo-constants` for environment variables - Configuration is typed and validated - Use `utils/config.ts` for all config access ### Theme and Styling - Dark/light mode support built-in - Theme colors are centralized and typed - Responsive design utilities available ### Data Persistence - Custom hook for local data storage - Redux Toolkit for global state management - Proper data flow architecture ### Platform Support - iOS, Android, and Web platform support - Platform-specific utilities available - Responsive design considerations ## Development Rules ### Code Quality - No `console.log` in production code - Always handle loading and error states - Write self-documenting code - Keep functions focused and small ### Reusability Focus - Always check existing components before creating new ones - Use built-in utilities instead of reinventing - Extend existing components rather than duplicating - Follow established patterns in the codebase ### Testing - Write tests for all new components - Ensure tests pass before committing - Test both happy path and error scenarios - Use React Native Testing Library patterns ## Migration and Updates - Currently on Expo SDK 54 with React 19.1 - ESLint 9 with flat config - Modern React Native 0.81.4 - TypeScript strict mode enabled (v5.9.2) ## Key Principles 1. **Reuse existing built-in features** before creating new ones 2. **Follow established patterns** in the codebase 3. **Use TypeScript strictly** for better code quality 4. **Test all components** for reliability 5. **Keep components focused** and single-purpose 6. **Use the theme system** for consistent UI 7. **Leverage built-in hooks** for common functionality 8. **Follow import/export conventions** for maintainability
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
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.

