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

# 管理会话

# 概述

每次运行 Qoder CLI 都会产生一个**会话**，记录这次对话的完整历史——你的输入、Qoder 的回复和工具调用。会话可以被继续、恢复、命名、分支和清理，让你在不同任务之间灵活切换，也能在中断后接着之前的进度继续工作。

会话按项目隔离保存。每个会话有唯一的 session id，会话记录保存在用户配置目录下按项目组织的目录中（默认 `~/.qoder/projects/<项目>/<session-id>.jsonl`）。

# 新建会话

在项目根目录直接运行 `qodercli` 就会开始一个新会话，系统自动生成 session id：

```shell theme={null}
qodercli
```

在交互式会话中，用 `/new` 开始一个全新会话；`/clear` 会清空对话历史并同样开启新会话，两者效果相近。

## 命名会话

用 `-n`（`--name`）为会话设置一个便于识别的显示名：

```shell theme={null}
qodercli -n "登录重构"
```

在会话中也可以用 `/rename` 重命名当前会话。

## 指定 session id

用 `--session-id` 使用一个指定的会话 id，便于脚本或自动化流程引用固定会话：

```shell theme={null}
qodercli --session-id 00000000-0000-0000-0000-000000000000
```

# 继续与恢复

## 继续最近会话

用 `-c`（`--continue`）直接继续当前项目最近的一次会话：

```shell theme={null}
qodercli -c
```

## 恢复指定会话

用 `-r`（`--resume`）按 id 恢复某个之前的会话：

```shell theme={null}
qodercli -r <session-id>
```

不带 id 运行 `qodercli --resume` 会打开会话浏览器，让你从列表中选择要恢复的会话。在交互式会话中，`/resume` 命令也会打开会话浏览器；`/continue` 则继续最近会话。

# 分支会话

用 `--fork-session` 从一个恢复的会话创建新的分支，而不是在原会话上继续。这样可以从某个历史节点出发探索不同的方向，同时保留原会话不受影响：

```shell theme={null}
qodercli -r <session-id> --fork-session
```

在交互式会话中，也可以用 `/branch` 从当前会话创建分支。

# 导出会话

用 `/export` 把当前对话导出到文件或复制到剪贴板，便于分享、归档或在别处继续分析：

```shell theme={null}
/export
```

# 列出与删除

用 `--list-sessions` 列出当前可用的会话：

```shell theme={null}
qodercli --list-sessions
```

用 `--delete-session` 按列表序号删除某个会话：

```shell theme={null}
qodercli --delete-session <index>
```

# 会话存储位置

会话记录按项目隔离保存在用户配置目录下：

```text theme={null}
~/.qoder/projects/<项目路径经过处理后的名称>/<session-id>.jsonl
~/.qoder/projects/<项目路径经过处理后的名称>/<session-id>/state.json
```

其中 `.jsonl` 保存对话记录，`state.json` 保存会话状态。用户配置目录默认为 `~/.qoder`，可以通过 `QODER_CONFIG_DIR` 环境变量自定义。

# 命令与参数速览

| 命令 / 参数 | 作用 |
| :- | :- |
| `qodercli` | 新建会话 |
| `-c, --continue` | 继续最近会话 |
| `-r, --resume [id]` | 恢复指定会话；无 id 时打开会话浏览器 |
| `-n, --name <name>` | 设置会话显示名 |
| `--session-id <id>` | 使用指定的 session id |
| `--fork-session` | 从恢复的会话创建分支 |
| `--list-sessions` | 列出可用会话 |
| `--delete-session <index>` | 按序号删除会话 |
| `/new` | 在会话中开始新会话 |
| `/clear` | 清空对话历史并开启新会话 |
| `/rename` | 重命名当前会话 |
| `/branch` | 从当前会话创建分支 |
| `/resume`、`/continue` | 恢复 / 继续会话 |
| `/export` | 导出当前对话 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.