Cursor IDE AGENTS.md Project Configuration: Format, Rules & Examples (2026)

Β· Updated

πŸ“‹ Why Do You Need AI Configuration Files?

In Agentic Engineering, AI is your executor. But just like a new hire needs onboarding to learn team conventions, AI agents need their own β€œonboarding docs.”

An AI without configuration files is like a project without a README β€” it works, but it’s unpredictable.

Core problems AI config files solve:

πŸ—‚οΈ Current project instruction formats

The useful distinction in 2026 is between portable repository instructions and tool-specific rules:

FileToolScopeBest use
AGENTS.mdCursor, Codex, Jules, and other coding agentsRepository or nested directoryPortable project context and commands
.cursor/rules/*.mdcCursor IDEProject, file patterns, or always-onCursor-specific scoped rules
CLAUDE.mdClaude CodeUser, project, or directoryClaude-specific instructions
.cursorrulesOlder Cursor versionsProject rootLegacy format; migrate to .cursor/rules

AGENTS.md β€” portable project instructions

AGENTS.md is an open Markdown format for coding-agent instructions. Cursor officially supports it as a simpler alternative to .cursor/rules, and the same file can be reused by other compatible agents.

project-root/
β”œβ”€β”€ AGENTS.md          ← Top-level: global rules
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ AGENTS.md      ← Subdirectory: module-specific rules
β”‚   β”œβ”€β”€ frontend/
β”‚   β”‚   └── AGENTS.md  ← More specific frontend rules
β”‚   └── backend/
β”‚       └── AGENTS.md  ← More specific backend rules
└── tests/
    └── AGENTS.md      ← Testing-related rules

Characteristics:

CLAUDE.md β€” Claude Code Specific

CLAUDE.md is the configuration file that Anthropic’s Claude Code reads. Similar to AGENTS.md but with some Claude-specific features.

project-root/
β”œβ”€β”€ CLAUDE.md           ← Project-level config
β”œβ”€β”€ ~/.claude/CLAUDE.md ← User-level global config
└── src/
    └── CLAUDE.md       ← Subdirectory-level config

Characteristics:

.cursor/rules β€” Cursor project rules

Current Cursor project rules are stored under .cursor/rules and are version-controlled with the repository:

project-root/
β”œβ”€β”€ AGENTS.md
└── .cursor/
    └── rules/
        β”œβ”€β”€ core.mdc
        β”œβ”€β”€ frontend.mdc
        └── tests.mdc

An .mdc rule can include metadata that controls when it applies:

---
description: Frontend conventions
globs: ["src/**/*.tsx", "src/**/*.ts"]
alwaysApply: false
---

- Prefer server components unless browser state is required.
- Run `pnpm lint` and `pnpm test` after changes.

Use Cursor rules when you need file-pattern scoping or Cursor-specific behavior. The root .cursorrules file is now a legacy format.

πŸ“ Template Examples

AGENTS.md Universal Template

# AGENTS.md

## Project Overview
This is a Next.js 15 + TypeScript web application for [project description].

## Tech Stack
- **Framework**: Next.js 15 (App Router)
- **Language**: TypeScript (strict mode)
- **Styling**: Tailwind CSS v4
- **Database**: PostgreSQL + Drizzle ORM
- **Testing**: Vitest + Playwright

## Coding Standards

### TypeScript
- Use `interface` over `type` for object shapes
- Always use explicit return types on exported functions
- Prefer `const` assertions where applicable
- No `any` β€” use `unknown` + type guards instead

### File Organization
- Components: `src/components/[feature]/[ComponentName].tsx`
- Hooks: `src/hooks/use[HookName].ts`
- Utils: `src/lib/[domain].ts`

### Naming Conventions
- Components: PascalCase
- Files: kebab-case (except components)
- Constants: UPPER_SNAKE_CASE
- Database tables: snake_case

## Build & Test Commands
- `pnpm dev` β€” Start development server
- `pnpm build` β€” Production build
- `pnpm test` β€” Run unit tests
- `pnpm test:e2e` β€” Run E2E tests
- `pnpm lint` β€” Lint check

## Important Rules
1. Never modify migration files directly
2. Always run `pnpm test` before committing
3. All API routes must have input validation (zod)
4. No secrets in code β€” use environment variables
5. All public functions must have JSDoc comments

CLAUDE.md Template

# CLAUDE.md

## Project Context
[Similar project description as AGENTS.md]

## Claude-Specific Instructions

### Thinking Style
- Think step-by-step before making changes
- Always explain WHY before making a change
- When unsure, ask rather than guess

### File Operations
- Read the full file before editing
- Make minimal, focused changes
- Always verify changes compile: `pnpm tsc --noEmit`

### Git Workflow
- Commit messages follow Conventional Commits
- One logical change per commit
- Run tests before suggesting commit

### Off Limits
- Do NOT modify: `.env`, `*.lock`, `migrations/`
- Do NOT run: `rm -rf`, `DROP TABLE`, `git push --force`

## Common Tasks
- "Add a new API endpoint": Create route in `src/app/api/`, add zod schema, add tests
- "Fix a bug": Read error, find root cause, write test first, then fix
- "Refactor": Ensure tests pass before AND after

Cursor .cursor/rules/core.mdc template

---
description: Core TypeScript and repository rules
alwaysApply: true
---

# Project standards

- Use TypeScript strict mode; do not introduce `any`.
- Prefer server components unless browser state is required.
- Use prepared statements for database queries.
- Never commit `.env` files or credentials.
- Run `pnpm lint`, `pnpm test`, and `pnpm build` before finishing.

Keep the portable explanation of the project in AGENTS.md; keep Cursor-only scoping and editor behavior in .cursor/rules.

πŸ”„ Team Sharing Strategies

# Make sure these files are NOT in .gitignore
# The following files should be version-controlled:
AGENTS.md
CLAUDE.md
.cursor/rules/*.mdc

Pros: Everyone auto-syncs, version history is tracked Cons: Personal preferences need to go in global config

Strategy 2: Layered Configuration

# Team-shared (committed to Git)
AGENTS.md                 ← Portable team standards
.cursor/rules/core.mdc    ← Cursor-specific rules

# Personal config (not committed)
~/.claude/CLAUDE.md  ← Personal Claude global config

In .gitignore:

# Don't ignore team config files
!AGENTS.md
!CLAUDE.md
!.cursor/
!.cursor/rules/

Strategy 3: Monorepo Multi-Project

monorepo/
β”œβ”€β”€ AGENTS.md              ← Global portable rules
β”œβ”€β”€ .cursor/rules/         ← Cursor-specific project rules
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ web/
β”‚   β”‚   β”œβ”€β”€ AGENTS.md      ← Web frontend-specific rules
β”‚   β”‚   └── CLAUDE.md
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ AGENTS.md      ← API backend-specific rules
β”‚   β”‚   └── CLAUDE.md
β”‚   └── shared/
β”‚       └── AGENTS.md      ← Shared library rules

βœ… Best Practices

1. Start Small, Grow Organically πŸ“ˆ

Don’t write a 500-line config file on day one. Start with:

Then add rules based on issues you encounter in practice.

2. Use Concrete Examples, Not Abstract Descriptions 🎯

# ❌ Bad
Write clean code.

# βœ… Good
## Error Handling
Use the Result pattern:
​```typescript
type Result<T> = { ok: true; data: T } | { ok: false; error: string };

// Good
function getUser(id: string): Result<User> { ... }

// Bad β€” don't throw for business logic errors
function getUser(id: string): User { throw new Error(...) }
​```

3. Keep It Up to Date πŸ”„

Config files aren’t write-once-forget:

4. Keep one source of truth 🀝

If your team uses both Cursor and Claude Code:

# AGENTS.md β€” portable project standards and commands

# CLAUDE.md β€” Claude-specific additions; avoid copying the whole AGENTS.md

# .cursor/rules/*.mdc β€” Cursor-only scopes, globs, or editor behavior

Do not maintain three full copies of the same rules. Duplicated instructions drift and eventually conflict.

5. Add a β€œForbidden” List 🚫

Explicitly tell AI what NOT to do:

## Forbidden Actions
- Never delete or modify migration files
- Never commit .env files
- Never use `rm -rf` without explicit confirmation
- Never bypass TypeScript strict mode
- Never add dependencies without checking bundle size

6. Include Standard Workflow Recipes πŸ“‹

## Standard Workflows

### Adding a New Feature
1. Create feature branch from `main`
2. Write failing tests first (TDD)
3. Implement the feature
4. Ensure all tests pass: `pnpm test`
5. Run linting: `pnpm lint`
6. Create PR with description template

### Database Changes
1. Create migration: `pnpm drizzle-kit generate`
2. Review generated SQL
3. Test migration: `pnpm drizzle-kit push`
4. Never modify existing migrations

πŸš€ Quick Start Checklist


Configuration files are the β€œinfrastructure” of agentic engineering. Spend 30 minutes setting them up, save your team hundreds of hours of rework. πŸ—οΈ

Official references

Want to learn how to roll out agentic engineering across your team? Read our Team Adoption Guide.

Frequently Asked Questions

Does Cursor support AGENTS.md?

Yes. Cursor documents AGENTS.md as a Markdown-based alternative to .cursor/rules for Agent instructions. Put AGENTS.md in the project root and keep the instructions relevant to the repository.

What is the correct Cursor project rules format in 2026?

Cursor project rules live under .cursor/rules and commonly use .mdc files with optional frontmatter such as description, globs, and alwaysApply. The older root .cursorrules file is legacy and should be migrated.

Can a monorepo have more than one AGENTS.md file?

Yes. Put a root AGENTS.md at the repository level and nested AGENTS.md files inside packages or modules. The closest applicable file provides the more specific instructions.

Should I use AGENTS.md or .cursor/rules?

Use AGENTS.md for portable repository instructions shared across coding agents. Add .cursor/rules when you need Cursor-specific scoping, globs, or always-on rule metadata. Many teams use both with AGENTS.md as the source of truth.

Was this article helpful?

πŸ’¬ Comments