Guide for creating effective AGENTS.md files for Cursor. Use when (1) Creating new AGENTS.md files in project root, (2) Improving existing agent instructions, (3) Setting up project-specific coding guidelines, (4) Defining code style and architecture rules, (5) Writing simple agent instruction files as alternative to .cursor/rules, or any task related to Cursor AGENTS.md configuration.
Guide for creating effective AGENTS.md files that define project instructions for Cursor AI assistant.
⚠️ Important: Write reminders in
AGENTS.mdto urge the agents to readcursor-agents-mdskills every time before write or updateAGENTS.md, e.g.,
> **⚠️ Important:** You must read `cursor-agents-md` skills every time before write or update this `AGENTS.md`.
⚠️ Important: Before creating or updating AGENTS.md files, always consult the official Cursor documentation using
@Cursorto ensure alignment with the latest standards, features, and limitations. Cursor's functionality and requirements may change over time, so verifying against official documentation ensures your AGENTS.md files work correctly.
AGENTS.md is a simple markdown file for defining agent instructions. Place it in the project root directory as an alternative to .cursor/rules, suitable for simple, straightforward use cases.
Unlike Project Rules, AGENTS.md is a plain markdown file without metadata or complex configuration. It's ideal for projects that only need simple, readable instructions without the additional overhead of structured rules.
.cursor/rules directory instead, which supports multiple rule files with specific scopes and metadata configurationsEffective AGENTS.md files follow these principles:
AGENTS.md should be:
Use AGENTS.md when:
Use .cursor/rules when:
# Project Instructions
## Code Style
- Use TypeScript for all new files
- Prefer functional components in React
- Use snake_case for database columns
- Follow ESLint configuration in `.eslintrc.js`
- Maximum line length: 100 characters
## Architecture
- Follow the repository pattern
- Keep business logic in service layers
- Controllers should only handle HTTP requests/responses
- Use dependency injection for all services
## Testing
- Write unit tests for all service methods
- Use Jest for testing framework
- Aim for 80% code coverage minimum
- Place tests in `__tests__` directories adjacent to source files
## File Structure
- `src/` - Application source code
- `tests/` - Integration and E2E tests
- `docs/` - Documentation files
- `config/` - Configuration files
## Commands
- Build: `npm run build`
- Test: `npm test`
- Lint: `npm run lint --fix`
- Format: `prettier --write "src/**/*.{ts,tsx}"`
## Boundaries
- Never commit secrets or API keys
- Don't modify `node_modules/` or `vendor/` directories
- Ask before changing database schema
- Don't remove existing tests, even if they're failing
Define coding standards, naming conventions, and formatting rules:
Document architectural patterns and design decisions:
Specify testing requirements and practices:
Describe project directory organization:
List commonly used commands with descriptions:
Define what should never be done:
# Project Instructions
## Code Style
- Use [language] for all new files
- Follow [naming convention] for [variable types]
- Maximum line length: [number] characters
- Use [formatter] with configuration in [config file]
## Architecture
- Follow [design pattern] pattern
- Keep [layer] logic in [location]
- Use [dependency management approach]
## Testing
- Write [test type] for all [components]
- Use [testing framework]
- Aim for [coverage]% code coverage minimum
- Place tests in [location]
## File Structure
- `src/` - [description]
- `tests/` - [description]
- `docs/` - [description]
## Commands
- Build: `[command]`
- Test: `[command]`
- Lint: `[command]`
- Format: `[command]`
## Boundaries
- Never [action]
- Don't modify [files/directories]
- Ask before [action]
📚 Before starting: Query
@Cursordocumentation to verify current AGENTS.md requirements and any recent changes to the format or functionality.
.cursor/rules instead..cursor/rules.When adding new information to AGENTS.md, follow these strategies to maintain document quality and consistency:
Before adding new content:
Decision tree:
When adding to existing sections:
Example - Good integration:
## Architecture
- Follow the repository pattern
- Keep business logic in service layers
- Controllers should only handle HTTP requests/responses
- Use dependency injection for all services
- **NEW:** Use event-driven architecture for cross-service communication
Example - Bad integration:
## Architecture
- Follow the repository pattern
- Keep business logic in service layers
## NEW STUFF ABOUT EVENTS
We should use events now. This is important.
When adding new information, check for:
Example workflow:
Best practices for tracking changes:
Option A: Inline updates (for small changes)
**Updated 2024-01-15:** Changed from Jest to Vitest~~Use Jest~~ → Use VitestOption B: Changelog section (recommended for significant updates)
## 📝 Update Log
### 2024-01-15
- ✅ Updated testing framework from Jest to Vitest
- ✅ Added new event-driven architecture pattern
- ✅ Expanded File Structure section with `events/` directory
### 2024-01-10
- ✅ Initial AGENTS.md creation
Benefits of changelog:
Before finalizing new information:
When correcting errors or outdated information in AGENTS.md, follow these practices:
Types of corrections:
How to identify:
Strategy A: Direct Replacement (for simple errors)
# Before
- Use Jest for testing
# After
- Use Vitest for testing
Strategy B: Marked Correction (for significant changes)
# Before
- Use Jest for testing
# After
- Use Vitest for testing *(Updated: Jest deprecated as of 2024-01-15)*
Strategy C: Strikethrough + New (for historical context)
- ~~Use Jest~~ → Use Vitest for testing
Strategy D: Correction Note (for complex corrections)
## Testing
- Use Vitest for testing
> **⚠️ Correction Note (2024-01-15):** Previously documented Jest, but project migrated to Vitest for better performance. All test files use `.test.ts` extension with Vitest.
When information conflicts across sections:
# Search for the conflicting term/phrase
grep -r "conflicting_term" AGENTS.md
Example - Fixing inconsistency:
# Section 1 (incorrect)
- Tests go in `tests/` directory
# Section 2 (correct)
- Tests go in `__tests__/` directory
# After correction (both sections)
- Tests go in `__tests__/` directory *(Note: Corrected from `tests/` - tests are co-located with source files)*
Don't just delete wrong information - provide context:
Bad correction:
# Before
- Use Python 3.9
# After
- Use Python 3.11
Good correction:
# Before
- Use Python 3.9
# After
- Use Python 3.11 *(Updated: Minimum version requirement changed due to new dependencies)*
Why this matters:
Step-by-step correction process:
## 📝 Update Log
### 2024-01-15
- 🔧 Corrected: Updated Python version from 3.9 to 3.11
- 🔧 Fixed: Test directory path corrected to `__tests__/`
- 🔧 Clarified: Added note about event-driven architecture requirements
Do:
Don't:
For significant corrections (e.g., architecture changes, tool migrations):
> **⚠️ Important Update (2024-01-15):** This document was recently updated. Key changes:
> - Testing framework changed from Jest to Vitest
> - Architecture pattern updated to event-driven
> - See Update Log for details
## Migration Notes
If you're updating from the old guidelines:
- Replace all `jest` commands with `vitest`
- Move test files from `tests/` to `__tests__/`
- See [Migration Guide](./MIGRATION.md) for details
## Testing
- Use Vitest for testing
- ~~Use Jest for testing~~ *(Deprecated as of 2024-01-15)*
🔍 First step: If you encounter issues with AGENTS.md, always check
@Cursordocumentation first for the latest troubleshooting guidance and known issues.
If AGENTS.md appears to be ignored:
AGENTS.md (case-sensitive)@Cursor documentation for current requirements and limitationsIssue: Changes not being recognized
Issue: Conflicting information after updates
Issue: Document becoming too long/unorganized
.cursor/rules if it exceeds ~500 linesSearch for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer