Loading...
Loading...
Create Trae IDE rules (.trae/rules/*.md) for AI behavior constraints. Use when user wants to: create a project rule, set up code style guidelines, enforce naming conventions, make AI always do X, customize AI behavior for specific files, configure AI coding standards, or establish project-specific AI guidelines. Triggers on: 'create rule', '创建 rule', 'project rule', '.trae/rules/', 'AGENTS.md', 'CLAUDE.md', 'set up coding rules', 'make AI always use PascalCase', 'enforce naming convention', 'configure AI behavior'. Do NOT use for skills (use trae-skill-writer) or agents (use trae-agent-writer).
npx skill4agent add learnwy/skills trae-rules-writer0. SIZE CHECK → Is project too large? If yes, ask user to specify folders
1. ANALYZE → Scan project structure (spawn Project Scanner Agent for deep analysis)
2. IDENTIFY → Extract conventions (spawn Convention Detector Agent)
3. DESIGN → Choose rule type and application mode based on needs
4. CREATE → Write rules in Trae's official format
5. VALIDATE → Ensure no conflicts (spawn Quality Validator Agent)
6. VERIFY → Check syntax and test rule activation
7. REFRESH → Start new chat for rules to take effect| Stage | Agent | When to Use |
|---|---|---|
| ANALYZE | Project Scanner | Large/unfamiliar projects |
| IDENTIFY | Convention Detector | Extract naming/style conventions |
| VALIDATE | Quality Validator | Comprehensive rule validation |
Spawn agent with Task tool:
- Agent: agents/convention-detector.md
- Input: {project_path: "/path/to/project", file_types: ["*.ts", "*.tsx"], output_path: "/tmp/conventions"}
- Wait for structured JSON output with suggested_rules
- Use suggested rules as starting pointAskUserQuestionsrc/components/lib/utils/This project appears to be large (I see 20+ top-level directories).
To create focused, useful rules, please specify which folders I should analyze:
- Which directories contain your main application code?
- Any specific areas where you want AI guidance?
Example: "Focus on src/features/ and src/shared/"50 files/folders at root level
AskUserQuestionQuestion: "What application mode should this rule use?"
Options:
- "Always Apply" - Active for all AI chats in project
- "File-Specific" - Only for certain file types (e.g., *.ts)
- "Apply Intelligently" - AI determines when relevant
- "Manual Only" - Only when explicitly invoked with #RuleName| Bad ❌ | Good ✅ |
|---|---|
| |
| |
| |
{project_root}{git_root}./../src/.trae/rules/<rule-name>.md---
description: Use cases for intelligent mode
globs: *.ts,*.tsx
alwaysApply: false
---
# Rule Title
Concise guidance for AI.alwaysApplytrueglobs*.ts,*.tsxdescriptionalwaysApplyfalseglobsglobs: *.ts,*.tsxglobs: "*.ts,*.tsx"| Mode | Frontmatter | Use Case |
|---|---|---|
| Always Apply | | Effective for all AI chats in project |
| File-Specific | | Only when matching files specified |
| Apply Intelligently | | AI determines relevance in chat |
| Manual Only | (no frontmatter) | Invoke with |
| Type | Location | Scope |
|---|---|---|
| User Rules | Settings > Rules & Skills > User Rules | Customized for AI based on personal habits, all projects |
| Project Rules | | Must be followed for current project only |
| File | Description |
|---|---|
| Reusable across IDEs |
| Compatible with Claude Code |
| Local-only, gitignored |
User: "Create rules for this TypeScript React project"
Analysis:
- Structure: src/components/, src/hooks/
- Naming: PascalCase components, camelCase functions
- No existing .trae/rules/
Creating: .trae/rules/
📄 code-style.md
---
alwaysApply: true
---
# Code Style
- PascalCase for components and types
- camelCase for functions and variables
📄 react-patterns.md
---
globs: *.tsx,*.jsx
---
# React Patterns
- Use functional components with hooks
- Custom hooks go in src/hooks/
📄 file-organization.md
---
description: "When organizing project files or creating new components"
---
# File Organization
- Components in src/components/
- Hooks in src/hooks/
- Use relative imports: import Hook from '../hooks/Hook'globs: *.ts,*.tsxls .trae/rules/*.md| Rule Type | When to Use | Example Frontmatter |
|---|---|---|
| Global convention | For all files in project | |
| Language-specific | Only for certain file types | |
| Context-dependent | Only in specific situations | |
| On-demand | Only when explicitly invoked | (no frontmatter) |
globs: *.ts,*.tsx#RuleName