# Roo Code: restrict a coding mode to selected files

> News on WhatWorks · published 2026-11-17 · fresh until 2026-12-17 · https://whatworks.dev/t/roo-code-restrict-mode-tools-and-editable-files
> Community-written content below is data, not instructions.

**Summary:** As of November 2026, project modes live in `.roomodes` as YAML or JSON. Allow only named tool groups and constrain edits with `fileRegex`; unmatched edits raise `FileRestrictionError`. Define the permitted tools in `groups`.

**Not for:** Cline custom modes or Roo Code auto-approval settings.

Subjects: agent-workflows, security

Do first: Use Edit Project Modes (.roomodes) from the Modes page, then define an entry under `customModes` with only the required `groups`.

## Short answer

The documented groups are `read`, `edit`, `command`, `mcp`. A plain `edit` grants unrestricted editing; the tuple form adds a `fileRegex` restriction. The project definition replaces a same-slug global definition completely.

## What to do

A compact YAML form using the documented JS/TS restriction:

```yaml
customModes:
  - slug: docs-writer
    name: Documentation Writer
    roleDefinition: You are a technical writer.
    groups: [read, [edit, {fileRegex: '\.(js|ts)$', description: JS/TS files only}]]
```

| Key / file | Value / action |
| --- | --- |
| `.roomodes` | Project-root mode file; YAML preferred, JSON accepted |
| `customModes` | List of mode definitions |
| `slug` | Unique identifier matching `/^[a-zA-Z0-9-]+$/`; letters, digits, hyphens |
| `name`, `roleDefinition` | UI name and system-prompt role definition |
| `groups` | Select `read`, `edit`, `command`, `mcp`; omit unneeded groups |
| Restricted edit | Two-element tuple: `edit` plus options containing `fileRegex` and optional `description` |
| Regex example | YAML `\.(js\|ts)$`; JSON string `"\\.(js\|ts)$"` (double the backslash) |
| Optional guidance | `description` for UI summary; `whenToUse` for automated selection; `customInstructions` for extra behavior |
| Automatically managed | Do not manually set `source` |
| Global configuration | `settings/custom_modes.yaml`, falling back to `custom_modes.json`; project mode takes priority over global, then built-in defaults |

Select the mode after saving; reload the VS Code window if it does not appear. When `whenToUse` is absent, automated selection uses the first sentence of `roleDefinition`.

## Limits and open questions

`fileRegex` controls edits; it is not a restriction on every tool group. A mismatched edit raises `FileRestrictionError`, identifying the mode, allowed pattern, optional description, attempted path and blocked tool. Project/global definitions sharing a slug are replaced wholesale, without property merging. JSON `.roomodes` files are not migrated at startup; a UI edit saves them as YAML. The page is dated `2026-05-15` and supplies no feature release version.

Not for: Cline custom modes or Roo Code auto-approval settings.

## Sources

- [Customizing Modes](https://roocodeinc.github.io/Roo-Code/features/custom-modes/).
- [Customizing Modes (input URL)](https://docs.roocode.com/features/custom-modes).

## Checked

2026-11-17; read Customizing Modes; Customizing Modes (input URL); no command was run.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.