← All guides Teams

Sharing Cursor rules across a team

Commit .cursor/rules/ to git, use globs for different roles, and avoid merge conflicts.

Why teams need shared rules

Without shared rules, every developer on your team gets different AI suggestions. One person's Cursor uses camelCase, another's uses snake_case. One writes tests with Jest, another with Vitest. Shared rules keep everyone on the same conventions.

Benefits of committing rules to git:

Commit .cursor/rules/ to git

Cursor loads rules from .cursor/rules/ in your project directory. Commit this folder to git so the team shares the same setup.

git add .cursor/rules/
git commit -m "Add shared Cursor rules"
git push

Everyone who pulls the repo gets the rules automatically. No manual setup needed.

Don't commit personal rules: Keep team-wide rules in .cursor/rules/. Put personal preferences in your global Cursor config (outside the project).

Use globs for different roles

Not every rule applies to every file. Use globs to scope rules to specific parts of the codebase. This keeps frontend rules from firing in backend files, and vice versa.

Example structure:

.cursor/rules/
├── typescript-naming.mdc       # All .ts files
├── react-components.mdc        # Frontend only
├── api-routes.mdc              # Backend only
└── database-queries.mdc        # DB layer only

Frontend rule with scoped globs:

---
description: React component conventions
globs:
  - "src/components/**/*.tsx"
  - "src/pages/**/*.tsx"
---
Use functional components.
Extract custom hooks when logic repeats.
Name props interfaces with Props suffix.

Backend rule with different globs:

---
description: API error handling
globs:
  - "src/api/**/*.ts"
  - "src/routes/**/*.ts"
---
Wrap route handlers in try-catch.
Return {error, code} on failure.
Log errors with request context.

Naming conventions

Clear filenames make it obvious what each rule does and reduce merge conflicts. A few conventions that help:

❌ Vague names

  • frontend.mdc
  • backend.mdc
  • general.mdc
  • misc.mdc

✓ Clear names

  • react-hooks.mdc
  • api-error-handling.mdc
  • typescript-naming.mdc
  • database-queries.mdc

Avoiding merge conflicts

Merge conflicts happen when two people edit the same rule file at the same time. A few ways to reduce this:

Comparing setups across the team

The team commands (Pro feature) help keep everyone in sync. Export your rules as a shareable config, set a team baseline, and detect drift:

# Export rules to a shareable config file
npx cursor-doctor team export

# Set a baseline from a file or URL
npx cursor-doctor team baseline ./team-rules.json

# Check for drift from the baseline
npx cursor-doctor team drift

Team members can import the shared config with npx cursor-doctor team import <file-or-url>.

These are Pro features. The basic workflow (commit to git, pull to sync) works without them.

Personal overrides

Sometimes you want a personal rule that doesn't apply to the whole team. Put these in your global Cursor config, not in .cursor/rules/.

Cursor stores user-level settings in its app data directory. Check Cursor's documentation for the current global rules path on your OS, as it can change between versions.

Global rules load in every project. Use them for personal preferences that don't affect the team.

Validating team rules

Before pushing rule changes, run the linter to catch errors:

npx cursor-doctor scan

This checks frontmatter, globs, and rule quality. Add it to your CI workflow to block PRs with broken rules (see the CI guide).

Related guides

Scan your team's rules

Check your shared rules for frontmatter errors, invalid globs, and quality issues before committing.

npx cursor-doctor scan