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

# AI 智能体

> 使用 lager agent 为 AI 编程智能体提供 lager CLI 的使用指南

AI 编程智能体（例如 Claude Code、Codex 或 Cursor）可以像人一样使用 `lager` CLI。`lager agent` 为智能体提供一份指南。指南告诉智能体如何查找 Box 和 Net，以及如何运行测试。它还告诉智能体哪些命令是安全的，以及何时需要先询问人。

该指南是 CLI 的一部分，因此它始终与已安装的版本一致。更新 CLI 之后，请再次运行 `lager agent install`。

## 语法

```bash theme={null}
lager agent install [--target TARGET] [--scope SCOPE] [--force]
lager agent uninstall [--target TARGET] [--scope SCOPE] [--force]
lager agent status
lager agent guide [--topic TOPIC]
```

## 命令

| 命令 | 说明 |
| - | - |
| `install` | 为智能体安装或更新指南 |
| `uninstall` | 删除 `install` 写入的指南 |
| `status` | 显示指南安装在哪里，以及它是否为最新 |
| `guide` | 打印指南，供任何智能体阅读 |

## 选项

| 选项 | 说明 |
| - | - |
| `--target claude` | 位于 `.claude/skills/lager/` 的技能。这是默认值 |
| `--target codex` | `AGENTS.md` 中的一段内容。其他读取 `AGENTS.md` 的智能体也会使用它 |
| `--target cursor` | 位于 `.cursor/rules/lager.mdc` 的规则 |
| `--target all` | 该范围支持的全部目标 |
| `--scope project` | 仓库根目录（包含 `.git` 的文件夹），或当前文件夹。这是默认值 |
| `--scope user` | 您的主目录：`~/.claude/skills/lager/` 或 `~/.codex/AGENTS.md`。Cursor 没有用户范围 |
| `--force` | 替换您修改过的文件，或不是由 lager 写入的文件 |
| `--json` | 把结果作为一个 JSON 对象输出 |
| `--topic TOPIC` | 用于 `guide`：`skill`、`commands`、`python-api`、`troubleshooting` 或 `agents` |
| `--list` | 用于 `guide`：列出全部主题 |

## 用法

```bash theme={null}
# Give Claude Code the guide for this repository
lager agent install

# Give every agent the guide for this repository
lager agent install --target all

# Give Claude Code the guide in every project
lager agent install --scope user

# Print the list of commands and the safety class of each
lager agent guide --topic commands
```

## 智能体学到什么

指南告诉智能体：

* 在每条命令中指定 Box，使用 `--box` 或 `LAGER_BOX`。
* 使用 JSON 输出，并读取错误信封和退出码。
* 为每个数据流设置时间限制，例如 `lager uart NET --duration 10`。
* 在规划测试之前，读取 DUT 上下文和每个 Net 的元数据。
* 把测试写成 `lager python` 脚本，并在结束时关闭电源。

每条命令都有一个安全类别：

| 类别 | 含义 | 智能体的做法 |
| - | - | - |
| `read` | 命令不改变任何东西 | 直接运行 |
| `actuate` | 命令会改变仪器或 DUT 的状态 | 先询问人 |
| `admin` | 命令会改变 Box、Net 或配置 | 先询问人 |
| `interactive` | 命令需要有人在终端前操作 | 不运行 |

指南是供智能体阅读的文字，它不会阻止任何命令。

## 您的修改是安全的

`install` 和 `uninstall` 只改变 lager 写入的文件。如果您修改了某个文件，lager 会保留您的版本，并以退出码 1 退出。使用 `--force` 可替换它。在 `AGENTS.md` 中，lager 只改变其 `BEGIN lager-cli agent guide` 与 `END lager-cli agent guide` 标记之间的文字。

您可以把项目范围的安装提交到仓库。运行 `lager agent install` 的队友会得到相同的更新规则。


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