Full Byte Developer.

Cursor setup for a serious repo: rules and review

Check in AGENTS.md or .cursor/rules, keep rules short, and leave human review on security and product judgment.

Published here , updated · 6 sources

A serious repo needs the agent to see the same house rules on every machine. Cursor docs give two public paths: AGENTS.md for plain markdown, or .cursor/rules/*.mdc when you need globs and apply modes [1] [2]. Pair with Claude Code vs Cursor vs Codex for surface pick, and write AGENTS.md that agents read for the file craft.

Quick start (under a minute)

Add a short AGENTS.md at the repo root with how to run tests and what never to commit [2]. Commit it on the default branch.

When TypeScript-only conventions need path scoping, add one .mdc rule with globs instead of stuffing the root file [1]. Keep total rule text small; Cursor's customizing-agents page says rules ride along in conversations [3].

How instruction files layer

The diagram is the documented layout [1] [2], not every enterprise SSO setting. Team rules and user rules also exist in Cursor settings; this page focuses on what you version in git. A plain .md under .cursor/rules without frontmatter is ignored [1].

Start with a short AGENTS.md at the root

Cursor's rules page calls AGENTS.md the simple alternative to .cursor/rules [1]. Help docs say create it at the project root and write plain instructions; Cursor picks it up automatically [2].

AGENTS.md
# Project instructions

- Run `npm run check` before you commit.
- Use TypeScript for all new files.
- Prefer the smallest change that passes tests.
- Never commit secrets or .env values.

Commit that file. Teammates should see it after git pull on the default branch. Keep it short; Cursor's customizing-agents note says rules are included in conversations and add up, so add a line when you see the same mistake twice [3]. Long manifestos train the model to ignore the signal.

For deeper craft on structure and headings, see write AGENTS.md that agents read.

Add .cursor/rules when you need scoping

Project rules live under .cursor/rules as .mdc files with frontmatter for description, globs, and alwaysApply [1]. A plain .md in that folder is ignored [1].

Apply mode (docs) [1]Use when
Always Apply (alwaysApply: true)Must sit in every chat
Apply Intelligently (description, no globs)Agent pulls it when relevant
Apply to Specific Files (globs)Path patterns like **/*.tsx
Apply ManuallyYou @-mention the rule
.cursor/rules/typescript.mdc
---
description: TypeScript conventions for this repo
globs: "**/*.ts,**/*.tsx"
alwaysApply: false
---

Prefer explicit return types on exported functions.
Do not add dependencies without a one-line reason in the PR.

Track the rule file in git so every clone shares behavior [2]. One scoped file beats five Always Apply files that repeat the same paragraph.

Verify rules are tracked on this draft host

This repo is the working copy on the agent VM. After you add instruction files, confirm git sees them:

bash
git status --short AGENTS.md .cursor/rules 2>/dev/null | head -5

Observed on this draft host (git 2.x, 2026-12-03):

text
(empty if those paths are unchanged; otherwise lines starting with M or ??)

Run the same command locally after you create rules. You should see AGENTS.md or paths under .cursor/rules ready to commit. If nothing appears, the files may be ignored or saved outside the repo root.

Wire a human review loop before merge

Rules do not replace review. Keep a checklist outside the model: security, secrets, product judgment, and smallest change [6]. For over-scoped agent diffs, see stop AI coding agents from over-engineering.

bash
git add AGENTS.md .cursor/rules
git commit -m "docs: add Cursor project rules"

Optional: point AGENTS.md at the same npm run check or cargo test command CI runs so agent suggestions align with the gate humans trust.

Onboard teammates and agents the same way

New contributors should not depend on one person's Cursor settings export. The checked-in AGENTS.md and .cursor/rules files are the contract [2]. In the README, add one paragraph: open the repo in Cursor, confirm rules loaded, run the test command from AGENTS.md, then pick a task.

For reviewers, treat agent-generated diffs like any other diffs: read auth paths, dependency additions, and generated lockfile churn. Rules reduce repeated nits; they do not remove accountability.

When the agent violates a rule twice in one week, add one sentence to the smallest scoped rule file, not a new Always Apply novel. Cursor's learn material is explicit that instructions accumulate in context [3].

Security-shaped rules without secret paste

Never put API keys, .env contents, or customer data samples in rule files to teach the model what to avoid. Reference file names like .env or secrets.yaml and policy sentences instead. Hardcoded credentials in committed instruction files are still credentials in git.

Point agents at your secret scanner command by name if one exists in CI, not at example tokens. Pair rule updates with the same human review checklist you use for application code.

Leave legacy .cursorrules behind

Cursor help marks root .cursorrules as legacy and points you to migrate into a New Cursor Rule with Always Apply, then delete the old file [2]. Prefer the documented layout so new machines do not depend on a deprecated path.

If your team still copies .cursorrules from an old template, migrate once in a dedicated PR so blame stays readable.

You should see the rules files in the commit diff. Open a PR and require a human pass on anything that touches auth, payments, or production config.

Common mistakes and misconceptions

Dumping entire style guides into Always Apply rules. Cursor learn material warns about context bloat [3]. Link to internal docs; put only triggers in rules.

Using plain .md under .cursor/rules. Cursor ignores it without frontmatter [1]. Rename to .mdc or move content to AGENTS.md.

Expecting rules to block bad merges. Rules nudge generation; branch protection and human review still enforce policy.

Duplicating CI secrets in rules. Never paste keys to teach the agent. Point at env var names and secret stores.

One giant rule file per language. Split by glob so backend agents are not force-fed frontend pixel rules.

Untracked local rules die with the laptop. Commit AGENTS.md and .cursor/rules so every clone shares them [2].

Commit one thin AGENTS.md tonight with the three rules your last agent ignored, then re-run the same prompt and diff the result. Keep .cursor/rules next to that file so humans and agents share one spine.

After the first PR lands, open Cursor on a clean clone and ask the agent for the test command named in AGENTS.md. If it invents a different script, your rules are not loading or the file is too vague. Fix the checked-in text before you scale prompts.

Send this to the teammate whose AGENTS.md still lives only on their laptop.

Illustration of document panels and a folder feeding cyan ribbons into a glowing cube hub, then out to a ringed grid of building blocks with orange cables, no people and no readable UI text.
Repo docs steer the agent hub before the block grid of edits.

Keep this guide

By Full Byte Developer

Filed under Dev tools, AI agents

Questions about this guide

Where do project rules live in Cursor?

Cursor docs put version-controlled project rules in .cursor/rules as .mdc files. For plain markdown instructions, AGENTS.md at the repo root is the simple alternative Cursor loads automatically.

Will a plain .md file inside .cursor/rules work?

No. Cursor's rules docs say a plain .md under .cursor/rules is ignored because it has no frontmatter for description, globs, and alwaysApply. Use .mdc for project rules, or AGENTS.md for plain markdown.

Should every instruction be Always Apply?

No. Docs describe Always Apply, intelligent relevance, glob-scoped files, and manual @-mention. Start short; Cursor's learn page warns that rules add up in every conversation.

Does a rule replace code review?

No. Rules steer the agent. Humans still own security, data, and product judgment, same as any AI diff.

What belongs in the first AGENTS.md?

Stack facts, test command, smallest-change expectation, and secrets policy. Add lines when you see the same agent mistake twice.

Sources

Next in this stack