Skip to content

Commit b97f290

Browse files
docs: correct Custom Instructions format and precedence (#400)
1 parent d402517 commit b97f290

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

docs/features/custom-instructions.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ You can provide custom instructions using global rules (applied across all proje
2020
* **Linux/macOS:** `~/.roo/rules/` and `~/.roo/rules-{modeSlug}/`
2121
* **Windows:** `%USERPROFILE%\.roo\rules\` and `%USERPROFILE%\.roo\rules-{modeSlug}\`
2222

23-
**Workspace Rules:** Apply only to the current project, can override global rules.
23+
**Workspace Rules:** Apply only to the current project and take precedence over global rules when they conflict.
2424
* **Preferred Method: Directory (`.roo/rules/`)**
2525
```
2626
.
@@ -54,7 +54,7 @@ You can provide custom instructions using global rules (applied across all proje
5454
└── ... (other project files)
5555
```
5656
57-
Rules are loaded in order: Global rules first, then workspace rules (which can override global rules). See [Global Rules Directory](#global-rules-directory) for details.
57+
Rules are loaded in order: Global rules first, then workspace rules. If there's a conflict, workspace rules take precedence. See [Global Rules Directory](#global-rules-directory) for details.
5858
:::
5959
6060
---
@@ -92,7 +92,7 @@ The Global Rules Directory feature provides reusable rules and custom instructio
9292
9393
**With Global Rules**: Create rules once and use them everywhere:
9494
- Set up your preferred coding standards globally
95-
- Override specific rules per project when needed
95+
- Customize specific rules per project when needed
9696
- Maintain consistency across all your work
9797
- Easy to update rules for all projects at once
9898
@@ -176,8 +176,8 @@ The global rules directory location is fixed and cannot be customized:
176176
Rules are loaded in this order:
177177

178178
1. **Global Rules** (from `~/.roo/`)
179-
2. **Project Rules** (from `project/.roo/`) - can override global rules
180-
3. **Legacy Files** (`.roorules`, `.clinerules` - for backward compatibility)
179+
2. **Project Rules** (from `project/.roo/`) - take precedence over global rules when they conflict
180+
3. [Generic only] **Legacy Files** (workspace root `.roorules`, `.clinerules`) - used only if no generic rules directory content was loaded
181181

182182
Within each level, mode-specific rules are loaded before general rules.
183183

@@ -279,7 +279,10 @@ Rules:
279279
* **Recursive Reading:** Rules directories are read recursively, including all files in subdirectories
280280
* **File Filtering:** System automatically excludes cache and temporary files (`.DS_Store`, `*.bak`, `*.cache`, `*.log`, `*.tmp`, `Thumbs.db`, etc.)
281281
* **Empty Files:** Empty or missing rule files are silently skipped
282-
* **Source Headers:** Directory-based rules are included without headers, while file-based rules include `# Rules from {filename}:` headers
282+
* **Source Headers:** Directory-based rules include per-file headers `# Rules from {absolute path}:`, while file-based rules include `# Rules from {filename}:` headers
283+
* **Aggregation:** Both global and workspace rules directories are aggregated for mode-specific and generic rules (not either-or)
284+
* **Sorting:** Files are sorted by basename only, case-insensitive
285+
* **Header Paths:** Header paths are absolute and follow symlinks
283286
* **Rule Interaction:** Mode-specific rules complement global rules rather than replacing them
284287
* **Symbolic Links:** Fully supported for both files and directories, with a maximum resolution depth of 5 to prevent infinite loops
285288

@@ -292,9 +295,12 @@ Roo Code also supports loading rules from an `AGENTS.md` (or `AGENT.md` as fallb
292295
* **Purpose:** Provides agent-specific rules and guidelines for AI behavior
293296
* **Location:** Must be in the workspace root directory
294297
* **Loading:** Automatically loaded by default. To disable AGENTS.md loading, set `"roo-cline.useAgentRules": false` in your VSCode settings
295-
* **Priority:** Loaded after mode-specific rules but before general workspace rules
296-
* **Header:** Added to system prompt with header `# Agent Rules Standard (AGENTS.md):`
297-
* **Symbolic Links:** Supports symbolic links to AGENTS.md files in other locations
298+
* **Setting:** `roo-cline.useAgentRules` (default: true)
299+
* **Preference:** If both exist, `AGENTS.md` is preferred over `AGENT.md`
300+
* **Priority:** Loaded after mode-specific rules and `.rooignore`, before generic rules from both `~/.roo/rules` and `.roo/rules`
301+
* **Header:** Added to system prompt with header `# Agent Rules Standard (AGENTS.md):` or `(AGENT.md):` accordingly
302+
* **Empty Files:** Empty or whitespace-only `AGENTS.md` is ignored
303+
* **Symbolic Links:** Symbolic links to files or directories are resolved before reading
298304

299305
This feature allows teams to maintain standardized AI agent behavior rules that can be version-controlled alongside the project code.
300306

@@ -317,7 +323,7 @@ For team environments, consider these approaches:
317323

318324
**Organization Standards**: Use global rules (`~/.roo/rules/`) to establish organization-wide coding standards that apply to all projects. Team members can set up identical global rules for consistency across all work.
319325

320-
**Hybrid Approach**: Combine global rules for organization standards with project-specific workspace rules for project-specific requirements. Workspace rules can override global rules when needed.
326+
**Hybrid Approach**: Combine global rules for organization standards with project-specific workspace rules for project-specific requirements. When rules conflict, workspace rules take precedence.
321327

322328
The directory-based approach offers better organization than single `.roorules` files and supports both global and project-level customization.
323329
:::

0 commit comments

Comments
 (0)