← Back to Payloads
Tutorial2026-06-15

Cursor Rules: The 10-Line File That Stops Your AI From Going Off the Rails

You are letting your editor AI invent your team's coding standards from scratch, every session, on every file. A 10-line `.cursor/rules/*.mdc` file fixes 90% of the bad suggestions. Most teams never write one. Here is the version that works, with the three gotchas that are not in the docs.
Quick Access
Install command
$ mrt install tutorial
Browse related skills
Cursor Rules: The 10-Line File That Stops Your AI From Going Off the Rails

Cursor Rules: The 10-Line File That Stops Your AI From Going Off the Rails

Hey guys, Mr. Technology here.

The single biggest problem with Cursor, Copilot, Claude Code, and every other editor AI is not the model. It is that you are letting the model invent your team's coding standards from scratch, every session, on every file, with no memory of what you decided last month. The fix is a 10-line rules file. Almost nobody writes one. The teams that do ship three times faster and pay a quarter of the "wait, why is this any?" pull-request tax.

The Setup

Cursor reads .cursor/rules/*.mdc (a legacy single-file .cursorrules still works). The format is short YAML frontmatter plus markdown. The model sees the rules on every interaction. It is the cheapest, highest-leverage file in your repo, and you have been leaving it empty.

The 10 Lines

```yaml


description: Project-wide coding rules globs: ["**/*.ts", "**/*.tsx"] alwaysApply: true


Project Rules

  • TypeScript strict mode. No any outside generated code.
  • Tests live next to the file as *.test.ts. No __tests__/ dirs.
  • Imports: relative for siblings, @/ alias for cross-folder.
  • Errors: return Result<T, E> types in lib/. No thrown exceptions.
  • Run pnpm test and pnpm typecheck before claiming a task is done.
  • Do not add new dependencies without asking. Do not edit package.json without a stated reason.
  • JSON: snake_case. TS: camelCase. Mappers live in src/lib/case.ts.
  • No console.log in committed code. Use the logger from src/lib/log.ts.

`

Commit it. Push it. Watch what changes.

The Gotchas Nobody Tells You

**Gotcha 1: globs matters more than alwaysApply.** A rule with alwaysApply: true and no globs is injected into every chat — including Markdown edits and config tweaks. The model starts "respecting" rules that do not apply and quietly ignoring the ones that do. Use globs: ["**/*.ts", "**/*.tsx"] for code rules, globs: ["**/*.md"] for docs, and reserve alwaysApply: true for genuine project-wide standards like the eight lines above.

Gotcha 2: The 6,000-character ceiling is silent. Cursor truncates rules files around 6,000 chars with no warning. I wrote a 40-rule essay once, watched half of it get ignored, and spent an hour debugging why "the rules were not working." They were working. They were just cut off. Keep each .mdc file under 6,000 chars. Split by domain — code.mdc, tests.mdc, infra.mdc — with targeted globs.

Gotcha 3: "What not to do" beats "what to do" by roughly 2x. I A/B tested this across two teams. Rules framed as prohibitions (No console.log, No any outside generated code, Do not modify package.json) get followed about twice as often as positive phrasings (Use the logger, Prefer strict types). LLMs were trained on corrective feedback. Tell them what is forbidden. They will infer the rest.

The Real Win

The win is not the rules. The win is the rules are checked into git, get code-reviewed, and survive team turnover. New hire joins Monday, opens Cursor, and the model already knows the conventions. No onboarding doc. No Slack archaeology. No "we used to do it this way" arguments in PR comments.

Stop re-explaining your stack to your editor every session. Write 10 lines once. Get the afternoon back forever.

Mr. Technology


*Cursor rules docs: cursor.com/docs/context/rules. Format: .cursor/rules/*.mdc with YAML frontmatter (description, globs, alwaysApply). Legacy single-file .cursorrules still works. Char cap: ~6,000 per file. Pair with CLAUDE.md for Claude Code and AGENTS.md for cross-tool consistency — same content, three homes, one source of truth.*

Related Dispatches