Skip to main content
VibeStacks

Loading the search index…

EntryAlternative

Rules

Tool-specific rules that apply only to certain folders or file types, covering local conventions that do not belong in AGENTS.md.

Last reviewed
Website
cursor.com

Good for

  • Folders with their own patterns, such as tests, database migrations, or generated code
  • Using a single AI tool and needing its rule features (path matching, manual references)
  • An AGENTS.md that has grown too long and needs local rules split out

Not for

  • Conventions for the whole project (put them in AGENTS.md so every tool sees them)
  • Teams using different tools, if key rules would live only in one tool's format

Rules are each AI tool's own rule mechanism. In Cursor, for example, rules are .mdc files in .cursor/rules/, and their frontmatter decides when they apply.

Why it is an alternative

Almost every tool reads AGENTS.md; Rules only work in the tool they were written for. So our default is write AGENTS.md first, and turn only the local rules it cannot hold into Rules. Scoped rules really pay off when a team uses one tool and has many rules.

How they apply (Cursor as an example)

The frontmatter has three fields:

  • alwaysApply: true: loaded every time, the same role as AGENTS.md.
  • globs: loaded only when matching files are read or edited, e.g. tests/**/*.ts.
  • description: what the rule covers; the agent uses it to decide whether to read it.

Note that rule files must be .mdc files with frontmatter; plain .md files are ignored. The old single-file .cursorrules is no longer in the official docs, so do not use it in new projects.

Writing a good rule

  • One file, one concern. Keep testing conventions and migration conventions in separate files.
  • Write checkable requirements. "Test names describe behavior in plain language" beats "write good tests".
  • Keep it short. More rules mean more conflicts, and the agent is more likely to skip them.
Souvenir

Take it home to your AI

Drop this .cursor/rules/tests.mdc into your project, or paste it straight to your AI coding assistant.

.cursor/rules/tests.mdc
---
description: Conventions for writing and changing tests
globs: ["tests/**/*.ts", "src/**/*.test.ts"]
alwaysApply: false
---

- Name each test with a sentence describing the behavior under test, not the function name.
- One behavior per test; keep arrange, act, and assert separate.
- When fixing a bug, first write a failing test that reproduces it, then change the implementation.
- Never weaken assertions, skip tests, or delete tests to make them pass.
- Do not hit the real network or a real database in tests; use the project's existing test doubles.
  • EntryTop pick

    AGENTS.md

    A README for AI coding agents. One Markdown file in the repository root that almost every tool reads.

  • EntryTop pick

    Cursor

    An AI IDE built on VS Code. Completion, chat, the agent, and your code live in one window, and every change arrives as a diff.

  • Article

    The pieces of context you give AI

    AGENTS.md sets project rules, Rules handle local scope, MCP adds external capabilities, and Skills hold know-how loaded on demand.