<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ahmed Mustafa</title>
    <description>The latest articles on DEV Community by Ahmed Mustafa (@ahmednimeri).</description>
    <link>https://dev.to/ahmednimeri</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3951067%2F7e9b33cd-f167-42df-b0a2-31eed5258a9f.png</url>
      <title>DEV Community: Ahmed Mustafa</title>
      <link>https://dev.to/ahmednimeri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ahmednimeri"/>
    <language>en</language>
    <item>
      <title>What's actually in a good .cursorrules file? I built 10 of them — here's what I learned</title>
      <dc:creator>Ahmed Mustafa</dc:creator>
      <pubDate>Mon, 25 May 2026 16:45:35 +0000</pubDate>
      <link>https://dev.to/ahmednimeri/whats-actually-in-a-good-cursorrules-file-i-built-10-of-them-heres-what-i-learned-1a46</link>
      <guid>https://dev.to/ahmednimeri/whats-actually-in-a-good-cursorrules-file-i-built-10-of-them-heres-what-i-learned-1a46</guid>
      <description>&lt;p&gt;description: Most .cursorrules files are either too vague to help or too rigid to be useful. Here's what I found actually works after building rules for 10 different stacks.&lt;br&gt;
tags: cursor,ai,webdev,productivity&lt;/p&gt;



&lt;p&gt;I've spent a lot of time reading other people's &lt;code&gt;.cursorrules&lt;/code&gt; files. Some are fantastic. Most are not.&lt;/p&gt;

&lt;p&gt;Not because the authors didn't try — but because there's a gap between what &lt;em&gt;feels&lt;/em&gt; like a good instruction and what actually changes how Cursor behaves. After building 10 rules files from scratch for different stacks, I want to share what I learned.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is a .cursorrules file, and why does it matter?
&lt;/h2&gt;

&lt;p&gt;If you haven't used one yet: a &lt;code&gt;.cursorrules&lt;/code&gt; file sits in your project root and gives Cursor a set of persistent instructions. Every time the AI generates code, it uses these rules as context.&lt;/p&gt;

&lt;p&gt;Think of it as a briefing document. Instead of re-explaining your preferences on every prompt — "use TypeScript strict mode," "don't use default exports," "we use Tailwind, not plain CSS" — you write them once and they apply automatically.&lt;/p&gt;

&lt;p&gt;Done well, it means Cursor generates code that fits your project from the first suggestion. Done poorly, it either does nothing or actively gets in the way.&lt;/p&gt;
&lt;h2&gt;
  
  
  What bad rules look like
&lt;/h2&gt;

&lt;p&gt;Here's a real example of the kind of rule that shows up a lot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Always write clean, readable, maintainable code.
Follow best practices.
Use meaningful variable names.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is useless. Not wrong — just useless. "Write clean code" is not an instruction. Cursor already tries to write clean code. You haven't told it anything it didn't already know.&lt;/p&gt;

&lt;p&gt;A slightly better but still weak version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Use TypeScript.
Add comments to complex functions.
Prefer async/await over callbacks.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are real preferences, but they're still too generic. Every modern TypeScript project uses async/await. Saying it here adds no signal.&lt;/p&gt;

&lt;p&gt;The problem with both examples is that they're &lt;em&gt;stack-agnostic&lt;/em&gt;. They would apply equally to any project, so they don't actually help Cursor understand &lt;em&gt;your&lt;/em&gt; project.&lt;/p&gt;

&lt;h2&gt;
  
  
  What good rules look like
&lt;/h2&gt;

&lt;p&gt;Good rules are &lt;strong&gt;specific to the stack and specific to the project's conventions&lt;/strong&gt;. Here's a before/after for a Next.js project:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weak:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Use Next.js best practices.
Structure components properly.
Handle errors appropriately.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Strong:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This project uses Next.js 14 with the App Router. All components in /app are Server Components by default.
Only add 'use client' when the component requires interactivity (event handlers, useState, useEffect).
Do not use getServerSideProps or getStaticProps — those are Pages Router patterns.
Data fetching happens in Server Components using async/await directly. Never fetch in useEffect for initial data loads.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the difference. The second version tells Cursor something it wouldn't otherwise know: that this is App Router, not Pages Router, and what the rules of that environment are. It also explicitly flags a common mistake — the Pages Router data-fetching patterns — because that's exactly the kind of thing AI models get wrong with App Router projects.&lt;/p&gt;

&lt;p&gt;Here's another example, this time for FastAPI:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weak:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Follow FastAPI conventions.
Use Pydantic for validation.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Strong:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This project uses FastAPI with Pydantic v2. Use model_validator and field_validator (not @validator, which is Pydantic v1).
Response models use model_config = ConfigDict(from_attributes=True), not class Config.
All database access goes through SQLAlchemy async sessions. Never use synchronous session patterns.
Route functions should be async. Dependencies go in Depends(), not imported directly into route functions.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The weak version would have Cursor defaulting to Pydantic v1 syntax half the time — because that's what's most common in its training data. The strong version explicitly says "Pydantic v2" and names the specific patterns that differ, so Cursor uses the right ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three things that make rules effective
&lt;/h2&gt;

&lt;p&gt;After writing rules for 10 stacks, I found a few patterns that consistently made a difference:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Name the version, not just the tool&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"Use React" is fine. "Use React 18 with concurrent features where appropriate" is better. Version specificity matters because AI models have seen a lot of different version patterns and will default to the most common one, which may not be current.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Explain what to avoid, not just what to do&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's often more useful to say "do not use X" than "use Y." When Cursor knows what the wrong path looks like, it avoids generating the plausible-but-wrong code that you'd otherwise have to catch and fix. For Go projects, for example, specifying "do not use global variables for state; use dependency injection" catches a common pattern that works at small scale but creates problems in production.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Describe your project structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your project has non-obvious structure — a monorepo, a specific folder layout, a separation between domain and infrastructure layers — put it in the rules. Cursor uses the file tree as context, but a brief description of &lt;em&gt;what lives where and why&lt;/em&gt; helps it make better decisions about where to put new code.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to avoid in rules files
&lt;/h2&gt;

&lt;p&gt;Keep them focused. A &lt;code&gt;.cursorrules&lt;/code&gt; file that's 500 lines long is a problem — it dilutes the important instructions with noise. If everything is emphasized, nothing is.&lt;/p&gt;

&lt;p&gt;Avoid instructions that are just philosophy: "Think carefully before writing code." "Consider edge cases." These do not change behavior.&lt;/p&gt;

&lt;p&gt;And avoid contradictions. If you say "always add JSDoc comments" and also "keep code concise," you'll get inconsistent results because those goals conflict.&lt;/p&gt;

&lt;h2&gt;
  
  
  The payoff
&lt;/h2&gt;

&lt;p&gt;When your rules file is doing its job, you stop noticing it — in a good way. Cursor just generates code that fits. You're not correcting the same mistakes repeatedly. You're not re-explaining your conventions every session. The suggestions match what you'd actually write.&lt;/p&gt;

&lt;p&gt;That compounding effect is real. Over a day of coding it's maybe a few frustrations avoided and a few minutes saved. Over a month it's meaningful.&lt;/p&gt;




&lt;p&gt;After going through this process for 10 different stacks — Next.js, React, FastAPI, Django, Node.js, Go, Vue 3, Svelte, React Native, and Full-Stack SaaS — I packaged the resulting rules files into a single pack if you want a starting point rather than building from scratch. Each file reflects the stack-specific conventions and gotchas I've described here, not just generic advice.&lt;/p&gt;

&lt;p&gt;You can find the pack here: &lt;a href="https://nas.com/stackdrop/digital-files/cursor-rules-pack-10-expert-cursorrules-files-for-" rel="noopener noreferrer"&gt;Stackdrop Cursor Rules Pack&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;What rules have you found actually make a difference in your &lt;code&gt;.cursorrules&lt;/code&gt; files? Curious what others have figured out — especially for stacks I haven't covered. Drop your best rules in the comments.&lt;/p&gt;

</description>
      <category>cursor</category>
      <category>ai</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
