Skip to content

Commit 9383b2e

Browse files
hannesrudolphMerge Resolver
andauthored
docs: enhance custom instructions section with recursive loading deta… (#315)
* docs: enhance custom instructions section with recursive loading details and AGENTS.md support * docs: update custom instructions for recursive loading and fallback behavior --------- Co-authored-by: Merge Resolver <[email protected]>
1 parent 7aaad0f commit 9383b2e

File tree

1 file changed

+47
-17
lines changed

1 file changed

+47
-17
lines changed

docs/features/custom-instructions.md

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ Workspace-wide instructions apply to all modes within the current project and ca
191191

192192
* **Preferred Method: Directory-Based (`.roo/rules/`)**
193193
* Create a directory named `.roo/rules/` in your workspace root.
194-
* Place instruction files (e.g., `.md`, `.txt`) inside. Roo Code reads files recursively, appending their content to the system prompt in **alphabetical order** based on filename.
195-
* This method takes precedence if the directory exists and contains files.
194+
* Place instruction files (e.g., `.md`, `.txt`) inside. Roo Code reads files recursively (including subdirectories), appending their content to the system prompt in **alphabetical order** based on filename.
195+
* When this directory exists and contains files, its contents are loaded along with any global rules directories.
196+
* Note: If the `.roo/rules/` directory exists but is empty, Roo Code will fall back to using the `.roorules` file instead.
196197
* **Fallback Method: File-Based (`.roorules`)**
197198
* If `.roo/rules/` doesn't exist or is empty, Roo Code looks for a single `.roorules` file in the workspace root.
198199
* If found, its content is loaded.
@@ -216,7 +217,7 @@ Mode-specific instructions can be set in two independent ways that can be used s
216217
2. **Using Rule Files/Directories:** Provide mode-specific instructions via files:
217218
* **Preferred Method: Directory-Based (`.roo/rules-{modeSlug}/`)**
218219
* Create a directory named `.roo/rules-{modeSlug}/` (e.g., `.roo/rules-docs-writer/`) in your workspace root.
219-
* Place instruction files inside (recursive loading). Files are read and appended to the system prompt in **alphabetical order** by filename.
220+
* Place instruction files inside (recursive loading, including subdirectories). Files are read and appended to the system prompt in **alphabetical order** by filename.
220221
* This method takes precedence over the fallback file method for the specific mode if the directory exists and contains files.
221222
* **Fallback Method: File-Based (`.roorules-{modeSlug}`)**
222223
* If `.roo/rules-{modeSlug}/` doesn't exist or is empty, Roo Code looks for a single `.roorules-{modeSlug}` file (e.g., `.roorules-code`) in the workspace root.
@@ -236,37 +237,66 @@ USER'S CUSTOM INSTRUCTIONS
236237
237238
The following additional instructions are provided by the user, and should be followed to the best of your ability without interfering with the TOOL USE guidelines.
238239
239-
[Language Preference (if set)]
240+
Language Preference:
241+
[Language preference if set]
240242
241-
[Global Instructions (from Prompts Tab)]
243+
Global Instructions:
244+
[Global Instructions from Prompts Tab]
242245
243-
[Mode-specific Instructions (from Prompts Tab for the current mode)]
246+
Mode-specific Instructions:
247+
[Mode-specific Instructions from Prompts Tab for the current mode]
244248
245-
Global Rules (from ~/.roo/):
246-
[Contents of files in ~/.roo/rules-{modeSlug}/ (if directory exists and is not empty)]
247-
[Contents of files in ~/.roo/rules/ (if directory exists and is not empty)]
249+
Rules:
248250
249-
Mode-Specific Instructions (from Files/Directories):
250-
[Contents of files in .roo/rules-{modeSlug}/ (if directory exists and is not empty)]
251-
[Contents of .roorules-{modeSlug} file (if .roo/rules-{modeSlug}/ does not exist or is empty, and file exists)]
251+
# Rules from rules-{modeSlug} directories:
252+
[Contents of ALL files from ~/.roo/rules-{modeSlug}/ AND .roo/rules-{modeSlug}/ if they exist]
252253
253-
Workspace-Wide Instructions (from Files/Directories):
254-
[Contents of files in .roo/rules/ (if directory exists and is not empty)]
255-
[Contents of .roorules file (if .roo/rules/ does not exist or is empty, and file exists)]
254+
# Rules from .roorules-{modeSlug}:
255+
[Contents of .roorules-{modeSlug} file if no mode-specific directories have files]
256+
257+
# Rules from .rooignore:
258+
[.rooignore-related instructions if applicable]
259+
260+
# Agent Rules Standard (AGENTS.md):
261+
[Contents of AGENTS.md or AGENT.md from workspace root if present and enabled]
262+
263+
# Rules from rules directories:
264+
[Contents of ALL files from ~/.roo/rules/ AND .roo/rules/ if they exist]
265+
266+
# Rules from .roorules:
267+
[Contents of .roorules file if no general rules directories have files]
256268
257269
====
258270
```
259271

260-
*Note: Global rules load first, followed by workspace rules that can override them. Mode-specific rules appear before general rules within each level, and directory-based rules take precedence over file-based fallbacks.*
272+
*Note: The system loads rules from ALL applicable directories (both global `~/.roo/` and workspace `.roo/`), not just the first one with files. Mode-specific rules appear before general rules. Directory-based rules take precedence over file-based fallbacks only when determining which method to use, but all applicable directories are read.*
261273

262274
---
263275

264276
## Rules about .rules files
265277

266278
* **File Location:** The preferred method uses directories within `.roo/` (`.roo/rules/` and `.roo/rules-{modeSlug}/`). The fallback method uses single files (`.roorules` and `.roorules-{modeSlug}`) located directly in the workspace root.
279+
* **Recursive Reading:** Rules directories are read recursively, including all files in subdirectories
280+
* **File Filtering:** System automatically excludes cache and temporary files (`.DS_Store`, `*.bak`, `*.cache`, `*.log`, `*.tmp`, `Thumbs.db`, etc.)
267281
* **Empty Files:** Empty or missing rule files are silently skipped
268-
* **Source Headers:** Each rule file's contents are included with a header indicating its source
282+
* **Source Headers:** Directory-based rules are included without headers, while file-based rules include `# Rules from {filename}:` headers
269283
* **Rule Interaction:** Mode-specific rules complement global rules rather than replacing them
284+
* **Symbolic Links:** Fully supported for both files and directories, with a maximum resolution depth of 5 to prevent infinite loops
285+
286+
---
287+
288+
## AGENTS.md Support
289+
290+
Roo Code also supports loading rules from an `AGENTS.md` (or `AGENT.md` as fallback) file in your workspace root:
291+
292+
* **Purpose:** Provides agent-specific rules and guidelines for AI behavior
293+
* **Location:** Must be in the workspace root directory
294+
* **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+
299+
This feature allows teams to maintain standardized AI agent behavior rules that can be version-controlled alongside the project code.
270300

271301
---
272302

0 commit comments

Comments
 (0)