Urgent.News

What's breaking now, across thousands of outlets.

Tech

How to write Cursor rules that the agent actually follows (with .mdc examples)

If you use Cursor every day, you've typed this more than once: "No, we use the App Router." "Don't use any ." "Put the test next to the file." "Validate with zod." The agent isn't bad. It just doesn't know your project. Project rules are how you tell it once instead of every prompt. Here's the structure I've settled on after a lot of trial and error. How Cursor rules work (current format) Rules…

Writing Cursor rules that the agent actually follows can be a challenge. The agent doesn't know your project unless you explicitly tell it. That's why project rules are essential - they tell the agent once instead of every time you make a prompt.

Rules live in .cursor/rules/ as .mdc files, which are markdown files with a small frontmatter block. The three fields that decide when a rule is loaded are setup, use for, and alwaysApply. Setup determines when it loads, Use for specifies when to use it, and alwaysApply is false by default.

There are three types of rules: always-on rules, framework-specific rules, and niche topic rules. Always-on rules stay short, under 40 lines each, and everything framework-specific is scoped to globs so it doesn't consume context when editing SQL migrations.

The recommended structure is 00-project-core.mdc, 01-workflow.mdc, 02-security.mdc, 05-code-style.mdc, and 10-nextjs.mdc. Each rule has a description and specific details about how to implement it.

For example, 00-project-core.mdc contains the project context and definition of done, while 10-nextjs.mdc specifies nextjs app router conventions.

Security rules are specified in 02-security.mdc for server code, and code style rules are in 05-code-style.mdc. Keep rules concrete and specific, and avoid vague rules like "write clean code". Skills are step-by-step procedures for tasks like reviewing diffs or writing tests, and should be kept separate from rules.

Lastly, the author recommends using VibeRules, which generates a ready .cursor/ folder with rules, skills, and prompt library based on your project stack, testing, styling, and team size.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

osFoundry Operator에게 앱 조작을 맡겨 봤더니, 모든 동작이 로그에 남아 있었다

"지금 과금되고 있는 GPU 엔드포인트가 뭐지?"라는 질문 자체는 간단합니다. 그런데 답하려면 화면 세 개쯤을 돌아다니며 숫자를 읽고, 다시 채팅으로 돌아와 옮겨 적어야 합니다. AI 에이전트에게 맡기고 싶지만, 그러면 "실제로 뭘 클릭했는데?"가 신경 쓰입니다. osFoundry의 Operator는 바로 이 질문을 전제로 만들어졌습니다.

More from Monday 9 November →