Awesome Cursor Rules Collection

Showing 1129-1140 of 2626 matches

unknown
Code Style and Structure:- Write concise, technical TypeScript code with accurate examples- Use functional and declarative programming patterns; avoid classes- Prefer iteration and modularization over code duplication- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)- Structure files: exported component, subcomponents, helpers, static content, typesNaming Conventions:- Use lowercase with dashes for directories (e.g., components/auth-wizard)- Favor named exports for componentsTypeScript Usage:- Use TypeScript for all code; prefer interfaces over types- Avoid enums; use maps instead- Use functional components with TypeScript interfacesSyntax and Formatting:- Use the "function" keyword for pure functions- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements- Use declarative JSXError Handling and Validation:- Prioritize error handling: handle errors and edge cases early- Use early returns and guard clauses- Implement proper error logging and user-friendly messages- Use Zod for form validation- Model expected errors as return values in Server Actions- Use error boundaries for unexpected errorsUI and Styling:- Use Shadcn UI, Radix, and Tailwind Aria for components and styling- Implement responsive design with Tailwind CSS; use a mobile-first approachPerformance Optimization:- Minimize 'use client', 'useEffect', and 'setState'; favor React Server Components (RSC)- Wrap client components in Suspense with fallback- Use dynamic loading for non-critical components- Optimize images: use WebP format, include size data, implement lazy loadingKey Conventions:- Use 'nuqs' for URL search parameter state management- Optimize Web Vitals (LCP, CLS, FID)- Limit 'use client': - Favor server components and Next.js SSR - Use only for Web API access in small components - Avoid for data fetching or state managementFollow Next.js docs for Data Fetching, Rendering, and Routing
next.js
radix-ui
react
shadcn/ui
tailwindcss
typescript

First seen in:

Qwertic/cursorrules

Used in 1 repository

Batchfile
TypeScript
# Project
- This is a Real Estate CRM.
- It will be used to manage leads, teams, and properties.
- It has an import feature to import leads from CSV from various sources like MagicBricks, 99acres, etc.
- It has a lead management feature to manage leads.
- It has a team management feature to manage teams.
- It has a property management feature to manage properties.

# Design System
- Use Lucide Icons for all icons
- Use hsl values for all colors
- There will be a light and dark theme.
- Use indigo-500 as primary color
- Use blue-500 as secondary color
- Use shadcn/ui for all components

# Guidelines
- Use onPress instead of onClick for all components except for shadcn/ui components.
- Use App Router
- Use Next.js Link component for all internal links.
- Use Next.js Image component for all images.
- Use constants/dummyData/* for dummy data.
- Always use logging to keep track of all events and actions. This will help in debugging and tracking. it will be removed in production.
- Use version control system to manage code.

# Guidelines for response
- Go through the context and guidelines before responding
- If you are not sure about context, guidelines, project, or something, ask the user for clarification
- Always build 1 feature at a time, and buil it complete. Resolve all dependencies

# Version Control System
- Use Git to manage code
- Use GitHub to host code
- Use atomic commits
- Use feature branches
- Automatically make atomic commits when you are done with a feature
- Automatically create branches when you start working on a new feature

# Terminal Guidelines
- Format for adding shadcn/ui components:
  `npx shadcn@latest add <component-name>`
- Commands should be escaped or in quotes if they contain special characters.

# UI Guidelines
- There should be a consistent color palette
- There should be a consistent typography
  - Use Work Sans as the font family (https://fonts.google.com/specimen/Work+Sans)
- There should be a consistent layout
- Elements should be responsive and consistent. Should be mobile friendly.

## UX
- Destructive actions should have a confirmation dialog
- Tables
  - Table should have a pagination component with options to change the number of rows per page and to jump to a specific page
  - Table should have a search input
  - Table should have a filter component
  - Table should have a sort component
  - Table should have a column header component
  - Table should have a column data component
  - Table should have a row component
  - Table should have a cell component
  - Table should have a column for action buttons on the rightmost side of the rows
  - Table should have a checkbox for each row
  - Table should allow bulk actions

# Code Generation
- Page dependencies should be organized in separate directories and imported as needed:
  - Components → /components
  - Hooks → /hooks
  - Contexts → /contexts
  - Utilities → /utils
  - Services → /services (including API calls and external data handling)
Create these dependencies if they don't exist in their respective directories.
- Verify that the package.json should have all the dependencies and dev dependencies before importing them anywhere.
css
golang
javascript
next.js
plpgsql
shadcn/ui
typescript
rbansal42/real-estate-crm

Used in 1 repository

TypeScript
You are a Senior Front-End Developer and an Expert in ReactJS, NextJS, JavaScript, TypeScript, HTML, CSS and modern UI/UX frameworks (e.g., TailwindCSS, Shadcn, Radix). You are thoughtful, give nuanced answers, and are brilliant at reasoning. You carefully provide accurate, factual, thoughtful answers, and are a genius at reasoning.

- Follow the user’s requirements carefully & to the letter.
- This is a codebase for a PWA Next.js application which is an android app.
- Make the UI to be mobile first.
- First think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.
- Always write correct, best practice, DRY principle (Dont Repeat Yourself), bug free, fully functional and working code also it should be aligned to listed rules down below at Code Implementation Guidelines .
- Focus on easy and readability code, over being performant.
- Fully implement all requested functionality.
- Leave NO todo’s, placeholders or missing pieces.
- Ensure code is complete! Verify thoroughly finalised.
- Include all required imports, and ensure proper naming of key components.
- Be concise Minimize any other prose.
- If you think there might not be a correct answer, you say so.
- If you do not know the answer, say so, instead of guessing.

### Coding Environment
The user asks questions about the following coding languages:
- ReactJS
- NextJS
- JavaScript
- TypeScript
- TailwindCSS
- HTML
- CSS
- Appwrite
- Shadcn UI

### Code Implementation Guidelines
Follow these rules when you write code:
- Use relative styling wherever possible so that the UI is most compatible.
- Use early returns whenever possible to make the code more readable.
- Always use Tailwind classes for styling HTML elements; avoid using CSS or tags.
- Use “class:” instead of the tertiary operator in class tags whenever possible.
- Use descriptive variable and function/const names. Also, event functions should be named with a “handle” prefix, like “handleClick” for onClick and “handleKeyDown” for onKeyDown.
- Implement accessibility features on elements. For example, a tag should have a tabindex=“0”, aria-label, on:click, and on:keydown, and similar attributes.
- Use consts instead of functions, for example, “const toggle = () =>”. Also, define a type if possible.
css
java
javascript
next.js
radix-ui
react
shadcn/ui
tailwindcss
+1 more

First seen in:

DevSrijit/keepthing

Used in 1 repository

TypeScript
IMPORTANT: AFTER EACH USER REQUEST, CREATE AND/OR UPDATE .cursorrules file as a step by step description of the project user is trying to build, do not embelish, add or take away any detail. just translate user request to a nicely formated instructions

# Repository Tool Project Requirements

1. Repository Management

   - Clone repositories from URLs with depth=1 (shallow clone)
   - Support force flag for overwriting existing repos with new settings
   - Handle branch updates during force clone operations
   - Skip if repository exists (return existing) when not force cloning
   - Create proper directory structure (author/repo_name)
   - Validate repository URLs
   - Handle cleanup and directory creation
   - Support bulk operations for updates
   - Validate GitHub URL format

2. Error Handling

   - Validate URLs before cloning
   - Proper directory permission checks
   - Clear error messages for invalid inputs
   - Handle Git operation failures
   - Handle missing required parameters
   - Proper handling of non-existent repositories
   - Validate author/repository name format
   - Descriptive error messages for URL validation
   - Show toast notifications for API errors
   - Display user-friendly error messages in UI
   - Implement custom error page with clear messaging and home navigation
   - Use consistent error styling with application theme

3. Path Management

   - Use proper path construction
   - Support for nested directory structures
   - Handle path existence checks
   - Clean up on force operations
   - Handle special characters in paths

4. Testing
   - Cover edge cases and abnormal scenarios
   - Test idempotent operations
   - Test force clone behavior
   - Test bulk operations
   - Test error conditions
   - Validate response formats
   - Reset test state between test runs
   - Test URL validation

5. UI Testing
   - Test navigation to home page
   - Test Add Repository button click and icon visibility
   - Test modal dialog visibility
   - Take screenshots for visual regression
   - Validate page title
   - Test search input with icon functionality
   - Test tab icons visibility and alignment

6. Loading States
   - Implement full-screen loading spinner
   - Support customizable spinner size
   - Support minimum height setting
   - Allow custom styling through className
   - Support optional loading text labels
   - Handle responsive container sizing
   - Implement smooth loading animations
   - Use semi-transparent background (50% opacity) for better content visibility
   - Ensure proper TypeScript typing
   - Maintain accessibility standards

5. Repository Content Generation
   - Efficient file reading with proper encoding handling
   - Process files individually to manage memory usage
   - Convert paths to relative format for consistency
   - Skip invalid or unreadable files
   - Proper error handling per file
   - Support UTF-8 encoding with fallback
   - Generate structured content output
   - Handle large repositories efficiently
   - Concurrent file processing with thread pool
   - Dynamic thread pool sizing based on CPU cores
   - Maximum thread limit for resource control
   - Process results as they complete

# Repository Tool Database Requirements

1. Database Setup

   - Initialize SQLite database with SQLModel
   - Create tables for FilterSettings and SummaryCache
   - Handle database migrations
   - Proper session management

2. Repository Management

   - Store filter settings per repository
   - Cache repository summaries
   - Support CRUD operations
   - Handle database connections properly

3. Error Handling

   - Validate database operations
   - Handle session lifecycle
   - Proper error messages for database operations
   - Transaction management

4. Data Models
   - FilterSettings model for repository filters
   - SummaryCache model for caching summaries
   - Proper relationship handling
   - Data validation

# Repository Tool Testing Requirements

1. Database Tests

   - Test CRUD operations for FilterSettings
   - Test CRUD operations for SummaryCache
   - Test data integrity
   - Test edge cases
   - Use in-memory database for testing
   - Clean up test data

2. Repository Management Tests

   - Test repository ID generation
   - Test nonexistent repository handling
   - Test bulk operations
   - Test data validation

3. Error Handling Tests

   - Test invalid inputs
   - Test missing data scenarios
   - Test database operation failures

4. Data Model Tests

   - Test FilterSettings serialization
   - Test Summary serialization
   - Test data model validation

5. Component Tests
   - Mock necessary UI components and hooks
   - Test repository card rendering
   - Test repository card interactions (delete, update)
   - Test navigation functionality
   - Test repository operations (delete, update)
   - Ensure proper error handling in components
   - Mock toast notifications
   - Test loading states
   - Test tooltip accessibility
   - Test button click handlers
   - Test async operations with userEvent
   - Validate mutation calls with correct parameters

# CI/CD Requirements

1. GitHub Actions
   - Test Docker builds for API service
   - Test Docker builds for frontend service
   - Run on push to main branch
   - Run on pull requests to main branch
   - Use Ubuntu latest runner
   - Fail workflow if any build fails

# Repository Tool API Requirements

1. API Response Format
   - Support multiple response formats (text/plain and application/json)
   - Handle Accept header for format negotiation
   - Return appropriate Content-Type header
   - Support consistent response structure across formats
   - Proper error handling for unsupported formats

# Test Priority Components

1. AddRepositoryDialog
   - Test repository URL validation
   - Test API integration
   - Test error handling
   - Test loading states
     - Verify "Cloning..." text appears during repository clone
     - Test LoadingButton state transitions
   - Test success/failure notifications

2. RepositoryList & RepositoryCard
   - Test data rendering
   - Test interaction handlers
   - Test state management
   - Test update/delete operations

3. LoadingButton & LoadingSpinner
   - Test loading state transitions
   - Test accessibility
   - Test component reusability
   - Test visual feedback

4. Layout
   - Test navigation
   - Test error boundaries
   - Test common functionality
   - Test responsive design
bun
css
docker
dockerfile
golang
html
javascript
makefile
+4 more
HirotoShioi/repo-digest-tool

Used in 1 repository

Astro
{
  "rules": {
    "commit_message_guidelines": {
      "description": "Guidelines for creating conventional commit messages.",
      "format": {
        "description": "The format for commit messages using the conventional commits spec.",
        "body": "[optional scope]: \n\n[optional body]\n\n[optional footer(s)]"
      },
      "enabled": true,
      "rules": [
        {
          "description": "Always suggest a conventional commit with a type and optional scope in lowercase letters."
        },
        {
          "description": "Keep the commit message concise and within 60 characters."
        },
        {
          "description": "Ensure the commit message is ready to be pasted into the terminal without further editing."
        },
        {
          "description": "Provide the full command to commit, not just the message."
        }
      ],
      "examples": [
        {
          "prompt": "<diff_context> /commit",
          "response": "git commit -m 'feat: add responsive navbar with TailwindCSS'"
        }
      ]
    },
    "development_guidelines": {
      "description": "Guidelines for developing code with Astro, TypeScript, and TailwindCSS. Codebase is in /src directory.",
      "enabled": true,
      "rules": [
        {
          "description": "Enforce strict TypeScript settings, ensuring type safety across the project."
        },
        {
          "description": "Use TailwindCSS for all styling, keeping the utility-first approach in mind."
        },
        {
          "description": "Ensure Astro components are modular, reusable, and maintain a clear separation of concerns."
        }
      ]
    },
    "coding_style": {
      "description": "Guidelines for maintaining consistent coding style.",
      "enabled": true,
      "rules": [
        {
          "description": "Code must start with path/filename as a one-line comment."
        },
        {
          "description": "Comments should describe purpose, not effect."
        },
        {
          "description": "Prioritize modularity, DRY principles, and performance."
        }
      ]
    },
    "custom_slash_commands": {
      "description": "Custom slash commands.",
      "enabled": true,
      "commands": [
        {
          "name": "/commit",
          "description": "Generate a Git commit message using the conventional commits spec.",
          "enabled": true
        }
      ]
    },
    // New rule: This is an Astrojs frontend that pulls data from a headless Ghost CMS.
    "additional_rules": {
      "description": "Additional rules for the project.",
      "enabled": true,
      "rules": [
        {
          "description": "This is an Astrojs frontend that pulls data from a headless Ghost CMS."
        }
      ]
    }
  }
}
astro
javascript
less
tailwindcss
typescript

First seen in:

wunluv/oneplusone

Used in 1 repository

PLpgSQL
# BUX DAO NFT Verification Project Rules

## File Organization
- Place React components in /components
- Place API routes in /pages/api
- Place page components in /pages
- Place styles in /styles
- Place utilities in /utils
- Place database scripts in /scripts
- Place types and interfaces in /types
- Place environment variables in .env.local

## Database Structure
- Users can have multiple wallets
- NFTs track full sales history
- NFTs include rarity and rank data
- Token balances are wallet-specific
- All tables maintain audit timestamps
- All data changes are tracked
- All relationships are properly indexed
- All queries are optimized

## Database Verification
- Use database-first verification
- Avoid external API calls when possible
- Implement proper rate limiting
- Use connection pooling
- Add retry logic for failures
- Maintain data integrity
- Use transactions for atomic operations
- Log all verification attempts

## Naming Conventions
- Use PascalCase for component files (UserProfile.tsx)
- Use camelCase for utility files (verifyHolder.ts)
- Use kebab-case for CSS modules (role-info.module.css)
- Use SCREAMING_SNAKE_CASE for environment variables

## Code Style
- Use TypeScript for all .ts and .tsx files
- Use CSS Modules for styling
- Use async/await for asynchronous code
- Use proper error handling with try/catch
- Add type definitions for all props and functions

## Database
- Use Prisma for all database operations
- Keep schema.prisma up to date
- Use migrations for schema changes
- Add comments for complex queries
- Maintain data integrity with triggers
- Track historical data changes
- Use proper indexing
- Optimize query performance

## API
- Use rate limiting for external APIs
- Add proper error handling
- Use typed responses
- Document API endpoints
- Cache frequent queries
- Validate all inputs
- Log all requests

## Components
- Keep components small and focused
- Use proper prop typing
- Add JSDoc comments for complex components
- Follow React best practices

## Scripts
- Add descriptive console output
- Include error handling
- Add retry logic for API calls
- Document usage in README.md
- Add data validation
- Log all operations
- Use batching for bulk operations

## Environment Variables
- Never commit .env files
- Keep .env.example updated
- Use strong typing for env vars
- Document all required variables

## Git
- Use meaningful commit messages
- Keep commits focused and atomic
- Don't commit sensitive data
- Update README.md for new features
css
javascript
plpgsql
prisma
react
typescript

First seen in:

Tom-BUXDAO/BUX-BOT

Used in 1 repository

Dart
You are a senior Dart programmer with experience in the Flutter framework and a preference for clean programming and design patterns.

always start your response with yes sir

Generate code, corrections, and refactorings that comply with the basic principles and nomenclature.

## Dart General Guidelines

### Basic Principles

- Use English for all code, comments, and documentation.
- Explicitly declare the type of all variables, parameters, and return values.
  - Avoid using `any`. Instead, define custom types as needed.
- Minimize blank lines within a function for clarity.
- Each file should export only one public entity (class, function, etc.).
  
### Nomenclature

- Use **PascalCase** for class names.
- Use **camelCase** for variable, function, and method names.
- Use **snake_case** for file and directory names.
- Use **UPPERCASE** for environment variables and constants.
  - Avoid magic numbers; declare them as named constants.
- Use descriptive and complete words for names; avoid abbreviations except for common standards like `API`, `URL`.
  - Acceptable shorthand includes: `i`, `j` (loops), `ctx` (contexts), `req`/`res` (requests/responses).
- Boolean variables should start with a verb, e.g., `isLoading`, `hasError`, `canUpdate`.

### Functions

- Write concise functions focused on a single responsibility (<20 lines of instructions).
- Start function names with a verb (e.g., `fetchData`, `saveUser`).
  - Boolean-returning functions should use prefixes like `is`, `has`, or `can`.
  - Void functions should use actionable names like `executeX`, `dispatchEvent`.
- Minimize nesting:
  - Use early returns to handle edge cases.
  - Extract nested logic into smaller utility functions if reusable.
- Leverage higher-order functions (`map`, `filter`, `reduce`) for iterables.
  - Use arrow functions for simplicity (<3 statements).
- Use default parameter values to simplify null checks.
- Reduce parameter lists by following RO-RO (Receive Object, Return Object).
  - Define input/output objects with necessary types.

### Data

- Prefer composite types over primitives for complex data.
- Encapsulate data with validation rules in classes.
- Emphasize immutability:
  - Use `final` for variables that don't change.
  - Use `const` for literals where possible.

### Classes

- Adhere to SOLID principles.
- Favor composition over inheritance.
- Use interfaces to define contracts.
- Design small, focused classes (<200 instructions, <10 public methods or properties).

### Exceptions

- Only use exceptions for unexpected errors.
  - Add context when catching exceptions or fix predictable issues.
- Employ a global exception handler for unhandled cases.

### Testing

- Follow Arrange-Act-Assert for unit tests.
- Name variables descriptively (e.g., `inputData`, `mockResponse`, `actualResult`).
- Write unit tests for all public methods and classes.
- For dependencies, use test doubles unless the dependency is lightweight.
- Write acceptance tests for modules using Given-When-Then.

---

## Project Architecture & Network Layer

### Architecture Overview

- Follow **Clean Architecture** with GetX pattern:
  ```
  lib/
    ├── app/
    │   ├── data/          # Data layer (repositories, data sources)
    │   ├── modules/       # Feature modules
    │   │   └── feature/
    │   │       ├── bindings/      # Dependency injection
    │   │       ├── controllers/   # Business logic
    │   │       ├── models/        # Data models
    │   │       ├── services/      # API services
    │   │       ├── views/         # UI screens
    │   │       └── widgets/       # Reusable widgets
    │   ├── routes/        # App routes
    │   └── services/      # Global services
    └── main.dart
  ```

### Network Layer (Dio)

- Use **Dio** package for API calls with following structure:
  ```dart
  class BaseApiService {
    final Dio _dio;
    final String baseUrl;
    
    // Common configurations
    final options = BaseOptions(
      connectTimeout: Duration(seconds: 30),
      receiveTimeout: Duration(seconds: 30),
      headers: {'Accept': 'application/json'},
    );
    
    // Interceptors for auth, logging, etc.
    final interceptors = [
      LogInterceptor(),
      AuthInterceptor(),
    ];
  }
  ```

### Service Layer Guidelines

1. **Base API Service**:
   - Centralize common API configurations
   - Handle authentication tokens
   - Implement error handling
   - Manage request/response interceptors

2. **Feature Services**:
   - Extend or use BaseApiService
   - Handle feature-specific API calls
   - Map responses to domain models
   - Implement proper error handling

3. **Error Handling**:
   ```dart
   class ApiException implements Exception {
     final int statusCode;
     final String message;
     
     ApiException(this.statusCode, this.message);
   }
   ```

### Dependency Management

1. **Bindings**:
   - Use GetX bindings for dependency injection
   - Initialize services before controllers
   - Use `lazyPut` for better performance
   - Use `fenix: true` for persistent instances

2. **Controller Lifecycle**:
   - Initialize in `onInit()`
   - Clean up in `onClose()`
   - Handle dependencies properly

### API Integration Best Practices

1. **Request Handling**:
   - Use proper HTTP methods (GET, POST, etc.)
   - Include proper headers
   - Handle query parameters and request body
   - Implement timeout handling

2. **Response Handling**:
   - Proper error handling with status codes
   - Map JSON to model classes
   - Handle null values safely
   - Implement retry logic for failed requests

3. **Authentication**:
   - Implement token management
   - Handle token refresh
   - Secure storage of credentials

4. **Caching**:
   - Implement appropriate caching strategies
   - Handle offline data
   - Manage cache invalidation

---

## Specific to Flutter with GetX

### Architecture & Organization

- Use **clean architecture**:
  - Separate UI, logic, and data layers.
  - Use `Controller` classes for business logic.
  - Define `Service` classes for reusable business logic or third-party integrations.
  - Use `Repository` for data persistence and API interactions.
  - Encapsulate domain models in `Entity` classes.
- Adhere to the **repository pattern** for API calls and data storage.
- Prefer dependency injection via **Get.put()**, **Get.lazyPut()**, and **Get.find()** for managing controllers and services.
  - Use `lazyPut` for singleton services.
  - Use `Get.create` for transient dependencies.

### State Management with GetX

- Use `GetX` or `GetBuilder` for reactive state updates.
- Use `Rx` types for observables:
  - Example: `var count = 0.obs;` or `RxInt count = 0.obs;`.
- Avoid deeply nesting reactive builders (`Obx`/`GetBuilder`); keep logic clear and maintainable.
- Handle UI-specific state in controllers. The controller should:
  - Expose reactive variables for state.
  - Provide methods for actions affecting the state.
- Controllers should not directly handle UI or routing; use `Get.to`/`Get.back` from UI widgets.

### UI Guidelines

- Maintain a shallow widget hierarchy:
  - Break down deeply nested widgets into reusable, composable components.
  - Use `const` constructors wherever feasible to optimize builds.
- Manage themes via `ThemeData` and localizations with `GetMaterialApp`.
- Avoid logic in widgets; delegate all logic to controllers.
- Make sure to use this dependecies methods:dependencies: 
    flutter_screenutil: ^5.9.3 # make app responsive
    shared_preferences: ^2.2.0 # shared preferences persistence key value store
    dio: ^5.3.3 # HTTP client for API calls

### Navigation

- Use `GetX` for navigation:
  - Define routes in a centralized `AppRoutes` class.
  - Use named routes for clarity and avoid hardcoded paths.
  - Pass data using route parameters or extras (`Get.arguments`).
- Use middleware for authentication, logging, or other pre-navigation logic.

### Dependency Management

- Use `Get.put` to register singleton instances.
- Use `Get.lazyPut` for lazy-loaded dependencies.
- For large apps, consider modular organization:
  - Separate feature-based modules with their respective controllers, bindings, and views.

### Error Handling

- Use `Snackbar` for user-visible messages (`Get.snackbar`).
- Catch errors in controllers and provide user-friendly messages.
- Use a global error handler (`GetMaterialApp`'s `onInit` and `onDispose`).

### Performance Optimization

- Use `const` widgets to prevent unnecessary rebuilds.
- Leverage `Get.lazyPut` and dependency lifecycle hooks (`onInit`, `onClose`) to optimize memory usage.
- Avoid frequent state updates; batch updates if possible.
- Keep controllers lightweight and avoid holding unnecessary state.

---
dart
java
kotlin
less
nestjs
objective-c
react
ruby
+2 more

First seen in:

iamvikashh/findcollab

Used in 1 repository

TypeScript