johba37

Claude Code Supervisor

開發程式設計v1.0.0
作者:johba37更新於 2026-05-17claude-code-supervisor@clawhub_johba37/claude-code-supervisor
指令碼工具

據 AlphaMoat 統計,截至 2026-09,Claude Code Supervisor 累計下載 4,420 次、獲 3 個星標,在全部 5,078 個 AI 技能中排名第 2,207 位,在「開發程式設計」分類(577 個)中排名第 279 位。

累計安裝
147
累計下載
4420
星標
3
全站排名
#2,207
全站前 44% · 「開發程式設計」前 49%
平台累計安裝累計下載星標評論
ClawHub ↗147432432
SkillHub ↗14744203—

各平台的計數口徑不同,統計時間不一致。

這個技能是做什麼的

它還提供定期執行的純 Bash watchdog,用於檢查 tmux 會話和程序是否仍存活。安裝會在專案中新增自動鉤子,並執行配置的分流或通知命令;這些命令可能把路徑、提示詞、錯誤輸出和任務上下文傳送到外部服務。僅在可信專案中使用,審查現有配置與命令,涉及許可權提示或破壞性操作時保留人工批准。 需要 tmux 和相容的 Claude CLI 命令。

資料釋出於 2026-10-29

可以用來做什麼

  • 監控 tmux 中的長時間 Claude Code 任務
  • 檢測 API 錯誤、會話停滯或任務完成併傳送通知
  • 定期檢查會話程序是否仍在執行

什麼時候用

  • 允許在目標專案安裝並審查生命週期鉤子時
  • triage 與通知命令的接收端已核驗且任務上下文可共享時
  • 會話提醒不會繞過許可權請求或破壞性操作的人工批准時

示例提示詞

以下是根據技能文件生成的示例,不代表實際執行結果。

規劃一個只監控指定 tmux 會話的方案,列出哪些任務資訊會傳送到通知服務;不要安裝鉤子、傳送通知或向會話輸入命令。

月度資料趨勢

累計下載4420
3712409244722026-05 · 累計下載 37642026-07 · 累計下載 41062026-08 · 累計下載 42182026-09 · 累計下載 442026-0526-09
星標3
2342026-05 · 星標 32026-07 · 星標 32026-08 · 星標 32026-09 · 星標 326-0526-09

2026-09 起統計方法調整:同名技能按作者分別統計,並覆蓋全部技能。圖中虛線為調整前的月份,與之後的資料不直接比較,也不計算跨越調整的增長。

月份累計下載環比星標
2026-094420—3
2026-084218+2.7%3
2026-074106—3
2026-053764—3

SKILL.md 原文

以下是作者釋出的原始檔案,按純文字顯示,本站未做修改或稽核;其中的連結不可點選,命令請核實後再執行。抓取於 2026-10-23。

6.6 KB · ClawHub v1.0.0
---
name: claude-code-supervisor
description: >
  Supervise Claude Code sessions running in tmux. Uses Claude Code hooks with
  bash pre-filtering (Option D) and fast LLM triage to detect errors, stuck
  agents, and task completion. Harness-agnostic — works with OpenClaw, webhooks,
  ntfy, or any notification backend. Use when: (1) launching long-running Claude
  Code tasks that need monitoring, (2) setting up automatic nudging for API
  errors or premature stops, (3) getting progress reports from background coding
  agents, (4) continuing work after session/context limits reset.
展開全部(共 207 行)
  Requires: tmux, claude CLI.
metadata:
  {
    "openclaw":
      {
        "emoji": "👷",
        "os": ["darwin", "linux"],
        "requires": { "bins": ["tmux"], "anyBins": ["claude"] },
      },
  }
---

# Claude Code Supervisor

Bridge between Claude Code's lifecycle hooks and your agent harness.

## Architecture

```
Claude Code (in tmux)
  │  Stop / Error / Notification
  ▼
Bash pre-filter (Option D)
  │  obvious cases handled directly
  │  ambiguous cases pass through
  ▼
Fast LLM triage (claude -p with Haiku, or local LLM)
  │  classifies: FINE | NEEDS_NUDGE | STUCK | DONE | ESCALATE
  │  FINE → logged silently
  ▼
Notify command (configurable)
  │  openclaw wake, webhook, ntfy, script, etc.
  ▼
Agent harness decides + acts
  │  nudge (send-keys to tmux), wait, escalate to human
```

## Quick Start

### 1. Install hooks into a project

```bash
{baseDir}/scripts/install-hooks.sh /path/to/your/project
```

Creates:
- `.claude/hooks/supervisor/` — hook scripts + triage
- `.claude/settings.json` — wired into Claude Code lifecycle
- `.claude-code-supervisor.yml` — configuration (edit this)

### 2. Configure

Edit `.claude-code-supervisor.yml`:

```yaml
triage:
  command: "claude -p --no-session-persistence"  # or: ollama run llama3.2
  model: "claude-haiku-4-20250414"

notify:
  command: "openclaw gateway call wake --params"  # or: curl, ntfy, script
```

### 3. Register a supervised session

Create `~/.openclaw/workspace/supervisor-state.json` (or wherever your harness keeps state):

```json
{
  "sessions": {
    "my-task": {
      "socket": "/tmp/openclaw-tmux-sockets/openclaw.sock",
      "tmuxSession": "my-task",
      "projectDir": "/path/to/project",
      "goal": "Fix issue #42",
      "successCriteria": "Tests pass, committed",
      "maxNudges": 5,
      "escalateAfterMin": 60,
      "status": "running"
    }
  }
}
```

### 4. Launch Claude Code in tmux

```bash
SOCKET="/tmp/openclaw-tmux-sockets/openclaw.sock"
tmux -S "$SOCKET" new -d -s my-task
tmux -S "$SOCKET" send-keys -t my-task "cd /path/to/project && claude 'Fix issue #42'" Enter
```

Hooks fire automatically. Triage assesses. You get notified only when it matters.

## How the Pre-Filter Works (Option D)

Not every hook event needs an LLM call. Bash catches the obvious cases first:

### on-stop.sh
| Signal | Bash decision | LLM triage? |
|--------|--------------|-------------|
| `max_tokens` | Always needs attention | ✅ Yes |
| `end_turn` + shell prompt back | Agent might be done | ✅ Yes |
| `end_turn` + no prompt | Agent is mid-work | ❌ Skip |
| `stop_sequence` | Normal | ❌ Skip |

### on-error.sh
| Signal | Bash decision | LLM triage? |
|--------|--------------|-------------|
| API 429 / rate limit | Transient, will resolve | ❌ Log only |
| API 500 | Agent likely stuck | ✅ Yes |
| Other tool error | Unknown severity | ✅ Yes |

### on-notify.sh
| Signal | Bash decision | LLM triage? |
|--------|--------------|-------------|
| `auth_*` | Internal, transient | ❌ Skip |
| `permission_prompt` | Needs decision | ✅ Yes |
| `idle_prompt` | Agent waiting | ✅ Yes |

## Triage Classifications

The LLM returns one of:

| Verdict | Meaning | Typical action |
|---------|---------|----------------|
| **FINE** | Agent is working normally | Log silently, no notification |
| **NEEDS_NUDGE** | Transient error, should continue | Send "continue" to tmux |
| **STUCK** | Looping or not progressing | Try different approach or escalate |
| **DONE** | Task completed successfully | Report to human |
| **ESCALATE** | Needs human judgment | Notify human with context |

## Handling Notifications (for agent harness authors)

Wake events arrive with the prefix `cc-supervisor:` followed by the classification:

```
cc-supervisor: NEEDS_NUDGE | error:api_500 | cwd=/home/user/project | ...
cc-supervisor: DONE | stopped:end_turn:prompt_back | cwd=/home/user/project | ...
```

### Nudging via tmux

```bash
tmux -S "$SOCKET" send-keys -t "$SESSION" "continue — the API error was transient" Enter
```

### Escalation format

See `references/escalation-rules.md` for when to nudge vs escalate and quiet hours.

## Watchdog (Who Watches the Watchman?)

Hooks depend on Claude Code being alive. If the session hard-crashes, hits account
limits, or the process gets OOM-killed, no hooks fire. The watchdog catches this.

`scripts/watchdog.sh` is a pure bash script (no LLM, no Claude Code dependency) that:
1. Reads `supervisor-state.json` for all `"running"` sessions
2. Checks: is the tmux socket alive? Is the session there? Is Claude Code still running?
3. If something is dead and no hook reported it → notifies via the configured command
4. Updates `lastWatchdogAt` in state for tracking

Run it on a timer. Choose your poison:

**System cron:**
```bash
*/15 * * * * /path/to/claude-code-supervisor/scripts/watchdog.sh
```

**OpenClaw cron:**
```json
{
  "schedule": { "kind": "every", "everyMs": 900000 },
  "payload": { "kind": "systemEvent", "text": "cc-supervisor: watchdog — run /path/to/scripts/watchdog.sh and report" },
  "sessionTarget": "main"
}
```

**systemd timer, launchd, or whatever runs periodically on your box.**

The watchdog is deliberately dumb — no LLM, no complex logic, just "is the process still
there?" This means it works even when the triage model is down, the API is melting, or
your account hit its limit. Belts and suspenders.

## Files

- `scripts/install-hooks.sh` — one-command setup per project
- `scripts/hooks/on-stop.sh` — Stop event handler with bash pre-filter
- `scripts/hooks/on-error.sh` — PostToolUseFailure handler with bash pre-filter
- `scripts/hooks/on-notify.sh` — Notification handler with bash pre-filter
- `scripts/triage.sh` — LLM triage (called by hooks for ambiguous cases)
- `scripts/lib.sh` — shared config loading and notification functions
- `scripts/watchdog.sh` — dead session detector (pure bash, no LLM dependency)
- `references/state-patterns.md` — terminal output pattern matching guide
- `references/escalation-rules.md` — when to nudge vs escalate vs wait
- `supervisor.yml.example` — example configuration

「開發程式設計」分類下的熱門技能

資料月份:2026-09 · 下載/星標/安裝數聚合自公開技能註冊庫(ClawHub、SkillHub),按月更新。口徑說明見資料方法。