# 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.

Source: https://fullbytedeveloper.com/blog/cursor-setup-for-serious-repo
Published here: 2026-12-03, updated 2026-12-03

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](/blog/claude-code-vs-cursor-vs-codex) for surface pick, and [write AGENTS.md that agents read](/blog/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

<figure aria-label="Repository root feeding AGENTS.md and scoped mdc rules into Cursor agent context">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 280" role="img" aria-hidden="true">
  <defs>
    <marker id="cursorsetupforseriousrep-csr-arr" markerWidth="8" markerHeight="8" refX="7" refY="4" orient="auto">
      <path d="M0,0 L8,4 L0,8 Z" fill="#14b8a6"/>
    </marker>
  </defs>
  <rect x="0" y="0" width="360" height="280" rx="12" fill="#0b1f3a"/>
  <rect x="124.615" y="7" width="110.769" height="50" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="1.38462"/>
  <text x="180" y="38" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">repo root [2]</text>
  <line x1="152.308" y1="52" x2="83.0769" y2="88" stroke="#14b8a6" stroke-width="1.38462" marker-end="url(#cursorsetupforseriousrep-csr-arr)"/>
  <line x1="207.692" y1="52" x2="276.923" y2="88" stroke="#14b8a6" stroke-width="1.38462" marker-end="url(#cursorsetupforseriousrep-csr-arr)"/>
  <rect x="16.6154" y="85" width="132.923" height="70" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="1.38462"/>
  <text x="83.0769" y="116" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">AGENTS.md</text>
  <text x="83.0769" y="134" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">plain markdown, always loaded [1]</text>
  <rect x="210.462" y="85" width="132.923" height="70" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="1.38462"/>
  <text x="276.923" y="116" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">.cursor/rules/*.mdc</text>
  <text x="276.923" y="134" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">globs, apply modes [1]</text>
  <line x1="180" y1="148" x2="180" y2="188" stroke="#14b8a6" stroke-width="1.38462" marker-end="url(#cursorsetupforseriousrep-csr-arr)"/>
  <rect x="110.769" y="186.5" width="138.462" height="55" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="1.38462"/>
  <text x="180" y="214" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">Cursor agent / cloud clone</text>
  <text x="180" y="230" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">reads rules on every session [3]</text>
  <text x="180" y="268" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">Legacy .cursorrules: migrate to Always Apply, then delete [2]</text>
</svg>
</figure>

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].

```md title="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](/blog/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 Manually | You `@`-mention the rule |

```md title=".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](/blog/stop-ai-coding-agent-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.

Image: 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.
https://fullbytedeveloper.com/media/cursor-setup-for-serious-repo/cursor-setup-for-serious-repo-venice.webp
Repo docs steer the agent hub before the block grid of edits.

## Sources

1. [Cursor docs: Rules, accessed 2026-12-03](https://cursor.com/docs/rules)
2. [Cursor help: Rules customization, accessed 2026-12-03](https://cursor.com/help/customization/rules)
3. [Cursor learn: Customizing agents, accessed 2026-12-03](https://cursor.com/learn/customizing-agents)
4. [Full Byte Developer: Claude Code vs Cursor vs Codex](https://fullbytedeveloper.com/blog/claude-code-vs-cursor-vs-codex)
5. [Full Byte Developer: Write AGENTS.md that agents read](https://fullbytedeveloper.com/blog/write-agents-md-that-agents-read)
6. [Full Byte Developer: Stop AI coding agents from over-engineering](https://fullbytedeveloper.com/blog/stop-ai-coding-agent-over-engineering)
