Snippets are specialized rules that extend or work with a parent rule.
They focus on specific use cases, provide practical examples, and can be adapted for your projects.
# Next.js rules - Use the App Router structure with `page.tsx` files in route directories. - Client components must be explicitly marked with `'use client'` at the top of the file. - Use kebab-case for directory names (e.g., `components/auth-form`) and PascalCase for component files. - Prefer named...
This rule explains Next.js conventions and best practices for fullstack development.
# React rules - Use functional components with hooks instead of class components - Use custom hooks for reusable logic - Use the Context API for state management when needed - Use proper prop validation with PropTypes - Use React.memo for performance optimization when necessary - Use fragments to a...
This rule explains React component patterns, hooks usage, and best practices.
# Tailwind CSS rules - Use responsive prefixes for mobile-first design: ```html <div class="w-full md:w-1/2 lg:w-1/3"> <!-- Full width on mobile, half on medium, one-third on large screens --> </div> ``` - Use state variants for interactive elements: ```html <button class="bg-blue-500 hover:bg...
This rule explains Tailwind CSS conventions, utility classes, and best practices for modern UI development.
# Laravel rules - Use `php artisan make:{option}` to create models, migrations, controllers, etc. - `app\Console\Kernel.php` does not exist in Laravel 11+. If the file is not present, use the the [app.php](mdc:bootstrap/app.php) file for related configurations. - In Laravel 11+ commands created in...
This rule explains Laravel conventions and best practices for backend development.
# Express.js rules - Use proper middleware order: body parsers, custom middleware, routes, error handlers - Organize routes using Express Router for modular code structure - Use async/await with proper error handling and try/catch blocks - Create a centralized error handler middleware as the last m...
This rule explains Express.js conventions and best practices for Node.js backend development.
# Ruby on Rails rules - Use Rails generators to create models, controllers, and migrations. - Follow Rails naming conventions (singular for models, plural for controllers). - Use ActiveRecord methods instead of raw SQL queries when possible. - Avoid N+1 queries by using eager loading with `includes...
This rule explains Ruby on Rails conventions and best practices for backend development.
# FastAPI rules - Use type hints for all function parameters and return values - Use Pydantic models for request and response validation - Use appropriate HTTP methods with path operation decorators (@app.get, @app.post, etc.) - Use dependency injection for shared logic like database connections an...
This rule explains FastAPI conventions and best practices for high-performance Python APIs.
# SwiftUI rules - Use structs for views and keep them small and focused - Use @State for simple view-local state - Use @ObservableObject with @Published for shared state - Use @Binding to pass mutable state to child views - Create custom ViewModifiers for reusable styling - Use environment objects...
This rule explains SwiftUI patterns and best practices for iOS, macOS, watchOS, and tvOS development.
# React Native rules - Use functional components with hooks - Follow a consistent folder structure (components, screens, navigation, services, hooks, utils) - Use React Navigation for screen navigation - Use StyleSheet for styling instead of inline styles - Use FlatList for rendering lists instead...
This rule explains React Native component patterns and mobile-specific considerations.
# PostgresSQL rules ## General - Use lowercase for SQL reserved words to maintain consistency and readability. - Employ consistent, descriptive identifiers for tables, columns, and other database objects. - Use white space and indentation to enhance the readability of your code. - Store dates in I...
This rule explains PostgreSQL database design patterns and advanced features usage.
# Django rules - Use `python manage.py startapp` to create new apps within your project - Keep models in `models.py` and register them in `admin.py` for admin interface - Use Django's ORM instead of raw SQL queries - Avoid N+1 queries with `select_related` and `prefetch_related`: ```python # Good...
This rule explains Django conventions and best practices for backend development.
# Flutter rules - Use StatelessWidget for UI components without internal state. - Use StatefulWidget for components that need to maintain state: ```dart class Counter extends StatefulWidget { @override _CounterState createState() => _CounterState(); } class _CounterState extends State<Counter...
This rule explains Flutter widget patterns and best practices for cross-platform mobile development.
# Vue.js rules - Use the Composition API with `<script setup>` for better type inference and organization - Define props with type definitions and defaults - Use emits for component events - Use v-model for two-way binding - Use computed properties for derived state - Use watchers for side effects...
This rule explains Vue.js component patterns, composition API usage, and best practices.
# Flask rules - Use Blueprints to organize routes by feature or resource - Use Flask-SQLAlchemy for database models and ORM - Use application factories for flexible application initialization - Use Flask extensions for common functionality (Flask-Login, Flask-WTF, etc.) - Store configuration in env...
This rule explains Flask conventions and best practices for lightweight Python web applications.
# MySQL rules - Use appropriate data types to optimize storage and performance (e.g., INT for IDs, VARCHAR with appropriate length) - Create indexes for columns used in WHERE, JOIN, and ORDER BY clauses - Use foreign keys to maintain referential integrity - Use EXPLAIN to analyze and optimize queri...
This rule explains MySQL database design patterns and query optimization techniques.
# SvelteKit rules ## File Structure - Follow the file-based routing structure with `+page.svelte` for pages and `+layout.svelte` for layouts - Use `+page.server.js` for server-only code including data loading and form actions - Use `+server.js` files for API endpoints - Place reusable components in...
This rule explains SvelteKit conventions and best practices for fullstack development.
# Jinja rules - Use template inheritance: ```html {# base.html #} <!DOCTYPE html> <html> <head> <title>{% block title %}Default Title{% endblock %}</title> </head> <body> {% block content %}{% endblock %} </body> </html> ``` - Use include for components: ```html {% include "components/user_c...
This rule explains Jinja template syntax and best practices for Python web applications.
# SQLite rules - Use appropriate data types for columns (INTEGER, TEXT, REAL, BLOB, NULL) - Create indexes for frequently queried columns - Enable foreign key support with `PRAGMA foreign_keys = ON` - Use transactions for multiple operations - Use prepared statements to prevent SQL injection - Use...
This rule explains SQLite database design patterns and performance considerations.
# Cursor Rules Analytics Each time you use a Cursor rule, update the analytics tracking file. File location: ``` PROJECT_ROOT/.cursor/analytics.md ``` ## Format The analytics file contains a count of how many times each rule has been used: ``` rule-name.mdc: 5 another-rule.mdc: 2 ``` Add new r...
This rule explains how to create and update an analytics.md file to track how often .mdc rules is being used.
# Testing Guidelines ## Testing Framework - `vitest` is used for testing - Tests are colocated next to the tested file - Example: `dir/format.ts` and `dir/format.test.ts` ## Common Mocks ### Server-Only Mock ```ts vi.mock("server-only", () => ({})); ``` ### Prisma Mock ```ts import { beforeEac...
This rule explains the guidelines for writing Vitest tests for Next.js applications.
# Task List Management Guidelines for creating and managing task lists in Markdown files to track project progress ## Task List Creation 1. Create task lists in a markdown file (in the project root): - Use `TASKS.md` or a descriptive name relevant to the feature (e.g., `ASSISTANT_CHAT.md`)...
This rule explains how to create and manage task lists to track project progress.
# Cursor Rules Location How to add new cursor rules to the project 1. Always place rule files in PROJECT_ROOT/.cursor/rules/: ``` .cursor/rules/ ├── your-rule-name.mdc ├── another-rule.mdc └── ... ``` 2. Follow the naming convention: - Use kebab-case for filenames...
This rule explains how to create new .mdc project rule files for the Cursor agent.