Automate Cursor Rules Generation for Your Projects

If you're using Cursor, then you already know about Cursor rules. But if you're still creating them one by one for every framework or dependency, you're doing it wrong. There's a tool that generates them instantly just by pasting your requirements.txt or other dependency files. No more manual setup, no more wasted time. Let me show you how it works.

A Quick Background on Cursor Rules

Before we start, let me just give you a bit of background on what these rules actually are. Previously, we had "cursor rules," which were a way to control your agent in Cursor by giving it specific instructions on how to act. However, Cursor has now deprecated that and introduced "rules files," which are basically separate for each framework or language. If you go into your settings, you'll find a menu where you can add them.

Generating Rules with Cursor Directory

Now, let's get into the main topic of this article. This is Cursor Directory, a tool I've covered in a bunch of articles on this publication, so you might have seen it before. It offers Cursor rules files for different languages like Tailwind and Python, and they've recently added some exciting new features, one of them being mCPs. But what I'm really excited about is the "Generate Cursor Project Rules" feature.

What this feature does is let you generate your Cursor project Rules by simply dropping in your package.json or requirements.txt file. Pretty straightforward, right? And as you can see, it's powered by Groq.

Let's not waste any time and jump straight into the demo.

How to Generate Rules

All right, I've got Cursor open with a small project I'm working on. Right now, I only have the Cursor rules file for Python; adding more would help me further develop the project. If we open the package.json, you'll see the dependencies listed right here:

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "react": "^18",
    "react-dom": "^18",
    "next": "14.2.4",
    "typescript": "^5",
    "tailwindcss": "^3.4.1"
  }
}

I'm going to upload this file, and for the back end, I'll include the requirements.txt as well. The tool will analyze both files and generate a Cursor rules file based on the dependencies.

We're back in the tool. Just a quick reminder: you can only upload your package.json or requirements.txt file. For example, if I try to paste a package-lock.json file here, it won't work. So, make sure you're using the package.json file.

Let me just drag and drop it in. Now, looking at the dependencies in the package.json file, it's generating custom rules for each one. As you can see, it's done. For example, there are rules for Next.js, React, TypeScript, Tailwind CSS, and a few others as well.

Here is an example of the generated output:

// For nextjs
{
    "name": "nextjs",
    "description": "Best practices for Next.js development.",
    "globs": ["**/*.{js,jsx,ts,tsx}", "**/next.config.js"],
    "rules": "Follow Next.js conventions for file-based routing, data fetching (getServerSideProps, getStaticProps), and API routes. Use the `next/image` component for optimized images."
}

// For react
{
    "name": "react",
    "description": "Best practices for React development.",
    "globs": ["**/*.{js,jsx,ts,tsx}"],
    "rules": "Use functional components and hooks. Follow the rules of hooks. Use state and props effectively. Write modular and reusable components."
}

What it's given us is the name, description, and the globs. If you're not sure how to use them or where to paste them, let me show you. First, just copy the generated content and then paste it into a .txt file in your project directory.

All right, I've dropped it into my rules.txt file here in Cursor. You can see it right there. Now, let me show you how to actually use these rules.

Applying the Rules in Cursor

  1. Go to General Settings under Cursor Settings.
  2. The first thing you'll notice are the Rules for AI; these are the global rules.
  3. Scroll down to the Project Rules section. You can see I've already added the Python project rules.
  4. To add the rest, just copy the name from the generated file (e.g., "nextjs") and paste it into the field. You don't need to add .mdc, as that's just the file type.
  5. Once you hit Enter, the full rules file will open up.
  6. From there, just copy the description and the globs from your generated file and paste them in.
  7. After you've pasted them, go ahead and copy the rules as well and drop them into the designated area.

These rules are optimized based on your other dependencies, so they work really well together.

Now, let me close this and open up the sidebar, and there you go, the Next.js best practices have been added to the .cursor-rules folder.

Backend Rules with requirements.txt

If you're wondering, you can do the same thing with the requirements.txt file. Heading into the back end, I'm just going to drop it in here.

fastapi==0.111.0
uvicorn==0.29.0
sqlalchemy==2.0.30

As you can see, it started generating the rules for the back end too. It's done generating, and you can see it's listed the best practices for FastAPI and also for SQLAlchemy. Basically, all the main tools I've used in the app, it created rules for all of them. You can paste them into Cursor the same way I showed you earlier.

Exploring More Features

Besides generating these specific Cursor rules, you can also explore them on your own. There's a huge library of different frameworks and languages right here, all contributed by various people. Definitely take a look; some of them might be super helpful for your particular use case.

They've also put together a curated library of mCP servers. If you're not sure what those are, check out our article on the topic. It covers what they are, how to integrate them into Cursor, and how to use them. It's a really cool integration that's definitely worth exploring. They've got this curated list of integrations, and if you open one up—let's check out the Obsidian Markdown notes as an example—you'll find a basic overview of how to use it in Cursor. Scroll down, and you'll see detailed installation instructions that link directly to the GitHub repo. Most of the time, you'll find the setup steps right there in the repo.

And that's it. With the "Generate Cursor Project Rules" feature, setting up your project just got way easier. No more manual work—just quick, optimized rules ready to go.