Trae怎么开发Agent

Trae怎么开发Agent

TRAE 中开发 Agent(智能体)有以下几种方式,取决于你的使用场景:


一、自定义智能体(IDE / Work 中使用)

通过 @ 调用的专用助手,适合面向特定开发场景。

创建方式

  1. 在对话输入框输入 @ → 点击底部 创建智能体
  2. 选择 智能生成(推荐)或 手动创建

可配置项

参数 说明
名称 智能体显示名
提示词 人设、工作流、规范、输出格式等
工具 阅读、文件系统、终端、联网搜索、预览 + 已配置的 MCP Server
可被其他智能体调用 开启后可被 SOLO Agent 自动调度(需设置英文标识名和触发条件)

使用方式

输入 @ 或点击 @智能体 → 选择目标智能体即可调用。支持分享和导入。


二、子智能体 Subagent(SOLO Agent 自动调度)

通过 Markdown 文件定义,SOLO Agent 在匹配到合适任务时自动调用,拥有独立上下文窗口。

存放路径

类型 路径
项目级 {project}/.trae/agents/{my-agent}.md
用户级 Windows: %userprofile%/.trae-cn/agents/{my-agent}.md

文件格式

---
name: code-reviewer
description: Reviews code for quality, security, and best practices when user asks for code review
model: DeepSeek-V4-Pro
tools: Read, Glob, Grep, Write
disallowedTools: Bash
mcpServers:
    - GitHub
---
You are a senior code reviewer with expertise in TypeScript and React.

When invoked, follow this workflow:
1. Identify the files to review
2. Read each file carefully
3. Analyze for: logic errors, security vulnerabilities, performance issues
4. Output a table: File | Line | Severity | Issue | Suggestion

关键字段

字段 必填 说明
name 是 唯一标识,字母开头,支持字母/数字/连字符,<=50 字符
description 是 最关键 — 决定 SOLO Agent 何时自动调用,描述越具体调度越准
model 否 指定模型(如 Doubao-Seed-2.1-Pro、DeepSeek-V4-Pro 等)
tools 否 允许的工具(Read, Write, Bash, Grep, Glob, WebSearch 等)
disallowedTools 否 禁用的工具
mcpServers 否 允许调用的 MCP Server 名称

可用工具

Read | Write | Edit | Bash | Glob | Grep | WebSearch | WebFetch | Skill | TodoWrite | LSP | mcp__<server>__<tool>


三、TRAE CLI Agent

在命令行中通过 /agent-new 创建,配置文件保存在 .traecli/agents 目录。

---
name: tui-implementer
description: |
    Use this agent when creating TUI screens, debugging terminal rendering...
tools: Read,Write,Bash
model: Doubao-Seed-2.1-Pro
---
You are an expert TUI architect...

调用方式:对话中输入 @tui-implementer 或由 CLI 自动调度。


四、官方预制智能体(一键导入)

TRAE 提供了一系列可直接导入的专业智能体:

智能体 专长
UI Designer UI/UX 设计、组件库、设计系统
Frontend Architect 前端架构、性能优化、状态管理
Backend Architect API 设计、数据库、系统架构
API Test Pro API 测试、性能测试、安全测试
AI Integration Eng LLM 集成、推荐系统、模型部署
DevOps Architect CI/CD、云基础设施、监控
Performance Expert 性能分析、压力测试、优化方案
Compliance Checker 法律合规、隐私政策、风险识别

点击链接即可直接导入使用,也可以作为模板二次修改。


Skill vs Agent 的区别

Skill(技能) Agent(智能体)
定位 流程规范 / 操作手册 专职助手 / 执行者
触发 AI 按需加载 @ 手动调用 / 自动调度
上下文 注入主对话 Subagent 有独立上下文
工具权限 无独立权限 可配置专属工具和 MCP
典型用途 "怎么做"的规范 "谁来做什么"的专业分工

更多详情:创建并管理智能体、子智能体