Skip to content
Move custom links under /@handle
Sniptide

Cursor rules examples

Cursor rules are Markdown files in .cursor/rules that give Cursor's agent standing instructions for your project. Copy the two rules below, one that applies to every request and one that applies only when you work on React components, and adjust them to your code.

Updated

Files

.cursor/rules/project.mdcRaw
---
description: Project overview, commands and rules that apply to every task
alwaysApply: true
---

# Acme Dashboard

Next.js App Router, TypeScript, Tailwind CSS and Drizzle on Postgres.

## Commands

- Dev server: `pnpm dev`
- Tests: `pnpm test`
- Lint and types: `pnpm lint && pnpm typecheck`

Run the tests and the type check before you finish a task.

## Rules

- TypeScript strict mode. Use `unknown` and narrow it instead of `any`.
- Database access only in `lib/db`. Components call functions from there.
- Ask before you add a dependency.
.cursor/rules/react-components.mdcRaw
---
description: How to write React components in this project
globs: components/**/*.tsx, app/**/*.tsx
alwaysApply: false
---

# React components

- Server Components by default. Add `"use client"` only for state, effects or browser APIs.
- One component per file, named export, file name in kebab-case: `order-table.tsx`.
- Props get a `type`, not an `interface`, declared above the component.
- Style with Tailwind classes. Merge conditional classes with `cn()` from `@/lib/utils`.
- Build on the primitives in `components/ui` before writing new markup.

Follow the structure of this example:

@components/ui/empty-state.tsx

Save with your agent

Connect the Sniptide MCP server once, then ask your agent to keep this template in your library. It reads the files from the JSON version of this page and saves them as a private snippet you can edit and file into a collection.

Terminal
claude mcp add --transport http sniptide https://app.sniptide.com/api/mcp
Prompt
Read https://sniptide.com/templates/cursor-rules.json and save its files as a private Sniptide snippet titled "Cursor rules examples".

How Cursor picks a rule

Each rule is an .mdc file: YAML frontmatter that decides when the rule applies, then Markdown instructions. Commit the folder and everyone on the project gets the same rules. The frontmatter gives four ways to apply a rule:

Type
Frontmatter
When it applies
Always
alwaysApply: true
In every request in the project. Keep these short.
Auto attached
globs with alwaysApply: false
When a file matching the globs is in the conversation.
Agent requested
description only
When the agent decides from the description that it needs the rule.
Manual
No description, no globs
Only when you mention it, such as @react-components.

A line like @components/ui/empty-state.tsx inside a rule attaches that file whenever the rule applies. One real example in your codebase teaches more than a paragraph of style rules.

What each rule does

project.mdc is the always-on rule. It holds what every request needs: the stack in one line, the commands and a few rules. Change it when a script or a team rule changes.

react-components.mdc applies only while Cursor works on .tsx files in components/ or app/. Rules scoped by globs cost nothing in other requests, so this is where detailed conventions belong. Add a rule like it for each area with its own conventions, such as API routes or tests.

Older projects keep their rules in a single .cursorrules file at the root. Cursor still reads it, but it is deprecated, so move its contents into .cursor/rules and split them by area as you go.

Variant: a rule the agent requests

A rule with only a description stays out of context until a task matches it. This suits instructions for a task that comes up now and then, such as writing a migration.

.cursor/rules/database-migrations.mdc
---
description: Use when creating or changing database tables, columns or indexes
---

# Database migrations

1. Change the schema in `db/schema.ts`.
2. Run `pnpm db:generate` and read the generated SQL in `db/migrations/`.
3. Never edit a migration that is already merged. Write a new one.
4. Add a column as nullable or with a default, so the migration runs on a live table.

Variant: one file for every agent

If your team also uses Claude Code or Codex, Cursor reads an AGENTS.md at the root of the repository as well. Put shared rules there and keep .cursor/rules for what only Cursor needs. The AGENTS.md template is a starting point.

All templates
  • Agent filesAGENTS.md template

    An AGENTS.md template and example with setup, checks, code style, testing and PR rules, plus a monorepo layout. Copy it into your repo.

  • Agent filesCLAUDE.md template

    A CLAUDE.md template for Claude Code with commands, layout, code style and rules, plus monorepo and AGENTS.md variants you can copy.

  • Agent filesClaude Code skill template

    A Claude Code skill template with a SKILL.md example and a supporting file, plus the frontmatter fields, scopes and two variants explained.

Pick where your library lives.

Use sniptide.com

Save your first pattern in the app, then connect Claude Code, Cursor or Codex with one sign-in in the browser.

Run it on your own server

One image and a database give you the app, the API and the MCP endpoint. Sniptide is open source under AGPL-3.0.

$docker compose up -d