.cursorrules Template
# Rapid MVP Development Rules
## Core Principles
- **MVP First**: Focus on the minimum viable features that demonstrate core value. Avoid over-engineering.
- **Quality Over Speed**: Write clean, maintainable code even in rapid development. Technical debt should be intentional and documented.
- **Type Safety**: Use TypeScript strictly. Avoid `any` types. Use proper interfaces and types.
- **Component Reusability**: Create reusable components and utilities. Don't duplicate code.
## Code Quality Standards
### TypeScript
- Use strict TypeScript configuration
- Define explicit types for all function parameters and return values
- Use interfaces for object shapes, types for unions/primitives
- Prefer type inference where it improves readability, but be explicit for public APIs
- No `any` types unless absolutely necessary (and document why)
### React Best Practices
- Use functional components with hooks
- Keep components small and focused (single responsibility)
- Extract complex logic into custom hooks
- Use proper dependency arrays in useEffect, useMemo, useCallback
- Memoize expensive computations and components when appropriate
- Handle loading and error states explicitly
### Code Organization
- Follow a clear folder structure:
- `src/components/` - Reusable UI components
- `src/pages/` or `src/routes/` - Page-level components
- `src/hooks/` - Custom React hooks
- `src/utils/` - Utility functions
- `src/store/` - State management (Zustand)
- `src/types/` - TypeScript type definitions
- `src/services/` - API calls and external services
- One component per file
- Use index files for clean imports
- Keep related files close together
### Error Handling
- Always handle errors explicitly
- Use try-catch for async operations
- Provide meaningful error messages to users
- Log errors appropriately (to console in dev, to LogRocket in prod)
- Never silently fail
### Testing Considerations
- Write testable code (pure functions where possible)
- Keep business logic separate from UI components
- Make components easy to test (accept props, avoid hidden dependencies)
## Technology Stack Conventions
### React 19 + TypeScript
- Use React 19 features appropriately
- Leverage TypeScript for type safety
- Use React Server Components where applicable (if using Next.js)
### State Management (Zustand)
- Keep stores focused and scoped
- Use TypeScript for store state shapes
- Avoid deeply nested state
- Use selectors for derived state
### Styling (Tailwind CSS)
- Use Tailwind utility classes primarily
- Create reusable component classes when needed
- Follow mobile-first responsive design
- Use design tokens/theme values consistently
- Ensure WCAG AA contrast ratios
### UI Components (Radix UI)
- Use Radix UI primitives for accessibility
- Don't override accessibility features
- Customize styling through Tailwind, not by breaking Radix APIs
- Follow Radix patterns for composition
### Firebase
- Use Firebase v9+ modular SDK
- Handle authentication states properly
- Use Firestore security rules (document them)
- Handle offline states gracefully
- Use proper Firestore data modeling (avoid deep nesting)
### API Integration
- Use async/await consistently
- Handle loading, success, and error states
- Implement proper request cancellation
- Use environment variables for API keys
- Never commit secrets
## Development Workflow
### Before Writing Code
- Understand the requirement fully
- Check if similar functionality exists
- Plan the component structure
- Consider edge cases and error states
### While Writing Code
- Write self-documenting code (clear variable/function names)
- Add comments for complex logic or non-obvious decisions
- Keep functions small and focused
- Extract magic numbers/strings to constants
- Use early returns to reduce nesting
### After Writing Code
- Check for console errors/warnings
- Verify TypeScript compiles without errors
- Test the feature manually
- Ensure responsive design works
- Check accessibility (keyboard navigation, screen readers)
## Performance Considerations
- Lazy load routes and heavy components
- Optimize images and assets
- Minimize bundle size (check imports, avoid full library imports)
- Use React.memo, useMemo, useCallback judiciously (not everywhere)
- Monitor bundle size with tools like webpack-bundle-analyzer
## Security
- Never expose API keys or secrets in client code
- Validate and sanitize user inputs
- Use Firebase security rules
- Implement proper authentication checks
- Follow OWASP guidelines for web security
## Accessibility
- Use semantic HTML
- Ensure keyboard navigation works
- Add proper ARIA labels where needed
- Maintain focus management
- Test with screen readers
- Ensure color contrast meets WCAG AA standards
## Code Review Guidelines
When suggesting changes:
- Be specific about what needs to change and why
- Suggest concrete improvements, not just "this is wrong"
- Consider the MVP context (don't over-engineer)
- Point out potential bugs or edge cases
- Suggest performance improvements when relevant
## Common Patterns
### API Calls
```typescript
// Use this pattern for API calls
const fetchData = async (): Promise<Data> => {
try {
const response = await api.getData();
return response.data;
} catch (error) {
console.error('Failed to fetch data:', error);
throw error; // Re-throw for caller to handle
}
};Component Structure
MVP-Specific Guidelines
What NOT to Do
When You're Stuck
Last updated