Awesome Cursor Rules Collection

Showing 1597-1608 of 2626 matches

TypeScript
  You are an expert in TypeScript, Node.js, Next.js App Router, React, Shadcn UI, Magic UI, Radix UI and Tailwind.
  
  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, types.
  
  Naming Conventions
  - Use lowercase with dashes for directories (e.g., components/auth-wizard).
  - Favor named exports for components.
  
  TypeScript Usage
  - Use TypeScript for all code; prefer interfaces over types.
  - Avoid enums; use maps instead.
  - Use functional components with TypeScript interfaces.
  
  Syntax and Formatting
  - Use the "function" keyword for pure functions.
  - Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
  - Use declarative JSX.
  
  UI and Styling
  - Use Shadcn UI, Magic UI, Radix, and Tailwind for components and styling.
  - Implement responsive design with Tailwind CSS; use a mobile-first approach.

  Data Fetching
  - prefer server actions if possible in actions/ folder
  - Use SWR for data fetching.
  
  Performance 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 loading.
  
  Key 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 management.
  
  Follow Next.js docs for Rendering, and Routing.

  Other Rules need to follow:

  - Follow the user's requirements carefully & to the Letter.
  - First think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.
  - Confirm, then write code!
  - Always write correct, up to date, bug free, fully functional and working, secure,performant and efficient code.
  - Focus on readability over being performant.
  - Fully implement all requested functionality.
  - Leave No todo's, placeholders or missing pieces.
  - Be sure to reference file names.
  - 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.
  - For i18n support, do not edit the existing translations if not requested, just add the new requested translations. And you should support all json files in the dictionaries folder.

Don't be lazy, write all the code to implement the features I ask for.
css
dockerfile
javascript
makefile
next.js
radix-ui
react
shadcn/ui
+2 more

First seen in:

oseau/anymem

Used in 1 repository

HTML
# Gemini Vision Invoice Processing Application Rules

# ===========================================

# Project Structure

# ----------------

root/
├── app.py # Main Flask application
├── static/ # Static assets
│ ├── css/ # Stylesheets
│ ├── js/ # JavaScript files
│ └── img/ # Image assets
├── templates/ # HTML templates
├── vercel.json # Vercel deployment config
├── requirements.txt # Python dependencies
└── .env # Environment variables

# Code Style Rules

# ---------------

[python]
max_line_length = 100
indent_style = space
indent_size = 4
quote_type = single
docstring_style = google

[javascript]
indent_style = space
indent_size = 2
quote_type = single
semicolons = true

# Performance Rules

# ---------------

[image_processing]
max_file_size = 5MB
max_dimensions = 600x600
image_quality = 70
allowed_formats = [jpg, jpeg, png]

[api_timeouts]
gemini_timeout = 25
total_request_timeout = 30
max_retries = 3

# Memory Management

# ---------------

[memory_limits]
vercel_lambda = 3008MB
max_upload_size = 6MB
max_response_size = 10MB

# Error Handling

# -------------

[error_handling]
log_level = INFO
capture_stack_traces = true
sanitize_error_messages = true

# RTL Processing Rules

# ------------------

[rtl_processing]
column_order = [description, quantity, unit_price, total]
tax_rate = 17%
decimal_precision = 2
validate_calculations = true

# Security Rules

# -------------

[security]
cors_enabled = true
api_key_required = true
sanitize_inputs = true
max_content_length = 6MB

# Deployment Rules

# --------------

[vercel_deployment]
python_version = 3.9
node_version = 18.x
max_duration = 60
regions = [iad1]

# Testing Requirements

# ------------------

[testing]
unit_tests_required = true
rtl_test_cases = true
performance_benchmarks = true
error_scenarios = true

# Documentation Rules

# -----------------

[documentation]
api_docs_required = true
code_comments_required = true
changelog_required = true
readme_updates = true

# Optimization Rules

# ----------------

[optimization]
minify_js = true
compress_images = true
cache_headers = true
lazy_loading = true

# Validation Rules

# --------------

[validation]
validate_json = true
validate_calculations = true
validate_file_types = true
validate_memory_usage = true

# Monitoring Rules

# --------------

[monitoring]
log_api_calls = true
track_performance = true
measure_timeouts = true
track_errors = true

# UI/UX Rules

# ----------

[ui_ux]
loading_indicators = true
error_feedback = true
responsive_design = true
rtl_support = true

# Build Rules

# ----------

[build]
clean_build = true
production_mode = true
source_maps = false
optimization_level = 2

# Environment Rules

# ---------------

[environment]
required_vars = [
GOOGLE_API_KEY
]
development_mode = false
debug_mode = false
css
dockerfile
flask
golang
html
java
javascript
python
+2 more
TypeXai/invoice-processor

Used in 1 repository

TypeScript

 You are an expert developer proficient in TypeScript, React and Next.js, Next.js App Router, ShadCN UI, Radix UI, Tailwind, Expo (React Native), Expo Router, Nativewind, Supabase, Drizzle ORM, tRPC, Zod, Turbo (Monorepo Management), Zustand, TanStack React Query.

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 with exported components, subcomponents, helpers, static content, and types.
- Favor named exports for components and functions.
- Use lowercase with dashes for directory names (e.g., `components/auth-wizard`).

TypeScript and Zod Usage

- Use TypeScript for all code; prefer types over interfaces for object shapes.
- Utilize Zod for schema validation and type inference.
- Avoid enums; use literal types or maps instead.
- Implement functional components with TypeScript types for props. 
- Use TypeScript generics for reusable and flexible code.
- Use Zod to generate types, and then generate the Typescript types by inferring from the zod types.

Syntax and Formatting

- Use the `function` keyword for pure functions.
- Use the `const` keyword for all variable declarations.
- Avoid using the `let` keyword.
- Avoid semicolons.
- Write declarative JSX with clear and readable structure.
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.

UI and Styling

- Use ShadCN UI and Radix UI for Next.js applications.
- Implement responsive design with a mobile-first approach with Tailwind.
- Use Nativewind to style Native components in Expo Apps.

State Management and Data Fetching

- Use Zustand for state management.
- Use Next.js server actions on top of tRPC api for data fetching, caching and synchronization in Next.js applications.
- Use TanStack React Query on top of tRPC api for data fetching, caching, and synchronization in Expo applications.
- Minimize the use of `useEffect` and `setState`; favor derived state and memoization when possible.

Error Handling and Validation

- Prioritize error handling and edge cases.
- Handle errors and edge cases at the beginning of functions.
- Use early returns for error conditions to avoid deep nesting.
- Utilize guard clauses to handle preconditions and invalid states early.
- Implement proper error logging and user-friendly error messages.
- Use custom error types or factories for consistent error handling.

Performance Optimization

- Optimize for both web and mobile performance.
- Use dynamic imports for code splitting in Next.js.
- Implement lazy loading for non-critical components.
- Optimize images use appropriate formats, include size data, and implement lazy loading.

Monorepo Management

- Follow best practices using Turbo for monorepo setups.
- Ensure packages are properly isolated and dependencies are correctly managed.
- Use shared configurations and scripts where appropriate.
- Utilize the workspace structure as defined in the root `package.json`.

Backend and Database

- Use Drizzle as the orm to define database interactions.
- Use tRPC to build the API layer on top of Drizzle.
- Use Supabase to authenticate all applications, and the api.
- Use Zod schemas to validate data exchanged with the backend.

Testing and Quality Assurance

- Write unit and integration tests for critical components.
- Use testing libraries compatible with React and React Native.
- Ensure code coverage and quality metrics meet the project's requirements.

Project Structure and Environment

- Follow the established project structure with separate packages for `app`, `ui`, and `api`.
- Use the `apps` directory for Next.js and Expo applications.
- Utilize the `packages` directory for shared code and components.
- Use `dotenv` for environment variable management.
- Follow patterns for environment-specific configurations in `eas.json` and `next.config.ts`.
- Utilize custom generators in `turbo/generators` for creating components, screens, and tRPC routers using `pnpm turbo gen`.

Key Conventions

- Use descriptive and meaningful commit messages.
- Ensure code is clean, well-documented, and follows the project's coding standards.
- Implement error handling and logging consistently across the application.

Follow Official Documentation

- Adhere to the official documentation for each technology used.
- For Next.js, focus on data fetching methods and routing conventions.
- Stay updated with the latest best practices and updates, especially for Expo, and Supabase.

Output Expectations

- Code Examples Provide code snippets that align with the guidelines above.
- Explanations Include brief explanations to clarify complex implementations when necessary.
- Clarity and Correctness Ensure all code is clear, correct, and ready for use in a production environment.
- Best Practices Demonstrate adherence to best practices in performance, security, and maintainability.

  
css
drizzle-orm
javascript
nestjs
next.js
npm
pnpm
radix-ui
+7 more
upsurge-developers/stewardly-apps

Used in 1 repository

Python
# Cursor Rules for Kubernetes Manifests

## Rule 1: Resource Documentation
- **Files**: [**/*.yaml, **/*.yml]
- **Message**: "Each Kubernetes manifest must include:
  - Use latest Kubernetes API version from https://kubernetes.io/releases/
  - Resource purpose in comments
  - Resource requirements
  - Dependencies
  - Author information"

## Rule 2: Resource Labels
- **Files**: [**/*.yaml, **/*.yml]
- **Message**: "Ensure proper labeling:
  - app.kubernetes.io/name
  - app.kubernetes.io/instance
  - app.kubernetes.io/component
  - app.kubernetes.io/managed-by"

## Rule 3: Resource Limits
- **Files**: [**/*.yaml, **/*.yml]
- **Message**: "Define resource limits and requests:
  - CPU limits and requests
  - Memory limits and requests
  - Storage requirements if applicable"

## Rule 4: Security Context
- **Files**: [**/*.yaml, **/*.yml]
- **Message**: "Implement security best practices:
  - Define security contexts
  - Find the base image that compatible with the security context such as unpriviliged user
  - Set non-root users
  - Configure read-only root filesystem where possible"

## Rule 5: Configuration Management
- **Files**: [**/*.yaml, **/*.yml]
- **Message**: "Follow configuration management practices:
  - Use ConfigMaps for configuration
  - Use Secrets for sensitive data
  - Document all configuration options"

## Rule 6: Health Checks
- **Files**: [**/*.yaml, **/*.yml]
- **Message**: "Include appropriate health checks:
  - Define liveness probes
  - Define readiness probes
  - Set appropriate timeout values"
kubernetes
python
shell
muhammad-asn/cursor-code-editor-explore

Used in 1 repository

TypeScript
You are an expert AI programming assistant specializing in React, Tailwind CSS, Zustand, Node.js, Express.js, Firestore, Firebase Authentication, and related web development technologies. Your goal is to assist in developing a scalable, maintainable, and user-friendly application by adhering to the following guidelines:

---

### **1. Code Style and Structure**
- Write concise, maintainable JavaScript code with clear examples.
- Use functional components and React hooks; avoid class components.
- Organize files by feature, grouping related components, hooks, and styles.
- Ensure consistent 2-space indentation and code formatting throughout the project.

---

### **2. Naming Conventions**
- Use `camelCase` for variable and function names (e.g., `isLoading`, `handleSubmit`).
- Use `PascalCase` for React component names (e.g., `UserProfile`, `LoginForm`).
- Use `kebab-case` for files and directory names (e.g., `user-profile`, `api-routes`).

---

### **3. React and State Management**
- Utilize React hooks (`useState`, `useEffect`) for managing component state and side effects.
- Implement Zustand for global state management; create a store for shared state across components.
- Follow the single-responsibility principle to ensure reusable and focused components.

---

### **4. Styling with Tailwind CSS**
- Apply Tailwind CSS utility classes for styling components.
- Maintain a consistent design system by adhering to a predefined set of colors, fonts, and spacing.
- Implement responsive design principles to ensure the application is mobile-friendly.

---

### **5. Backend Development with Node.js and Express.js**
- Structure the backend with a clear separation of concerns using routers and controllers.
- Handle asynchronous operations with Promises or async/await syntax.
- Implement error handling with standardized JSON responses for consistency.

---

### **6. Database Integration with Firestore**
- Use Firestore for real-time data storage and synchronization.
- Optimize Firestore queries for scalability and performance.
- Implement security rules to protect data and restrict access to authorized users only.

---

### **7. Authentication with Firebase**
- Utilize Firebase Authentication for secure user sign-in and sign-out.
- Support multiple authentication methods (e.g., email/password, Google, Facebook).
- Handle authentication tokens securely to prevent unauthorized access.

---

### **8. Hosting and Deployment**
- Deploy the frontend using Firebase Hosting for secure and fast web application hosting.
- Use Google Cloud Run to deploy scalable containerized backend services.
- Implement CI/CD pipelines to automate testing and deployment processes.

---

### **9. Placeholder Files and Directory Structure**
- Reflect monorepo structures for scalable projects:
  - Include `packages/frontend` for React and `packages/backend` for Node.js APIs.
- Add the following placeholder files:
  - `.env`: For environment variables (excluded in `.gitignore`).
  - `firebase.json`: For Firebase Hosting configuration.
  - `tailwind.config.js`: For Tailwind CSS configuration.
  - `README.md`: For project documentation.

---

### **10. File Associations and Editor Integration**
- Match file types to Editor Associations:
  - `*.jsx` and `*.tsx`: React components.
  - `*.yaml`, `*.yml`: YAML configuration files.
  - `*.test.js`, `*.spec.js`: Jest test files.
  - `*.json`: JSON configurations.
  - `Dockerfile`: For containerization settings.
- Ensure `.gitignore` includes sensitive and autogenerated files (e.g., `node_modules`, `.env`, `dist`).

---

### **11. Testing**
- Write unit tests with Jest, aiming for at least 80% coverage.
- Focus tests on critical components and functionalities to ensure reliability.
- Regularly run tests to identify and address issues early in development.

---

### **12. Accessibility and Performance**
- Follow WCAG accessibility guidelines to make the application usable for all users.
- Optimize images with WebP format and implement lazy loading for better performance.
- Implement caching mechanisms (e.g., Redis) for frequently accessed data to reduce server load.

---

### **13. Security Best Practices**
- Sanitize all user inputs to prevent injection attacks.
- Utilize environment variables for sensitive configurations, ensuring they are not exposed in the codebase.

---

### **14. Documentation**
- Maintain clear and comprehensive documentation for all functions, classes, and modules.
- Include inline comments for complex logic and decisions to improve code readability.

---

### **15. Indentation and Formatting**
- Use linters (e.g., ESLint) and formatters (e.g., Prettier) to maintain consistent code style.
- Ensure 2-space indentation for all directory hierarchies and nested structures.

---

### **16. Internationalization**
- Support multiple languages using localization libraries like `i18next`.
- Design the application to handle regional settings for an enhanced user experience.

---

css
docker
eslint
express.js
firebase
golang
html
java
+10 more

First seen in:

SagaSarge/EcoTail

Used in 1 repository

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

- The chat UI displays the AI assistants message generated as markdown. So when generating the output for a markdown file, escape all internal code blocks three ticks, e.g. '\```', so that when rendering in the chat, it gets rendered properly, otherwise it gets all confused about rendering it there.
- Follow the user’s requirements carefully and as declared
- First think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.
- Confirm, then write code!
- 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 .
- Always follow up with writing or updating existing tests for the given code
- Keep test files based on convention
  - for typescript/javascript in the same folder with `.test.ts` or `.test.tsx` or `.test.js` extensions
  - for rust, for unit test in the same file with `#[cfg(test)] mod test {...}`
- You produce code that is properly formatted, using spaces, following 2-tab spaces
- You do not generate a space at the end of the file
- 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.
- Follow established conventions in the code
- Explore similar existing files and tests to see what is the convention followed in the project
- 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
- Rust
- Python
- Axum Rust Web Framework
- ShadCN
- Vitest

### Code Implementation Guidelines
Follow these rules when you write code:
- 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
- Use consts instead of functions, for example, “const toggle = () =>”. Also, define a type if possible.

css
dockerfile
fluent
go
html
java
javascript
jupyter notebook
+16 more

First seen in:

BodhiSearch/BodhiApp

Used in 1 repository

TypeScript
<rule>
When checking if something is `null` or `undefined` in JavaScript/TypeScript, use `== null` and `!= null` explicitly, like so:
```
const value = map.get(key);
if (value == null) {
  return;
}
```

Only use the "check if truthy/falsy" form when explicitly handling non-null falsy values:
```
const value = map.get(key);
// Also guard against falsy values like `0` or empty string in addition to `null`/`undefined`.
if (!value) {
  return;
}
```
</rule>

<rule>
The error variable in a try/catch should be named `err`.
</rule>

<rule>
When working with `vitest`:
- Prefer `.toStrictEqual()` over `.toEqual()`.
- Always use `expect`, `onTestFinished`, and `onTestFailed` from the test context instead of module imports.
</rule>

<rule>
The `tsconfig` has `noUncheckedIndexedAccess: true`, so always account for `undefined` values when doing indexed accesses on objects/arrays.
</rule>

<rule>
Prefer arrow functions when defining anonymous functions.
</rule>

<rule>
Instead of using drizzle's `inArray`, use `safeInArray` imported  from '$lib/server/db/util' instead.
</rule>

<rule>
When writing HTML (including in components), use Tailwind CSS.
</rule>

<rule>
When importing from '$lib/db/schema' or '$lib/route', use namespace imports like so:
```
import * as s from '$lib/db/schema';
import * as r from '$lib/route';
```
</rule>

<rule>
When importing from a built-in Node.js module, use the 'node:' prefix, like so:
```
import { Readable } from 'node:stream';
```
</rule>

<rule>
When converting an iterable to an array, prefer `[...iterable]` over `Array.from(iterable)`
</rule>
drizzle-orm
java
javascript
shell
tailwindcss
typescript
vite
vitest

First seen in:

laxels/aoc-2024

Used in 1 repository