trae-rules-writer-workspace/skill-snapshot/trae-rules-writer-v1_6/~/SKILL.md
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 project-skill-writer) or agents (use project-agent-writer).
npx skillsauth add learnwy/skills trae-rules-writerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Analyze project conventions AND business context, then create rules that guide AI behavior.
Before creating ANY rule, you MUST understand the project first.
If project is too large (>50 top-level items, monorepo):
AskUserQuestion for target foldersQuick scan to understand what exists (NOT deep reading):
1. List top-level directories
2. Identify tech stack and frameworks
3. Find existing .trae/rules/, linting configs
4. List areas that need AI guidance
Note: Deep code reading happens in Phase 2 for each specific rule.
Rules should reflect business requirements:
| Source | What to Extract | |--------|-----------------| | User input | Team standards, preferences | | README/docs | Coding guidelines | | Code comments | Constraints, requirements |
Ask: "What coding standards does your team follow?"
Create rules ONE at a time.
First, identify all rules needed:
Example: react-project
├── code-style.md (naming conventions)
├── react-patterns.md (component patterns)
├── import-order.md (import style)
└── testing.md (test patterns)
┌─────────────────────────────────────────────┐
│ For each rule: │
│ │
│ 0. Initialize from template via script │
│ - Run scripts/init_rule.py │
│ - Ensure frontmatter markers exist │
│ │
│ 1. Deep-dive into THIS rule's scope │
│ - What files does it apply to? │
│ - What conventions exist? │
│ │
│ 2. Choose application mode │
│ - alwaysApply: true │
│ - globs: *.ts,*.tsx │
│ - description: "When..." │
│ │
│ 3. Write rule with business context │
│ - Include domain terminology │
│ - Explain "why" for each guideline │
│ │
│ 4. Move to next rule │
└─────────────────────────────────────────────┘
Initialization command:
python {skill_dir}/scripts/init_rule.py \
--skill-dir {skill_dir} \
--name {rule_name} \
--mode intelligent \
--description "When to apply this rule" \
--output-dir {project_root}/.trae/rules
description: Brief explanation of what this rule does
globs: *.ts,*.tsx
alwaysApply: false
# Rule Title
Concise guidance for AI.
Character Limit: Keep rules under 1000 characters when possible. Long rules reduce AI attention.
| Mode | Frontmatter | Use Case |
|------|-------------|----------|
| Always | alwaysApply: true | All AI chats |
| File-Specific | globs: *.tsx | Matching files |
| Intelligent | description: "..." | AI determines |
| Manual | (none) | #RuleName only |
These mistakes break rules. Always check:
| Wrong ❌ | Correct ✅ | Why |
|----------|------------|-----|
| globs: "*.ts,*.tsx" | globs: *.ts,*.tsx | No quotes in globs |
| globs: ["*.ts"] | globs: *.ts,*.tsx | No YAML arrays |
| /Users/john/project/src/ | src/ | NO absolute paths! |
| /home/dev/lib/file.ts | lib/file.ts | Paths from project root, no / prefix |
| Mixed 中英文 | Single language | Confuses AI |
| Missing description | Always include | Even for alwaysApply |
Path Rule: Always use paths relative to project root. Just src/file.ts, never /absolute/path/.
Trae does NOT recognize:
"*.ts,*.tsx" ❌["*.ts", "*.tsx"] ❌Only this format works: globs: *.ts,*.tsx ✅
Before creating each rule:
Even for alwaysApply: true:
# Good
description: Code style for TypeScript
alwaysApply: true
# Bad
alwaysApply: true
| Good ✅ | Bad ❌ |
|---------|--------|
| code-style.md | rules.md |
| react-patterns.md | all.md |
## Domain Rules
- **Card Pack**: Always show minimum 3 cards
- **Scene**: Determines allowed styles
## Code Conventions
- Use CardPack component
- Apply SceneStyle based on context
User: "Create rules for TypeScript React project"
Phase 1: Read src/components/, src/hooks/
Found: PascalCase components, camelCase hooks
Phase 2: Create rules
📄 .trae/rules/code-style.md
description: Naming conventions for TypeScript React
alwaysApply: true
# Code Style
- PascalCase for components
- camelCase for functions/hooks
📄 .trae/rules/react-patterns.md
description: React component patterns
globs: *.tsx,*.jsx
# React Patterns
- Functional components with hooks
- Custom hooks in src/hooks/
Phase 3: Verify no conflicts, test activation
| Stage | Agent | When | |-------|-------|------| | Phase 1 | Project Scanner | Large projects | | Phase 1 | Convention Detector | Extract patterns | | Phase 3 | Quality Validator | Check conflicts |
tools
Fallback skill when no project-specific one matches. Provides 10 battle-tested software-engineering methodology agents: problem-definer (Weinberg), story-mapper (Patton), spec-by-example (Adzic), domain-modeler (DDD/Evans), responsibility-modeler (CRC/Wirfs-Brock), architecture-advisor (Bass), tdd-coach (Beck), refactoring-guide (Fowler), legacy-surgeon (Feathers), test-strategist (Crispin). Use when user asks about DDD, TDD, refactoring, story mapping, test strategy, or software-architecture quality attributes.
development
Use when the user wants to build, implement, or develop a feature. Orchestrates evidence-driven Spec-Driven Development. Default lifecycle is `lite` (INIT → IMPLEMENTING → TESTING → DONE); auto-promote to `standard` or `full` when scope, risk, or AC traceability demands it. Triggers: 'develop feature', 'implement this', 'build feature', 'add module', 'fix bug', '开发功能', '实现这个'.
documentation
当用户需要创建、更新或设计项目级技能(.agents/skills/*/SKILL.md)时使用此技能。Analyzes the user's problem and project context to design reusable skill solutions. 触发词:'创建技能'、'编写技能'、'构建技能'、'添加技能'、'更新技能'、'项目技能'、'新建技能'、'设计技能', or when the user describes a repetitive workflow that should be captured as a reusable AI skill.
tools
Use this skill when the user wants to install, add, or configure a skill in a project. Analyze the project's tech stack and workflow, then recommend and install the best-matching skill. Triggers: 'install skill', 'add skill', 'configure skill', 'set up skill', 'enable skill', 'use skill in project', 'project skill', or when the user asks how to bring an existing skill capability into the current workspace.