Skip to content
AI Agent & Markdown Files

Generate Cursor Rules for Your Stack

For when Cursor keeps ignoring your rules, or you copied a long .cursorrules from somewhere and it doesn't fit your repo. Give it your stack, commands, folders and the mistakes Cursor keeps making. It writes a few small .cursor/rules/*.mdc files with the right frontmatter for each rule type, keeps shared facts in AGENTS.md instead, and tells you how to check every rule actually loads.

Illustration for the AI prompt: Generate Cursor Rules for Your Stack
Chat promptAI Agent & Markdown FilesClaudeChatGPTGemini
The Prompt
You are a senior engineer who writes Cursor project rules. I want a set of Cursor rules for my stack that Cursor actually applies. My current setup has the usual problems: a long legacy .cursorrules file or rules copied from a public collection that don't match my repo, rules Cursor seems to ignore most of the time, and confusion about which rule type to use. I know the Cursor docs now call the rule types Always Apply, Apply Intelligently, Apply to Specific Files and Apply Manually, while older posts call them Always, Agent Requested, Auto Attached and Manual, and that the frontmatter (description, globs, alwaysApply) decides which type a rule becomes. I want a small set of focused .mdc files where every rule type is chosen on purpose, plus a clear split between what belongs in Cursor rules and what belongs in AGENTS.md.

HARD RULES:
1. RIGHT PLACE, RIGHT EXTENSION. Every rule is its own file in .cursor/rules/ with the .mdc extension; a plain .md file in that folder is not loaded as a rule. Treat a root .cursorrules file as legacy: move its useful lines into .mdc files and tell me to retire it instead of keeping two sources.
2. ONE RULE TYPE PER FILE, SET ON PURPOSE. Use exactly one of these frontmatter patterns:
   - Always Apply (old label: Always): alwaysApply: true, no globs. Only for the few rules that apply to nearly every request.
   - Apply to Specific Files (old label: Auto Attached): globs set, alwaysApply: false.
   - Apply Intelligently (old label: Agent Requested): description set, no globs, alwaysApply: false.
   - Apply Manually (old label: Manual): no description, no globs, alwaysApply: false; I call it with @ and the rule name.
   Never put globs and a description in the same rule.
3. GLOBS AS ONE COMMA-SEPARATED STRING, for example globs: src/**/*.ts, src/**/*.tsx. Not a YAML list and not a bracketed array, because that is a common reason a scoped rule silently never attaches.
4. DESCRIPTIONS ARE WRITTEN FOR THE AGENT, NOT FOR ME. Start every Apply Intelligently description with "USE WHEN" and name the concrete task (for example "USE WHEN writing or changing Playwright tests"), never a topic label like "testing rules".
5. FEW, SMALL, SPECIFIC. Prefer 3 to 8 focused rules over one giant file, because every extra rule is one more thing the agent can miss. Keep each file far below the 500 lines the Cursor docs recommend; aim for under 50. Every line is a direct instruction with a concrete command, path or name. Cut "write clean code", "you are an expert in...", "follow best practices" and anything a linter or formatter already enforces.
6. NEVER INVENT. Use only the stack, versions, commands, paths and conventions I give you. If something is missing or unclear, write [CONFIRM: ...] instead of filling the gap with the popular default for my framework.
7. SHARED FACTS GO IN AGENTS.MD. Build and test commands and conventions every agent should know belong in AGENTS.md, which Cursor also reads. Keep .cursor/rules for Cursor-only behaviour: rules scoped to folders or file types, task-triggered rules and manual templates. Never repeat AGENTS.md content inside an .mdc file.
8. POINTERS, NOT COPIES. Reference files (for example "follow the pattern in src/api/users.ts") instead of pasting their contents into the rule.
9. RULES ARE REQUESTS. Cursor can still skip a rule, so any rule that must never be broken also gets a suggested linter, hook or CI check.

BEFORE WRITING, ask me these in one short batch and STOP:
1. What the project is in one sentence, plus the stack, versions and package manager.
2. The exact commands for install, dev, build, test (full suite and a single test), lint or format, and typecheck. Pasting package.json scripts or a Makefile is fine.
3. The folder layout, and which folders or file types need their own conventions (for example components, API routes, migrations, tests).
4. The mistakes Cursor keeps making in this repo, in my own words, and which of my current rules it seems to ignore.
5. My existing .cursorrules, .cursor/rules/*.mdc files and AGENTS.md, if any (I will paste them).
6. The rules that must never be broken, and the linters, formatters, hooks or CI already in place.
7. Whether the team also uses other agents (Claude Code, Codex, Copilot) that need the same shared rules.

Then reply using exactly these sections:
RULE MAP: a table with columns File | Rule type (new label / old label) | Trigger (globs, USE WHEN description, alwaysApply or @mention).
RULE FILES: each .mdc file as its path on one line, followed by its complete contents (frontmatter included) in its own markdown code block.
AGENTS.MD ADDITIONS: the shared lines that belong in AGENTS.md instead of a Cursor rule, or "none".
MIGRATION: what to do with .cursorrules and each existing rule file (merge, keep or delete), one line each.
VERIFY IT LOADS: short steps to confirm each rule works: check its type in Cursor Settings > Rules, open a file matching each glob and ask the agent which rules it has in context, and what to check in the frontmatter if an Always Apply rule shows up as agent-requested instead.
MOVE TO CHECKS: each never-break rule paired with the kind of linter, hook or CI check that would enforce it, as a suggestion for me to verify, not a finished script.
CUT AND WHY: everything from my input you left out, one line each, with the reason (vague, linter's job, discoverable from code, belongs in AGENTS.md, duplicate).
CONFIRM: every [CONFIRM] placeholder still in the files.

Plain text outside the code blocks, no intro, no pep talk.

Here are my details:
Project and stack: [FILL IN]
Commands: [PASTE SCRIPTS OR LIST]
Folders and file types with their own conventions: [FILL IN]
Mistakes Cursor keeps making: [FILL IN]
Existing .cursorrules, .mdc files or AGENTS.md: [PASTE OR "none"]
Never-break rules and existing checks: [FILL IN]
Other agents the team uses: [FILL IN OR "Cursor only"]

Start with the questions.
Open directly inChatGPTClaudeGemini

How to use this chat prompt

Paste it directly into a new chat, replace anything in [BRACKETS] with your context, and send. Re-use it whenever the task comes up, or save it as a text-expander snippet.

Example output

Next.js App Router repo with pnpm, Prisma and Playwright. Cursor keeps running npm and ignores a 300-line .cursorrules. All seven questions answered.

Plain ChatGPT answer

Create a .cursorrules file in your project root with your guidelines:

- You are an expert in Next.js, TypeScript and Tailwind. Write clean, maintainable code.

- Always write tests and follow best practices.

With this prompt

RULE MAP:

| File | Rule type (new / old) | Trigger |

| api-routes.mdc | Apply to Specific Files / Auto Attached | globs: app/api/**/*.ts |

| e2e-tests.mdc | Apply Intelligently / Agent Requested | USE WHEN writing Playwright tests |

AGENTS.MD ADDITIONS: `pnpm install`, `pnpm test:e2e`; use pnpm, never npm.

MIGRATION: 6 useful lines from .cursorrules moved into the two files above; retire it.

VERIFY IT LOADS: open app/api/users/route.ts and confirm api-routes.mdc is in context.

FAQ

Frequently asked questions

What are Cursor rules and where do they go?

Cursor rules are instructions the Cursor agent reads alongside your code. Project rules live in a .cursor/rules folder in your repo, one rule per file, and each file needs the .mdc extension: Markdown with a short frontmatter block (description, globs, alwaysApply) that controls when the rule is used. You can also set personal User Rules in Cursor's settings, and Cursor reads AGENTS.md as well.

.cursorrules vs .cursor/rules: which should I use?

Use .cursor/rules/*.mdc. Cursor's docs describe the single root .cursorrules file as legacy, with Project Rules as the replacement, and reports differ on how reliably the old file is still picked up, especially in Agent mode. If you have one, paste it into the prompt: it moves the useful lines into scoped .mdc files and tells you to retire the old file so you aren't maintaining two sources.

Why is Cursor ignoring my rules?

The common causes are fixable: a rule saved as .md instead of .mdc, globs written as a YAML list instead of one comma-separated string, a description that names a topic instead of the task it applies to, or simply too many rules competing for attention. Open Cursor Settings > Rules and check each rule shows the type you expect. Even a well-formed rule is a request, not a guarantee, so the prompt pairs any never-break rule with a linter, hook or CI check.

What's the difference between Always Apply, Apply Intelligently, Apply to Specific Files and Apply Manually?

They are the four rule types, and older guides call them Always, Agent Requested, Auto Attached and Manual. Always Apply (alwaysApply: true) is included in every request. Apply to Specific Files uses globs and attaches when matching files are in context. Apply Intelligently uses only a description, and the agent decides when to pull it in. Apply Manually has neither, and only loads when you @mention it. Mixing globs and a description in one rule is a frequent source of confusion, so the prompt sets exactly one pattern per file.

Should I use Cursor rules or AGENTS.md?

Usually both, with a clear split. Shared facts every agent needs, like build and test commands and repo-wide conventions, go in AGENTS.md, which Cursor reads too. Cursor rules are for what only Cursor can do: rules scoped to certain folders or file types, and rules the agent pulls in for specific tasks. If your team also uses Claude Code or Codex, write the shared file first with the AGENTS.md generator, then use this prompt for the Cursor-only rules.

Keep going

What's next