claude-code/claude-zh/commands/claw.md

80 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
description: 啟動 NanoClaw agent REPL — 由 claude CLI 驅動的具備工作階段感知能力的持久型 AI 助手。
---
# Claw 指令
啟動互動式 AI agent 工作階段,將對話歷史記錄持久化到磁碟,並可選擇載入 ECC 技能上下文。
## 使用方式
```bash
node scripts/claw.js
```
或透過 npm
```bash
npm run claw
```
## 環境變數
| 變數 | 預設值 | 描述 |
|----------|---------|-------------|
| `CLAW_SESSION` | `default` | 工作階段名稱 (英數字 + 連字號) |
| `CLAW_SKILLS` | *(空)* | 以逗號分隔的技能名稱,作為系統上下文載入 |
## REPL 指令
在 REPL 內部,直接提示字元處輸入以下指令:
```
/clear 清除目前工作階段歷史
/history 列印完整對話歷史
/sessions 列出所有存檔的工作階段
/help 顯示可用指令
exit 退出 REPL
```
## 運作原理
1. 讀取 `CLAW_SESSION` 環境變數以選擇具名工作階段 (預設:`default`)
2.`~/.claude/claw/{session}.md` 載入對話歷史
3. (選擇性) 從 `CLAW_SKILLS` 環境變數載入 ECC 技能上下文
4. 進入阻斷式提示迴圈 — 每個使用者訊息都會連同完整歷史發送給 `claude -p`
5. 回應會追加到工作階段檔案中,以便在重新啟動後保持持久性
## 工作階段儲存
工作階段以 Markdown 檔案形式儲存在 `~/.claude/claw/`
```
~/.claude/claw/default.md
~/.claude/claw/my-project.md
```
每一輪的格式為:
```markdown
### [2025-01-15T10:30:00.000Z] 使用者
這個函式的作用是什麼?
---
### [2025-01-15T10:30:05.000Z] 助手
這個函式計算...
---
```
## 範例
```bash
# 啟動預設工作階段
node scripts/claw.js
# 具名工作階段
CLAW_SESSION=my-project node scripts/claw.js
# 帶有技能上下文
CLAW_SKILLS=tdd-workflow,security-review node scripts/claw.js
```