TRAERULESMD(5)TRAERULESMD(5)

NAME

.trae/rules/*.md — instruction file for Trae

SYNOPSIS

.trae/rules/

METADATA

FORMATMarkdown
FILENAME.trae/rules/*.md
CASE SENSITIVENo
TOOLTrae
ENCODINGUTF-8
GIT COMMITTEDYes
MAX SIZE5KB per rule file
SINCETrae IDE (2025)

DESCRIPTION

`.trae/rules/*.md` are Markdown rule files for Trae, ByteDance's AI-powered IDE. Each rule file uses YAML frontmatter to define its activation behavior, supporting four distinct modes: Always (alwaysApply: true), Auto (glob-pattern matching), Manual (explicit user reference), and Agent-requested (AI pulls in rules based on description relevance).

Rules live in the `.trae/rules/` directory within the project. Each file needs frontmatter with at minimum a `description` field and an `alwaysApply` boolean. The optional `globs` array enables auto-activation when files matching the patterns are in the current context.

The system is similar to Cursor's .cursor/rules/ and Roo Code's .roo/rules/ — all use frontmatter-controlled Markdown files with glob-based scoping. Trae's distinguishing feature is the agent-requested mode where the AI autonomously decides to load relevant rules.

STRUCTURE

├──YAML FrontmatterREQUIRED
Required frontmatter block with `description` (string), `alwaysApply` (boolean), and optional `globs` (string array). These fields control the rule's activation mode.
└──Rule BodyREQUIRED
Markdown content with the actual coding instructions, conventions, or constraints. Supports standard Markdown formatting.

ANNOTATED EXAMPLE

.trae/rules/*.md
markdown
1---
2description: "TypeScript coding standards for the project"
3alwaysApply: true
4---
5
6# TypeScript Standards
7
8- Use strict mode with no `any` types
9- Prefer `interface` over `type` for object shapes
10- Named exports only — no default exports
11- Use `import type` for type-only imports
12
13---
14
15## Example: Auto-activated rule (.trae/rules/testing.md)
16
17```markdown
18---
19description: "Testing conventions for Vitest test files"
20alwaysApply: false
21globs:
22  - "**/*.test.ts"
23  - "**/*.spec.ts"
24---
25
26# Testing Rules
27- Use describe/it blocks, not test()
28- One assertion per test when practical
29- Use vi.mock() for module mocking
30```
31
32---
33
34## Example: Manual rule (.trae/rules/migration.md)
35
36```markdown
37---
38description: "Database migration guidelines"
39alwaysApply: false
40---
41
42# Migration Rules
43- Always create reversible migrations
44- Test both up and down migrations
45- Never modify existing migration files
46```

COMMON MISTAKES

Gotchas
✗WRONG Setting both `alwaysApply: true` and `globs` patterns
✓RIGHT Use one activation mode: `alwaysApply: true` (always), `globs` (auto), both false/empty (manual), or agent-requested

Trae has four activation modes: (1) Always — `alwaysApply: true`, loaded every request. (2) Auto — `alwaysApply: false` with `globs` patterns, loaded when matching files are in context. (3) Manual — `alwaysApply: false` with no globs, only when user explicitly references the rule. (4) Agent-requested — Trae's AI can pull in relevant rules based on the description field.

✗WRONG Omitting the `description` field in frontmatter
✓RIGHT Always include a clear `description` — it helps agent-requested activation

The description field serves double duty: it appears in the rules UI for humans, and Trae's AI uses it to determine whether to pull in the rule during agent-requested mode. A missing or vague description reduces discoverability.

✗WRONG Placing rules directly in `.trae/` instead of `.trae/rules/`
✓RIGHT Rule files must be in the `.trae/rules/` subdirectory

The `.trae/` directory contains other Trae configuration. Only Markdown files inside `rules/` are treated as AI instruction rules.

✗WRONG Expecting rules to work in Trae's inline autocomplete
✓RIGHT Rules apply to Trae's chat/agent mode, not inline completions

Trae rules are injected into the AI context for chat and agent interactions. Inline code completions use a different, more constrained context and may not incorporate all rules.

USED BY

SIMILAR FILES

.cursor/rules/*.mdcCursor Rules (MDC Format)
.kiro/steering/*.mdKiro Steering Files
.roo/rules/*.mdRoo Code Rules

COMPARISONS

agentconfig.ing2026-03-16TRAERULESMD(5)