ClawSkills logoClawSkills

Coder Workspaces

通过 CLI 管理 Coder 工作区和 AI 编码代理任务。列出、创建、启动、停止和删除工作区。通过 SSH 进入工作区以运行命令。创建并监控

介绍

# Coder Workspaces

通过 coder CLI 管理 Coder 工作区和 AI 编码代理任务。

> 注意:命令在隔离的、受控的 Coder 工作区内执行——而非宿主系统。

## 设置

在使用 coder CLI 之前,请配置身份验证:

1. 从 [Coder CLI 文档](https://coder.com/docs/install/cli)安装 CLI。

2. 设置环境变量: ```bash export CODER_URL=https://your-coder-instance.com export CODER_SESSION_TOKEN=<your-token> # Get from /cli-auth ```

3. 测试连接: ```bash coder whoami ```

## 工作区命令

```bash coder list # List workspaces coder list --all # Include stopped coder list -o json # JSON output

coder start <workspace> coder stop <workspace> coder restart <workspace> -y coder delete <workspace> -y

coder ssh <workspace> # Interactive shell coder ssh <workspace> -- <command> # Run command in workspace

coder logs <workspace> coder logs <workspace> -f # Follow logs ```

## AI 编码任务

Coder 任务在隔离的工作区中运行 AI 代理(Claude Code、Aider 等)。

### 创建任务

```bash coder tasks create --template <template> --preset "<preset>" "prompt" ```

- **Template**:必填。使用 `coder templates list` 列出。 - **Preset**:可能必填。首先尝试不指定。如果创建失败并提示“Required parameter not provided”,请通过 `coder templates presets list <template> -o json` 获取预设列表并使用默认值。如果没有默认值,请询问用户使用哪个预设。

### 管理任务

```bash coder tasks list # List all tasks coder tasks logs <task-name> # View output coder tasks connect <task-name> # Interactive session coder tasks delete <task-name> -y # Delete task ```

### 任务状态

- **Initializing**:工作区正在配置(耗时取决于模板) - **Working**:设置脚本正在运行 - **Active**:代理正在处理提示词 - **Idle**:代理正在等待输入

## 故障排除

- **找不到 CLI**:请参阅 [Coder CLI 文档](https://coder.com/docs/install/cli) - **认证失败**:验证 CODER_URL 和 CODER_SESSION_TOKEN 已设置,然后运行 `coder login` - **版本不匹配**:从您的 Coder 实例重新安装 CLI

## 更多信息

- [Coder 文档](https://coder.com/docs) - [Coder CLI](https://coder.com/docs/install/cli) - [Coder 任务](https://coder.com/docs/ai-coder)

更多产品