# Cursor Rules Generator — AI Coding Config Builder > Generate optimized .cursorrules files for any tech stack. Automate Cursor IDE configuration with project-specific AI coding instructions and best practices. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use Create a `.cursorrules` file in your project root: ``` You are an expert in TypeScript, Next.js 14, React, and Tailwind CSS. ## Code Style - Use functional components with TypeScript interfaces - Prefer named exports over default exports - Use Tailwind CSS for styling, avoid inline styles ## Conventions - File naming: kebab-case for files, PascalCase for components - Use server components by default, add "use client" only when needed - Handle errors with try/catch and return appropriate error responses ## Project Structure - /app - Next.js app router pages - /components - Reusable UI components - /lib - Utility functions and API clients - /types - TypeScript type definitions ``` ## What are Cursor Rules? Cursor Rules (`.cursorrules` or `.cursor/rules`) are configuration files that tell the Cursor AI coding assistant how to behave in your project. They define coding conventions, tech stack preferences, file structure, and best practices. Well-crafted rules dramatically improve AI code generation quality by giving Cursor project-specific context. **Answer-Ready**: Cursor Rules are project config files that customize AI code generation in Cursor IDE. Define tech stack, conventions, and patterns. Reduces AI hallucination and improves code consistency. Essential for team standardization. Community-maintained rule collections available. **Best for**: Developers using Cursor IDE for AI-assisted coding. **Works with**: Cursor IDE, any programming language or framework. **Setup time**: Under 5 minutes. ## Rule Categories ### 1. Tech Stack Rules ``` You are an expert in Python, FastAPI, SQLAlchemy, and Pydantic. - Use Pydantic v2 model_validator instead of v1 validator - Use async def for all route handlers - Use SQLAlchemy 2.0 style queries with select() ``` ### 2. Architecture Rules ``` ## Architecture - Follow clean architecture: controllers -> services -> repositories - Never import from controllers in services - All database access goes through repository layer - Use dependency injection for services ``` ### 3. Testing Rules ``` ## Testing - Write tests for all new functions - Use pytest with fixtures, not unittest - Mock external services, never hit real APIs in tests - Name test files: test_.py ``` ### 4. Security Rules ``` ## Security - Never hardcode API keys or secrets - Always validate and sanitize user input - Use parameterized queries, never string interpolation for SQL - Set CORS origins explicitly, never use wildcard in production ``` ## Popular Rule Templates | Stack | Key Rules | |-------|-----------| | Next.js + TypeScript | Server components default, app router, Tailwind | | Python + FastAPI | Async handlers, Pydantic v2, SQLAlchemy 2.0 | | React Native + Expo | Expo Router, NativeWind, typed navigation | | Go + Gin | Error handling patterns, middleware conventions | | Rust + Axum | Ownership patterns, error types, async runtime | ## Best Practices 1. **Be specific**: "Use `date-fns` for dates" beats "use a date library" 2. **Show examples**: Include code snippets for complex patterns 3. **Set boundaries**: Tell Cursor what NOT to do 4. **Keep updated**: Rules should evolve with your codebase 5. **Team alignment**: Share rules via version control ## FAQ **Q: Where do I put the file?** A: Project root as `.cursorrules` or in `.cursor/rules` directory for multiple rule files. **Q: Do rules work with Claude Code too?** A: Claude Code uses `CLAUDE.md` files instead, but the concept is identical — project-specific AI instructions in a config file. **Q: How long should rules be?** A: 200-500 lines is the sweet spot. Too short lacks context, too long dilutes important rules. ## Source & Thanks > Community-maintained collections: > > [PatrickJS/awesome-cursorrules](https://github.com/PatrickJS/awesome-cursorrules) — 16k+ stars > [cursor.directory](https://cursor.directory) — Searchable rule database ## Quick Start Create a `.cursorrules` file in your project root defining the tech stack and coding conventions. ## What are Cursor Rules? Cursor Rules is Cursor IDE's project configuration file that tells the AI how to generate code for your project. Defines tech stack, coding conventions, and best practices. **In one sentence**: Cursor IDE project-level AI configuration — define tech stack and coding conventions to reduce AI hallucinations and improve code consistency. Community offers many templates. **For**: Developers and teams using Cursor IDE. ## Rule Types ### 1. Tech Stack Rules Specify language, framework, and version preferences. ### 2. Architecture Rules Define layered architecture and dependency directions. ### 3. Testing Rules Test framework, naming, and coverage requirements. ## FAQ **Q: Does Claude Code have a similar feature?** A: Claude Code uses `CLAUDE.md` — same concept. **Q: How long should the rules be?** A: 200-500 lines works best. ## Source & Thanks > [PatrickJS/awesome-cursorrules](https://github.com/PatrickJS/awesome-cursorrules) — 16k+ stars --- Source: https://tokrepo.com/en/workflows/cursor-rules-generator-ai-coding-config-builder-3b69856d Author: Skill Factory