> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trae.cn/llms.txt
> Use this file to discover all available pages before exploring further.

目前 TRAE CLI 1.0 已进入弱维护状态，请及时升级到 2.0。

## 安装 TRAE CLI 2.0 {#hsFNJlI1h}

* Mac/Linux
   ```Bash
   sh -c "$(curl -fsSL https://trae.cn/trae-cli/install_v2.sh)"
   ```
* Windows
   ```PowerShell
   irm https://trae.cn/trae-cli/install_v2.ps1 | iex
   ```   


### 自动迁移配置 {#hb5OXET2E}

TRAE CLI 1.0 用户首次启动 TRAE CLI 2.0 时，如果检测到以下任一未迁移内容，会弹出迁移提示：

* 用户级主配置或兼容配置。
* 用户级资源目录中的可迁移资源（skills/agents/hooks/mcp/rules等）。
* 当前项目中的项目级资源目录。
* 可迁移的 TRAE CLI 1.0 session 历史。

提示会列出检测到的 legacy data，例如：

```Plain Text
Legacy TraeCLI data or external agent config detected
Would you like to migrate detected data to the new Trae CLI storage?
Select what to import:
Home
  [x] Migrate /Users/alex/.trae/traecli.yaml to /Users/alex/.trae/test/traecli.toml
  [x] Migrate recent sessions from /Users/alex/.cache/coco/sessions to /Users/alex/…
  [x] Migrate subagents from /Users/alex/.claude/agents to /Users/alex/.trae/agents
  [x] Migrate recent sessions from /Users/alex/.claude/projects

Project: /workspace/project
  [x] Migrate CLAUDE.md to AGENTS.md

Selected 5 of 5 item(s).
  1. Proceed with selected
  2. Skip for now
  3. Don't ask again for the selected data
  4. Don't ask again for any legacy TraeCLI data or external agent config for this user
Use ↑/↓ to move, space to toggle, 1/2/3/4 to choose, a/n for all/none
```

迁移是非破坏性的：

* 不删除原始文件。
* 用户级和项目级迁移都会写入对应的 `traecli.toml`。
* 不覆盖目标 `traecli.toml` 中已经存在的配置项。
* 超过 50M 的单个 legacy session 默认会跳过，否则会造成 TUI 启动过程卡顿。如需迁移大 legacy session，使用以下手动迁移指令：
   ```Bash
   traecli migrate --force --no-legacy-session-size-limit
   ```   


### CLI 手动触发 {#hcS83Rr20}

如果错误过了自动迁移提示，可手动触发历史数据迁移

```Bash
traecli migrate --force 
traecli migrate --force --legacy-session-max-mib 1200
traecli migrate --force --no-legacy-session-size-limit 
```

`--force` 会忽略已有迁移标记并重新执行迁移；迁移仍然是非破坏性的，不会覆盖目标 `traecli.toml` 中已经存在的配置键。

### 命令行参数兼容问题说明 {#haoJeTf7G}

<!-- @cols-width: 293,728 -->
| **TRAE CLI 1.0 参数**  | **替代方案**  |
| --- | --- |
| `-p, --print`  | 对齐 `--print`，但短参 `-p` 被 `--profile` 占用，历史 `-p` 任务参数请改为 `--print` 或换 `exec`  |
| `--output-format=json`  | 不支持，支持 JSONL，用 `--output-format=stream-json`替代，或者`traecli exec --json`  |
| `--output-format=stream-json`  | 参数对齐；但事件流结构不同，映射到现有 `traecli exec --json` 的 JSONL 事件流能力  |
| `--query-timeout`  | 不支持，请直接使用外层 `timeout` 指令限制执行时间  |
