Commit Cursor Rules to Git: A Team Setup That Works
Two developers on the same repo ask Cursor for the same component and get two different styles of code: one uses default exports, the other named exports; one reaches for fetch, the other for the axios wrapper. The cause is rarely the model. It is usually that one person has rules on their laptop and the other does not. If that sounds familiar, you should commit Cursor rules to git so every teammate, and every CI-driven agent, starts from the same instructions.
A Cursor project rule is a plain text file, stored inside the repository, that Cursor injects into the model's context so generated code follows your conventions. Because it is just a file, it can be versioned, reviewed and reverted like any other source file. This article covers what to commit, what to keep out, how to lay out the folder, and how to stop the rules from decaying after the first month.
Should you commit Cursor rules to git?
Yes. Project rules describe how the codebase works, and anything that describes the codebase belongs next to the codebase. Committed rules give you three things a local-only setup cannot: a single shared version, a review step before an instruction changes how everyone's AI writes code, and a history that tells you when and why a convention changed.
There is also a practical reason. A rule that only exists on one machine cannot be debugged by anyone else. When the model ignores an instruction, the first question is always which rules were loaded. If the rules are in the repo, a teammate can open the same files and reproduce the problem in minutes.
The one exception is anything personal. Tone of explanations, preferred language for chat replies and editor habits are not project conventions, and they should not be forced on colleagues.
What belongs in the repo and what stays personal?
Project conventions go in the repo, and personal preferences stay in your own Cursor settings. Cursor keeps user-level rules in its settings, outside any repository, so they follow you across projects without touching the team's files. Project rules live in the folder .cursor/rules and are checked in with everything else.
The table below is the split we recommend. Use it as a test: if a new hire would need the instruction to write correct code on day one, it is a project rule.
| Instruction | Where it lives | Why |
|---|---|---|
| Use the shared API client, never raw fetch | Repo, .cursor/rules | Every contributor needs it |
| Test files sit next to the source file | Repo, scoped by glob | Part of the project layout |
| Database migrations are never edited after merge | Repo, always applied | Safety rule for the whole team |
| Explain changes in short bullet points | Personal user settings | Individual taste |
| Reply in a specific language in chat | Personal user settings | Individual taste |
How should you lay out the .cursor/rules folder?
Use one small file per concern, named for the concern, and scope each file to the paths it applies to. Cursor's current project rule format is the .mdc file, which carries a short frontmatter block with a description, optional globs and an always-apply flag. A single giant file defeats review, because nobody can tell what a diff changes in practice.
A layout that stays readable looks like this:
.cursor/rules/
00-project-overview.mdc (always applied, under 30 lines)
api-client.mdc (globs: src/lib/api/**)
react-components.mdc (globs: src/components/**/*.tsx)
testing.mdc (globs: **/*.test.ts)
migrations.mdc (globs: db/migrations/**)Keep the always-applied set tiny. Every always-on rule costs context on every request, which is why a long list tends to dilute the instructions that matter. Everything else should be attached by glob or by description so it loads only when relevant.
How do you review a rule change?
Treat a rule change as a code change that alters behaviour, and review it the same way. The reviewer's job is not to check the grammar. It is to check that the rule is specific, testable and not already covered by another file. Follow these steps for every pull request that touches .cursor/rules:
- Read the diff and ask what concrete code the rule will change. If you cannot name an example, the rule is too vague.
- Check for conflicts with existing files by searching the rules folder for the same topic.
- Confirm the rule is scoped: a glob, or a description precise enough for Cursor to decide when to attach it.
- Run one real prompt in a branch before and after the change, and compare the output.
- Record the reason in the pull request description so the history explains the rule later.
Step four is the one teams skip, and it is the one that catches silent failures. A rule that reads well but changes nothing is just noise in the context window.
What goes wrong when rules live in git?
The most common failure is drift: the code moves on and the rules do not. A rule that says to use a library the team already removed will actively push the model toward outdated code. The fix is ownership. Give each rule file one owner, and make part of every dependency upgrade a quick check of the rules that mention that dependency.
The second failure is contradiction. Two files that disagree, for example one demanding default exports and another named exports, leave the model to pick, and it will not pick consistently. A short monthly search of the folder for shared keywords finds most of these.
The third failure is the legacy file. Older projects often still carry a root-level .cursorrules file next to the newer folder. If both exist, you cannot be sure which one a given teammate's version of Cursor honours, so migrate the old file into the folder and delete it.
Where do you get good rules without writing them all?
Writing rules from scratch is slow, and most of the time goes into discovering which instructions the model actually follows. If you work in a mainstream stack, starting from a tested set and trimming it to your conventions is faster than a blank folder. BuyCoded sells the Cursor Rules Mega-Pack, which lists 1,057 rules across 20 stacks in both Cursor formats, so you can copy the relevant files into .cursor/rules and commit them as your starting point. Details and the stack list are on the Cursor Rules Mega-Pack page.
Whichever source you use, the same discipline applies: commit only the rules you will keep, delete the rest, and edit what remains to match your real codebase. A bought rule you never reviewed is no better than a copied one from a forum thread.
Is it worth the process for a small team?
For a solo developer, a lightweight version is enough: commit the folder, keep the always-on file short, and skip formal review. The process earns its cost when a second person starts using an AI editor on the same repo, because that is the moment inconsistent output turns into inconsistent code in the main branch.
The honest objection is that rules are only suggestions to a model and cannot enforce anything. That is true. Rules reduce mistakes but do not replace linters, type checks and tests, and you should keep those as the actual gate. Think of committed rules as the cheap first pass that makes the expensive checks fail less often.
What is the next step?
Create the .cursor/rules folder today, add a 20-line overview file and one scoped rule for the area where your team disagrees most, and open a pull request for it. When you want a larger base to trim from, browse the BuyCoded product catalog, pick the pack that matches your stack, and you can download it instantly and commit the files you keep. You can also read more on rule design in the BuyCoded blog.
Frequently asked questions
Should I commit .cursor/rules to git?
Yes, commit it. Project rules describe how your codebase works, so they belong in version control with the code. Committing gives the whole team one shared set of instructions, a review step before conventions change, and a history you can read when the model starts behaving differently. Keep purely personal preferences in your own Cursor user settings instead.
Where do personal Cursor rules go if the project rules are in git?
Personal rules go in your Cursor user settings, which are stored outside the repository. That keeps tone, chat language and editor habits on your machine only. Project conventions that a new teammate needs to write correct code belong in the committed .cursor/rules folder, where everyone loads the same files.
Can I keep both .cursorrules and .cursor/rules in the same repo?
You can, but you should not. Having both makes it unclear which instructions a given teammate's Cursor version applies. Migrate the contents of the root .cursorrules file into scoped .mdc files inside .cursor/rules, review them, and delete the old file so there is one source of truth.
How do I review a pull request that changes Cursor rules?
Review it like a behaviour change. Ask what concrete code the rule will alter, check it does not contradict another rule file, confirm it is scoped by glob or description, and run the same prompt before and after on a branch. If the output does not change, the rule adds context cost and no value.
How often should a team audit its Cursor rules?
Audit whenever a dependency is upgraded or removed, and do a quick search for contradictions about once a month. Rules referencing a library you no longer use push the model toward outdated code. Assigning one owner per rule file makes these checks fast, because someone is clearly responsible for each file.