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 feeds it into the same Rules engine that powers .windsurf/rules/ — just with the activation mode inferred from the file’s location instead of frontmatter:
- Root directory: Treated as an always-on rule — the full content is included in Cascade’s system prompt on every message.
- Subdirectories: Treated as a glob rule with an auto-generated pattern of
<directory>/**— the content is applied only when Cascade reads or edits files inside that directory.
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.