AGENTS.md files provide a simple way to give Cascade context-aware instructions that automatically apply based on where the file is located in your project. This is particularly useful for providing directory-specific coding guidelines, architectural decisions, or project conventions.
How It Works
When you create anAGENTS.md file (or agents.md), Windsurf automatically discovers it and uses its contents as instructions for Cascade. The behavior depends on where the file is placed:
- Root directory: When placed at the root of your workspace or git repository, the instructions apply globally to all files (similar to an “always on” rule)
- Subdirectories: When placed in a subdirectory, the instructions automatically apply only when working with files in that directory or its children
AGENTS.md ideal for providing targeted guidance without cluttering a single global configuration file.
Creating an AGENTS.md File
Simply create a file namedAGENTS.md or agents.md in the desired directory. The file uses plain markdown with no special frontmatter required.
Example Structure
Example Content
Here’s an exampleAGENTS.md file for a React components directory:
Discovery and Scoping
Windsurf automatically discoversAGENTS.md files throughout your workspace:
- Workspace scanning: All
AGENTS.mdfiles within your workspace and its subdirectories are discovered - Git repository support: For git repositories, Windsurf also searches parent directories up to the git root
- Case insensitive: Both
AGENTS.mdandagents.mdare recognized
Automatic Scoping
The key benefit ofAGENTS.md is automatic scoping based on file location:
| File Location | Scope |
|---|---|
| Workspace root | Applies to all files (always on) |
/frontend/ | Applies when working with files in /frontend/** |
/frontend/components/ | Applies when working with files in /frontend/components/** |
AGENTS.md files at different levels, each providing increasingly specific guidance for their respective directories.
Best Practices
To get the most out ofAGENTS.md files:
- Keep instructions focused: Each
AGENTS.mdshould contain instructions relevant to its directory’s purpose - Use clear formatting: Bullet points, headers, and code blocks make instructions easier for Cascade to follow
- Be specific: Concrete examples and explicit conventions work better than vague guidelines
- Avoid redundancy: Don’t repeat global instructions in subdirectory files; they inherit from parent directories
Content Guidelines
Comparison with Rules
While bothAGENTS.md and Rules provide instructions to Cascade, they serve different purposes:
| Feature | AGENTS.md | Rules |
|---|---|---|
| Location | In project directories | .windsurf/rules/ or global |
| Scoping | Automatic based on file location | Manual (glob, always on, model decision, manual) |
| Format | Plain markdown | Markdown with frontmatter |
| Best for | Directory-specific conventions | Cross-cutting concerns, complex activation logic |
AGENTS.md when you want simple, location-based instructions. Use Rules when you need more control over when and how instructions are applied.