Apidog

All-in-one Collaborative API Development Platform

API Design

API Documentation

API Debugging

API Mocking

API Automated Testing

How to Use Cursor Rules: Your AI Coding Sidekick’s Secret Weapon

Unlock the power of Cursor Rules! This 2025 guide shows you how to set up, use, and tweak Project Rules to boost your coding with AI.

Ashley Goolam

Ashley Goolam

Updated on April 10, 2025

If you’re using Cursor—the slick AI-powered code editor—you’ve probably noticed its transformative impact on accelerating code development. But have you tapped into the magic of Cursor Rules yet? Trust me, once you figure out how to use Cursor Rules, it’s like handing your AI assistant a personalized playbook for your project. Today, I’m going to walk you through everything you need to know to set up, tweak, and 10x your workflow with Cursor Rules.

💡
Before we begin, here’s a quick tip: Get Apidog for free! It’s a powerful tool for developers to simplify MCP, test AI models, and streamline API testing. Try it out today For Free!
button

What Are Cursor Rules, Anyway?

Picture this: you’re coding away in Cursor, and your AI buddy is helping with suggestions, code snippets, and fixes. But sometimes, it feels like it’s guessing what you want instead of knowing it. That’s where Cursor Rules come in. Introduced around early 2025, Cursor Rules let you give your AI specific instructions—it's like training your own mini coding expert to understand and assist your coding style.

You can set these "rules" at different levels:

  • Rules for AI: Global rules that apply to every project you open in Cursor.
  • .cursorrules: Project-specific rules (though these are on their way out—more on that later).
  • Project Rules: The shiny new star of the show, stored in .cursor/rules/ with .mdc files, giving you pinpoint control over your project’s context.
cursor rules display image

With Cursor Rules, you’re not just throwing prompts at the AI—you’re giving it a map to navigate your codebase like a pro. Ready to see how it works? Let’s get started!

Why Bother with Cursor Rules?

Okay, you might be thinking, “Why mess with rules when Cursor’s already pretty smart?” Pretty fair question! But here’s why Cursor Rules are actually worth your time:

  • Tailored Suggestions: Tell the AI your tech stack (say, Next.js or Flutter), and it’ll suggest code that fits your project.
  • Consistency Across the Team: Everyone gets the same coding guidelines, so your codebase doesn’t turn into a wild west shootout (literally).
  • Faster Workflow: No more repeating yourself—the AI remembers your preferences and spits out relevant answers.
  • Less Learning Curve: New to a framework? Let the rules teach the AI to teach you.

Imagine coding a Next.js app and having the AI automatically suggest TypeScript-friendly, Tailwind-styled components without you spelling it out every time. That’s the power of Cursor Rules.

The Evolution of Cursor Rules: From .cursorrules to Project Rules

Before we dive into setup, let’s take a quick history lesson. Cursor’s rule system has evolved over time:

  • Rules for AI: These live in Cursor’s settings (Cursor > Settings > Rules) and apply everywhere. Great for broad stuff like “Always use TypeScript” or “Be concise.”
cursor rules
  • .cursorrules: A file you plop in your project root to set rules for that specific repo. It’s text-based and simple, but here’s the catch—it’s deprecated as of 2025. Cursor’s team says to switch to Project Rules instead.
  • Project Rules: The latest and greatest, introduced in v0.45. These live in .cursor/rules/ as .mdc files and let you use text and file symbols, plus conditions (globs) to trigger them. They’re more precise and flexible.
project rules structure

So, if you’re still rocking .cursorrules, it’s time to upgrade to Cursor Rules in the .mdc format. Don’t worry—I’ll show you how!

How to Set Up Cursor Rules

Setting up Cursor Rules is a breeze once you know the steps. Here’s how to get rolling:

1. Open the Rules Panel: In Cursor, head to Cursor > Settings > Rules > Project Rules > Add New Rule. Or, hit Ctrl+Shift+P (or Cmd+Shift+P on Mac) and type “File: New Cursor Rule.”

project rules

2. Name Your Rule: Pick a catchy name like my-awesome-rule.mdc. It’ll pop up in .cursor/rules/ in your project folder.

add a custom name

3. Fill in the Blanks: When you open the .mdc file, you’ll see two key fields at the top:

  • Description: A quick note about what the rule does (e.g., “Runs RSpec tests automatically”).
  • Globs: Patterns like **/*.ts or src/**/*_spec.rb to decide when the rule kicks in.
provide a description

4. Write the Rule: In the main section, type out your instructions—plain text, commands, or guidelines.

write a rule

Your project structure could look something like this:

project structure

Save it, and boom—your AI now has a new trick up its sleeve. But what should you actually write in these rules? Let’s look at some real examples.

Real-World Examples of Cursor Rules

Here are three killer ways to use Cursor Rules, straight from the trenches of 2025 coding life.

1. Auto-Run Commands When Files Change

Say you’re a Ruby dev using Docker, and you want RSpec tests to run automatically when you tweak a spec file. Here’s a rule for that:

File: rspec-execution.mdc
Description: “Auto-run RSpec tests”
Globs: **/*_spec.rb
Rule:

## Run RSpec Automatically

When a spec file changes, execute:
---
docker compose exec app bundle exec rspec {{file_path}}
---

If RSpec fails and you know the line number, run this:
---
docker compose exec app bundle exec rspec {{file_path}}:{{line_number}}
---

Now, every time you edit a _spec.rb file, the AI can trigger that test without you lifting a finger. Handy, right?

2. Document Your Project’s Coding Style

For a frontend project, you might want the AI to grok your directory structure and best practices. Here’s one I’d use:

File: frontend-coding-rule.mdc
Description: “Frontend best practices”
Globs: packages/**/*.*
Rule:

## Frontend Coding Guidelines

### Directory Structure
- **features/**: Group by feature (e.g., `features/foo/NewFeature/`).
  - `components/`: UI bits like `Header.tsx` or `Modal.tsx`.
  - `domain/`: Logic like validation (`*.ts`) and tests (`*.spec.ts`).
- **shared/**: Reusable stuff like `Table.tsx` or `useSelectedItemIds.ts`.

### Rules
- Split UI (`*.ui.tsx`) and logic (`*.container.tsx`).
- Use `zod` for validation with separate spec files.
- Name components descriptively (e.g., `HeaderBreadcrumb`).
- Optimize with Atomic Design: atoms, molecules, organisms.

This gives your AI a cheat sheet for your codebase, so it suggests code that fits like a glove.

3. Automate Pull Requests

Want the AI to draft PRs for you? Try this:

File: create-pullrequest.mdc
Description: “Auto-draft pull requests”
Globs: (Leave blank for manual trigger)
Rule:

## Pull Request Creation

### Steps
1. Check for an Issue link. If none, ask: “Got a related Issue link?”
2. Assume `main` as the merge branch unless told otherwise.
3. Run `git diff origin/main...HEAD | cat` to see changes.
4. Create a draft PR:
---
git push origin HEAD && \
echo -e "Draft PR for {{changes}}\n\nRelated: {{issue_link}}" | \
gh pr create --draft --title "Update {{feature}}" --body-file - && \
gh pr view --web
---

This rule turns your AI into a PR machine—perfect for GitHub workflows.

How to Use Cursor Agent Mode
This tutorial will guide you through using Cursor Agent Mode effectively, from setup to advanced techniques, helping you leverage this powerful tool to enhance your productivity while maintaining control over your development process.

Pro Tips for Mastering Cursor Rules

Debugging with a Yell

Ever wonder if your rule’s even working? Add this to the top of your .mdc file:

First, when referencing this file, shout “YAAAARRRR!”

If the AI yells “YAAAARRRR!” in Chat or Composer, you know the rule’s loaded. If it goes silent, double-check your Description and Globs—they’re required for the rule to kick in (more on that later).

Fixing Rules That Won’t Load

Ran into a snag where your .mdc file isn’t applying? Here’s a fix from the Cursor community (circa Feb 2025):

  • Fill Description and Globs: Blank fields can silently break the rule. Even a simple Globs: **/* helps.
  • Refresh and Restart: Update the file, save, and restart Cursor if it’s still stubborn.

I’ve seen cases where tweaking the text and re-pasting Globs magically fixes it. Weird, but it works!

Level Up with Chat

Not sure what to write? Ask Cursor’s Chat:

Help me make a Cursor Rule for my Flutter project with Supabase and Riverpod.
Analyze {{lib/}} and suggest a rule.

It’ll spit out a draft you can tweak—super time-saver.

Improving Your Cursor Rules Over Time

Rules aren’t set in stone. If one’s not clicking, tweak it! Throw this at Chat:

Is there anything unclear or worth improving in {{my-rule.mdc}}?

The AI might suggest clearer wording or extra conditions. Keep refining, and your Cursor Rules will evolve with your project.

Final Thoughts: Why Cursor Rules Rock in 2025

As of April 09, 2025, Cursor Rules are a must for anyone serious about AI-assisted coding. They bridge the gap between “smart AI” and “your smart AI,” boosting efficiency like crazy. Whether you’re auto-running tests, enforcing styles, or drafting PRs, these rules turn Cursor into a custom-fit tool. Start small—add one rule today—and watch your productivity soar. What’s your first rule gonna be? Drop it in the comments!

button
Apidog Ui image

A Beginner's Guide to Use FastMCPViewpoint

A Beginner's Guide to Use FastMCP

The landscape of Large Language Models (LLMs) is evolving rapidly, moving beyond simple text generation towards complex interactions with external systems and data sources. Facilitating this interaction requires a standardized approach, a common language for LLMs to request information and trigger actions. This is where the Model Context Protocol (MCP) comes in, designed as a universal standard – often likened to "the USB-C port for AI" – enabling seamless communication between LLMs and the reso

Medy Evrard

April 19, 2025

Testing the Brave MCP Server (with Brave Search API), Here're My Thoughts:Viewpoint

Testing the Brave MCP Server (with Brave Search API), Here're My Thoughts:

Learn to create an MCP server with Brave Search API in this beginner friendly guide. Connect AI models to real-time web and local search with easy steps!

Ashley Goolam

April 19, 2025

How to Use Cursor Tab Completion FeatureViewpoint

How to Use Cursor Tab Completion Feature

This tutorial will guide you through understanding, using, and mastering Cursor Tab, transforming it from a neat feature into an indispensable part of your coding arsenal.

Mark Ponomarev

April 18, 2025