NAME
.trae/rules/*.md — instruction file for Trae
SYNOPSIS
.trae/rules/
METADATA
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
ANNOTATED EXAMPLE
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
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.
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.
The `.trae/` directory contains other Trae configuration. Only Markdown files inside `rules/` are treated as AI instruction rules.
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.