How to make Cursor follow your code style Cursor users can enforce code style by creating a `.cursorrules` file in the project root with explicit 'Do' and 'Don't' lists, concrete syntax examples, and a 'Style Reference' section, as vague adjectives like 'clean' are ineffective. The article advises using negative constraints, 'Always/Never' statements, few-shot examples, and file-path triggers to prevent the AI from ignoring rules, and suggests re-centering the AI by citing the specific broken rule when it forgets. How to make Cursor follow your code style To force Cursor /en/tags/cursor/ to follow your specific code style, create a .cursorrules file in your project root containing explicit "Do" and "Don't" lists, concrete syntax examples, and a designated "Style Reference" section. The AI ignores vague adjectives like "clean" or "modern" and instead responds to hard constraints like "Use named exports instead of default exports" or "No semicolons." Where do I actually put the rules? Put them in a .cursorrules file at the root of your repository. While Cursor has global settings, project-specific files are better because your React frontend needs different rules than your Go backend. If you use a global rule for everything, the AI starts hallucinating TypeScript types inside your Python scripts. I've found that keeping rules local to the repo prevents the AI from getting confused when switching between different languages in a monorepo. How should I phrase the rules so they actually work? Use negative constraints and "Always/Never" statements. Vague prompts like "Write professional code" are useless. The AI's definition of "professional" changes based on the model version Claude /en/tags/claude/ 3.5 Sonnet vs GPT-4o . You need to be pedantic. Instead of "Use a consistent naming convention," write: - Always use camelCase for variables. - Never use underscores in function names. - Always prefix boolean variables with is , has , or should . I spent three hours fighting with Cursor's tendency to use any in TypeScript until I added a hard rule: "Strictly forbid the use of any . If a type is unknown, use unknown and narrow it with a type guard." After that, the errors dropped immediately. Can I give the AI a visual example of my style? Yes, by using "Few-Shot" examples directly in the rules file. LLMs are pattern matchers. A list of rules is good, but a code block is better. In your .cursorrules , create a section called CODE STYLE REFERENCE and paste a 10-line snippet of your "perfect" code. Example format: js STYLE REFERENCE: // Good: const getUser = async id: string : Promise