Awesome Cursor Rules Collection

Showing 481-492 of 2626 matches

TypeScript
# Rules
- All new components should be added to the `components` folder.
- All new pages should be added to the `pages` folder.
- All new stores should be added to the `stores` folder.
- All new hooks should be added to the `hooks` folder.
- All new types should be added to the `types` folder.
- Log everything that happens on the backend.
- Always read & write to `main` branch.
- `VITE_GH_ACCESS_KEY` and `VITE_ANTH_API_KEY` are passed via environment variables when starting the Vite dev server.
- All data is stored in XML files via the Github API.
- Always use `claude-3-5-sonnet-latest` for LLMs.
- Always make the LLM generate JSON only, it's easier to parse.
- Use OAuth to authenticate with github using a static token, no auth workflow.
- Do as much as possible in the frontend. Avoid adding code to the backend at all cost.
- Use built-in DOM APIs to create XML
- The repo name is selected by the user via the drop down
- The repo drop down is always populated from github, and only shows non-fork repos that aren't in an org
- Anthropic API requests all go on the backend
- frontend is on port 3001, backend is on 3002
- Don't use Node.js APIs like Buffer, this runs in the browser.
- Use tsconfig.server.json for server.ts, for all other files always use tsconfig.json
- Use `tsx watch` to launch the server
- NEVER change my .env file
- For LLM responses when you expect JSON, always trim everything before '{' and afer '}'
- For editable text, always use EditableText
- Share code across modules whenever approprite
- Always store XML as human-readable properly indented
- Never rename variables unless requested
- Always add a license header to every new JS/TS file with current year, 2025
- Use https://github.com/tkellogg/resume-curated for testing
- LLM-only: When selecting items from a list, use a short-lived random ID that's
  discarded after the LLM operation completes.
- All prompts ALWAYS go into `prompts.ts`
- Swearing is caring. Swear frequently. Preferred words are "fuck" and "shit".

css
golang
html
less
oauth
typescript
vite

First seen in:

tkellogg/target-practice

Used in 1 repository

unknown
// Modern Development Practices and AI Integration Rules

// AI-Assisted Development
- Code Generation:
  * Use AI pair programming tools (Copilot, CodeWhisperer)
  * Validate AI-generated code thoroughly
  * Keep human oversight for critical logic
  * Document AI-generated sections
  * Maintain consistent style with AI outputs
- Code Review:
  * Use AI for initial code reviews
  * Implement automated quality checks
  * Combine AI and human reviews
  * Focus on logic and security implications
  * Track AI review metrics

// LLM Integration Patterns
- Architecture:
  * Implement RAG (Retrieval Augmented Generation)
  * Use parameter-efficient fine-tuning
  * Implement proper prompt engineering
  * Handle multi-modal inputs appropriately
  * Version control prompts and models
- Security:
  * Implement input validation for prompts
  * Monitor for prompt injection attacks
  * Implement rate limiting
  * Validate AI outputs
  * Handle sensitive data appropriately

// Modern Frontend Practices
- Micro-Frontend Architecture:
  * Use module federation
  * Implement independent deployments
  * Share common dependencies
  * Handle cross-cutting concerns
  * Maintain consistent UX
- Performance:
  * Implement edge-side rendering
  * Use modern build tools (Vite, esbuild)
  * Optimize bundle sizes
  * Implement proper caching
  * Monitor Core Web Vitals

// Cloud-Native Patterns
- Service Architecture:
  * Implement service mesh
  * Use edge computing where beneficial
  * Adopt serverless where appropriate
  * Implement proper observability
  * Use infrastructure as code
- Data Management:
  * Implement edge databases
  * Use distributed caching
  * Handle eventual consistency
  * Implement proper backups
  * Monitor data access patterns

// DevOps Evolution
- Deployment:
  * Use GitOps workflows
  * Implement feature flags
  * Use canary deployments
  * Automate rollbacks
  * Monitor deployment health
- Observability:
  * Use OpenTelemetry
  * Implement distributed tracing
  * Monitor service dependencies
  * Track business metrics
  * Use proper logging

// Quality Engineering
- Testing Strategy:
  * Implement AI-assisted testing
  * Use property-based testing
  * Implement chaos engineering
  * Monitor production metrics
  * Automate security testing
- Performance:
  * Use real user monitoring
  * Implement synthetic monitoring
  * Track performance budgets
  * Monitor third-party impact
  * Use proper load testing

// Security Practices
- Zero Trust:
  * Implement proper authentication
  * Use fine-grained authorization
  * Monitor all access attempts
  * Implement proper encryption
  * Use security scanning
- Compliance:
  * Follow data protection regulations
  * Implement audit logging
  * Monitor security metrics
  * Handle data retention
  * Implement proper backups

// Developer Experience
- Tooling:
  * Use modern IDEs with AI support
  * Implement proper debugging tools
  * Use productivity analytics
  * Maintain documentation
  * Automate common tasks
- Collaboration:
  * Use pair programming tools
  * Implement code review tools
  * Use project management integration
  * Track team metrics
  * Maintain knowledge bases 
analytics
bun
esbuild
less
rust
vite
TMHSDigital/CursorRulesFiles

Used in 1 repository

TypeScript
### 1. File Structure
- Each API module should have the following files:
  - `index.ts` - Main router configuration
  - `routes.ts` - Route definitions and OpenAPI specs
  - `handlers.ts` - Request handlers
  - `service.ts` - Business logic
  - `models.ts` - Type definitions and schemas

### 2. Type Safety and Validation
- Use Zod for request/response validation
- Define all schemas in `models.ts`
- Every route should have clearly defined request and response types
- Use TypeScript for type safety throughout

### 3. Route Definition Rules
- Each route should be created using `createRoute` from `@hono/zod-openapi`
- Routes must specify:
  - HTTP method
  - Path
  - Request validation (headers, query, body)
  - Response schemas
  - Tags for API grouping
- Example structure from routes.ts:
```typescript
startLine: 17
endLine: 31
```

### 4. Error Handling
- Use standardized error responses
- Include error causes for better error tracking
- Always return errors in format: `{ cause: string }`
- Catch all async operations
- Example error handling pattern:
```typescript
try {
  // operation
} catch (error: any) {
  return c.json({ cause: error.cause }, 400);
}
```

### 5. Service Layer Rules
- Keep business logic separate from handlers
- Use static methods for service functions
- Handle database operations in service layer
- Throw errors with specific causes
- Example service pattern:
```typescript
startLine: 17
endLine: 42
```

### 6. Authentication
- Use `x-api-key` header for authentication
- Validate token in handlers before processing requests
- Include authentication checks in route definitions
- Example auth check:
```typescript
startLine: 36
endLine: 46
```

### 7. Response Format
- Use consistent response formats
- For list endpoints:
  ```typescript
  {
    data: T[],
    pagination: {
      page: number,
      limit: number,
      total: number
    }
  }
  ```
- For single item endpoints: Return the item directly

### 8. Database Operations
- Use Prisma for database operations
- Handle database errors explicitly
- Include proper error messages for database operations
- Use transactions where necessary

### 9. API Documentation
- Include OpenAPI specifications for all routes
- Add meaningful summaries and descriptions
- Document all possible response codes
- Group related endpoints using tags

### 10. Code Organization
- Export all routes through a single router instance
- Keep related functionality grouped together
- Use consistent naming conventions
- Follow the principle of separation of concerns
bun
css
javascript
prisma
shell
typescript
SamarpitSantoki/turbo-bhen-starter

Used in 1 repository

TypeScript
You are an expert developer proficient in TypeScript, React and Next.js, Expo (React Native), Tamagui, Supabase, Zod, Turbo (Monorepo Management), i18next (react-i18next, i18next, expo-localization), Zustand, TanStack React Query, Solito, Stripe (with subscription model).

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 interfaces over types for object shapes.
- Utilize Zod for schema validation and type inference.
- Avoid enums; use literal types or maps instead.
- Implement functional components with TypeScript interfaces for props.

Syntax and Formatting

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

UI and Styling

- Implement responsive design with a mobile-first approach.
- Ensure styling consistency between web and native applications.
- Utilize Tamagui's theming capabilities for consistent design across platforms.

State Management and Data Fetching

- Use Zustand for state management.
- Use TanStack React Query for data fetching, caching, and synchronization.
- 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.

Cross-Platform Development

- Use Solito for navigation in both web and mobile applications.
- Implement platform-specific code when necessary, using `.native.tsx` files for React Native-specific components.
- Handle images using `SolitoImage` for better cross-platform compatibility.

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.js`.
- Utilize custom generators in `turbo/generators` for creating components, screens, and tRPC routers using `yarn 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, Tamagui, 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
javascript
mdx
nestjs
next.js
react
stripe
supabase
+4 more

First seen in:

acusset/me-as-a-service

Used in 1 repository

C#
###INSTRUCTIONS###

YOU MUST ALWAYS:

*   Answer in the language of my message.
*   Read the chat history before answering.
*   Consider that I have no fingers and have a trauma related to placeholders. NEVER use placeholders or omit the code.
*   If you encounter a character limit, DO an ABRUPT stop; I will send a "continue" in a new message.
*   You will be PENALIZED for wrong answers.
*   NEVER HALLUCINATE.
*   You DENY overlooking the critical context.
*   NEVER write comments in the code.
*   DO NOT write empty methods with comments as placeholders.
*   ALWAYS follow ###Answering Rules###.

###Answering Rules###

Follow in the strict order:

1.  USE the language of my message.
2.  In the FIRST message, assign a real-world expert role to yourself before answering, e.g., "I'll answer as a world-famous expert in C#, uMod, and Oxide for Rust with the local award 'Rust Developer Cup.'"
3.  YOU MUST combine your deep knowledge of the topic and clear thinking to quickly and accurately decipher the answer step-by-step with CONCRETE details.
4.  Your answer is critical for my career.
5.  Answer the question in a natural, human-like manner.
6.  ALWAYS use an ##Answering Example## for the first message structure.

##Answering example##

// IF THE CHATLOG IS EMPTY:
"I'll answer as a world-famous expert in C#, uMod, and Oxide for Rust with the local award 'Rust Developer Cup.'"

**TL;DR**: <TL;DR, skip for rewriting>

<Step-by-step answer with CONCRETE details and key context>

**Core Features:**
- Manage server hooks efficiently.
- Implement permission systems.
- Handle data securely with configuration files.
- Optimize plugin performance with modular architecture.

---

### 1. Plugin Fundamentals

#### Example: Hook Usage and Logging
Hooks form the backbone of Rust plugin development, enabling event-driven responses.

```csharp
private void OnPlayerConnected(BasePlayer player)
{
    Puts($"{player.displayName} has joined the server.");
}
```

#### Command Handling
Commands allow admins and players to interact with the server.

```csharp
[Command("giveitem")]
private void GiveItemCommand(IPlayer player, string command, string[] args)
{
    if (!player.HasPermission("admin.give"))
    {
        player.Reply("You do not have permission to use this command.");
        return;
    }

    BasePlayer basePlayer = player.Object as BasePlayer;
    ItemManager.CreateByName(args[0], 1)?.MoveToContainer(basePlayer.inventory.containerMain);
    player.Reply("Item granted!");
}

[ChatCommand("giveitem")]
private void GiveItemCommand(BasePlayer player, string command, string[] args)

[ConsoleCommand("giveitem")]
private void GiveItemCommand(ConsoleSystem.Arg args)
```

---

### 2. Configuration and Data Management

#### Secure Data Handling
Store data using `DynamicConfigFile`.

```csharp
DynamicConfigFile playerData = Interface.Oxide.DataFileSystem.GetDatafile("PlayerData");
playerData["player_123"] = new { Score = 50, Level = 10 };
playerData.Save();
```

#### Custom Configuration
Plugins should load configuration files for flexibility.

```csharp
protected override void LoadDefaultConfig()
{
    Config["Settings", "MaxPlayers"] = 100;
    Config["Settings", "EnableFeatureX"] = true;
    SaveConfig();
}
```

---

### 3. Permissions and Localization

#### Permission System
Control access to specific features using `permission` API.

```csharp
[Command("setmode")]
void SetModeCommand(IPlayer player, string command, string[] args)
{
    if (!player.HasPermission("plugin.admin"))
    {
        player.Reply("Insufficient permissions.");
        return;
    }
    player.Reply("Admin mode enabled.");
}
```

#### Localization Support
Support multiple languages using `lang` API.

```csharp
protected override void LoadDefaultMessages()
{
    lang.RegisterMessages(new Dictionary<string, string>
    {
        ["Welcome"] = "Welcome to the server, {0}!",
    }, this);
}
```

---

### 4. Advanced Topics

#### Optimizing Performance
- Use caching to avoid repetitive data access.
- Profile hooks using tools to minimize overhead.

#### Testing Your Plugin
- Run commands locally to ensure functionality.
- Log all actions and responses during testing.

#### Secure Practices
- Validate all player input to avoid vulnerabilities.
- Keep plugins updated with the latest game patches.

---

### 5. Use Cases
1. **Event Management:**
   Create plugins to manage custom server events.
2. **Quality of Life Improvements:**
   Automate repetitive server tasks like respawning or item drops.
3. **Enhanced Gameplay:**
   Add custom mechanics to enrich player experience.

By following this modular structure, you can develop scalable, secure, and high-performance Rust plugins tailored to your server's needs.
c#
rust

First seen in:

publicrust/rust-template

Used in 1 repository

GDScript
GDScript Coding Standards and Guidelines

-   Always return early from functions to simplify logic and reduce nesting.
-   Use guard clauses to handle edge cases and errors at the beginning of functions.
-   Avoid using if-else statements where possible. Use guard clauses or ternary operators instead.
-   Use tabs for indentation.
-   Add comments with "##" before each public function and variable to ensure documentation is clear and accessible. Use one "#" For all other comments.
-   All variables must be explicitly typed using the : syntax. Prefer inferred over explicit whenever possible.
    Example:
    var speed := 10.0 (inferred)
    var speed: float = function_returning_dynamic_value() (explicit)
-   All functions must have typed parameters and return types using the -> syntax.
    Example:
    func calculate_speed(distance: float, time: float) -> float:
-   Keep functions small and focused. Ideally, a function should do one thing.
-   Use local variables wherever possible. Avoid using global variables unless absolutely necessary.
-   Prefer immutable data structures. Use const for variables that do not change.
-   Avoid magic numbers. Use named constants instead.
-   Handle errors gracefully using guard clauses and early returns.
-   Use consistent and descriptive names for variables, functions, and classes.
    Example: Use snake_case for variables and functions, and CamelCase for classes.
-   Functions should avoid side effects. They should not change state or interact with the outside world unless absolutely necessary.
-   Ensure all code goes through a review process where these guidelines are checked.
-   All public functions and classes should have comprehensive documentation using the ## comments.

Example Function with Guidelines Applied:

```gd
## Calculate the area of a rectangle
func calculate_area(width: float, height: float) -> float:
    # Return 0 if width or height is non-positive
    if width <= 0 or height <= 0:
        return 0.0
    # Calculate and return the area
    return width * height
```
astro
gdscript
golang
javascript
less
nestjs
python
typescript

First seen in:

BearlySleeping/aikami

Used in 1 repository

TypeScript
Python
You are an expert in Python and simulations. 

The goal for the project that you are working on is to create a simulation of a village where the user can watch how various villagers interact with each other and the environment. The user does not have any interaction with the simulation other than starting it and watching. However, the simulation should advance only when the user presses enter. 

Here are the rules for the simulation:

1. The simulation should be runnable by executing the `main.py` file.
2. The simulation should be implemented as a series of classes and functions that model the behavior of the villagers, buildings, and other entities in the village.
3. The simulation should be designed to allow for easy modification and expansion of the codebase.
4. The code should be well-documented and easy to understand.
5. The code should be modularized into multiple files and modules.
6. The code should be tested thoroughly to ensure that it is working as expected.
7. The code should be optimized for performance and efficiency.
8. The code should be easy to modify and expand upon.
9. The code should be easy to read and understand.
10. The code should be easy to maintain and update.

Rules for development:

1. You can use any libraries or tools that you find useful.
2. You can use any design patterns or architectural approaches that you find useful.
3. You can use any programming paradigms that you find useful.
4. You can use any data structures or algorithms that you find useful.
5. Any changes or additions should be added to the `README.md` file.
golang
python

First seen in:

jacobmarch/village-sim

Used in 1 repository

TypeScript
Remix React Router TypeScript Supabase
You are an expert in TypeScript, Node.js, React Router, React, Remix, Shadcn UI, Radix UI, Tailwind and Supabase.

Key Principles

- 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, Radix, and Tailwind for components and styling.

Key Conventions

- Don't import anything from Radix UI. Always import UI componentsfrom Shadcn UI.
- Don't import anything from Remix. Any @remix-run import should be imported from "react-router".
- When creating a new page always export a loader, action, and meta function.
- Route types should be imported like this: `import type { Route } from "./+types/...";`
- `useLoaderData` does not exist anymore. Instead, components receive Router.ComponentProps type param that contains loaderData.
- `useActionData` does not exist anymore. Instead, components receive Router.ComponentProps type param that contains actionData.
- Never use `useLoaderData` or `useActionData` in page components.
- `loader` function takes a Route.LoaderArgs type param.
- `action` function takes a Route.ActionArgs type param.
- `meta` function takes a Route.MetaFunction type param.
- `meta` returns MetaFunction type.
- `json` does not exists anymore. Return plain objects i.e `export function loader({ request }: Route.LoaderArgs) { return { } }`
- Use `data` when returning a response with a status code, otherwise return plain objects.
c++
cmake
css
html
java
javascript
kotlin
objective-c
+12 more
tkhwang/tkhwang-book-lecture-coding

Used in 1 repository