Cursor IDE AGENTS.md Project Configuration: Format, Rules & Examples (2026)
π 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:
- π― Consistency: Every team memberβs AI behaves the same way
- π Quality: Enforces coding standards automatically
- π§ Context: Gives AI knowledge of your architecture and conventions
- π Safety: Limits what the AI can do
ποΈ Current project instruction formats
The useful distinction in 2026 is between portable repository instructions and tool-specific rules:
| File | Tool | Scope | Best use |
|---|---|---|---|
| AGENTS.md | Cursor, Codex, Jules, and other coding agents | Repository or nested directory | Portable project context and commands |
| .cursor/rules/*.mdc | Cursor IDE | Project, file patterns, or always-on | Cursor-specific scoped rules |
| CLAUDE.md | Claude Code | User, project, or directory | Claude-specific instructions |
| .cursorrules | Older Cursor versions | Project root | Legacy 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:
- π Supports hierarchical, directory-level configuration
- π Tool-agnostic β any AI assistant can read it
- π Markdown format, easy for humans to read too
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:
- π§ Automatically read by Claude Code
- π§ Supports global (user-level) + project-level + directory-level
- π Can include bash commands (build, test commands)
.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
Strategy 1: Commit Everything to Git (Recommended)
# 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:
- Project tech stack description
- 3-5 most important coding rules
- Build and test commands
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:
- π Review monthly β remove outdated content
- π When AI repeatedly makes a mistake β add a rule
- π Tech stack changes β update immediately
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
- Create
AGENTS.mdin your project root - Add project overview and tech stack
- Add 3-5 core coding rules
- Add build/test commands
- Add a βForbiddenβ list
- If using Cursor-specific scopes: create
.cursor/rules/*.mdc - If using Claude Code-specific behavior: create
CLAUDE.md - Commit to Git for team sync
- Schedule monthly reviews and updates
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.