ccc-nightwatch ยท diff
git:20260514.2648602 to git:20260707.947ab2f
4 added, 0 removed. Audit A to A.
---
name: ccc-nightwatch
description: "Remote YOLO control. Approve/deny tool use from your phone via Telegram/Discord while Claude runs overnight. Auto-classifies risk: reads auto-allow, rm/deploy ask human."
allowed-tools:
- Read
- Bash
- AskUserQuestion
argument-hint: "[setup | status | test]"
---
# /ccc-nightwatch โ Remote YOLO Control
Run Claude Code autonomously overnight. Approve or deny tool use from your phone via Telegram or Discord. A PreToolUse hook intercepts every tool call, classifies it by risk, and either auto-allows, asks you, or hard-blocks โ no sitting at the terminal required.
## What it does
Nightwatch installs a PreToolUse permission hook that intercepts tool calls during `/ccc night` (YOLO mode). Each call is scored against the risk matrix. Low-risk ops (reads, searches) proceed silently. Medium-risk ops (file writes, installs) send a phone notification and wait for your tap. High-risk ops (destructive commands, force pushes) are hard-blocked and alert you immediately. Your response routes back into the session within 2โ5 seconds, and Claude continues.
## Triggers
- `/ccc-nightwatch`
- "I want to run Claude Code overnight"
- "approve from phone"
- "remote YOLO"
- "autonomous with safety leash"
- "let it run, I'll check from my phone"
## Risk Classification Matrix
| Risk Level | Examples | Action |
|-----------|----------|--------|
| ๐ข Auto-allow | Read, Glob, Grep, LS, cat, git status, git log | Proceed silently โ logged |
| ๐ก Ask human | Edit, Write, Bash (npm/yarn/pnpm install), git commit, git push (non-main) | Push phone notify โ await tap โ resume |
| ๐ด Always-deny | rm -rf, git push --force to main, DROP TABLE, secret exfil patterns | Hard block + immediate alert |
Unclassified tools default to ๐ก Ask human.
## Architecture
```
Claude Code (YOLO mode)
|
[PreToolUse hook] โ hooks/nightwatch-relay.js
|
[Risk Classifier]
|
โโโโโโดโโโโโโโโโโโโโโโโโโโโโ
| |
๐ข Auto-allow ๐ก Ask human ๐ด Always-deny
| | |
proceed silently [Notifier] block + alert
| / \
| Telegram Discord
| bot webhook
| \ /
| user taps โ
/โ
| |
โโโโโโโโโโโโโโโ[Resume session]
|
tool call proceeds
(or blocked on โ)
```
## Setup
### Step 1 โ Choose your channel
Run `/ccc-nightwatch` and pick your channel:
```
AskUserQuestion:
question: "Which phone channel?"
options:
- Telegram bot (recommended โ instant, private)
- Discord webhook (easier setup)
- Skip (log-only mode โ no phone, just audit trail)
```
### Step 2a โ Telegram setup
```bash
# 1. Create bot via @BotFather on Telegram โ get token
# 2. Set env var
export CCC_NIGHTWATCH_TG_TOKEN="7123456789:AABBcc..."
export CCC_NIGHTWATCH_TG_CHAT_ID="123456789" # your personal chat ID
# 3. Test it
curl -s "https://api.telegram.org/bot$CCC_NIGHTWATCH_TG_TOKEN/sendMessage" \
-d "chat_id=$CCC_NIGHTWATCH_TG_CHAT_ID&text=Nightwatch+online+โ
"
```
Get your chat ID: message @userinfobot on Telegram.
### Step 2b โ Discord setup
```bash
# 1. Server Settings โ Integrations โ Webhooks โ New Webhook โ Copy URL
export CCC_NIGHTWATCH_DISCORD_URL="https://discord.com/api/webhooks/..."
# 2. Test it
curl -s -X POST "$CCC_NIGHTWATCH_DISCORD_URL" \
-H "Content-Type: application/json" \
-d '{"content":"Nightwatch online โ
"}'
```
### Step 3 โ Register the PreToolUse hook
Nightwatch registers its hook automatically on first run. Verify:
```bash
cat ~/.claude/settings.json | grep nightwatch
# โ "hooks/nightwatch-relay.js"
```
Then launch autonomous mode:
```bash
/ccc night # activates YOLO + Nightwatch relay
```
## Concrete Examples
**Example 1 โ Long refactor, 12 npm installs**
You kick off a dependency upgrade at 11pm. Nightwatch auto-allows all `Read` and `Glob` calls (silent). 12 `npm install` calls โ 12 Telegram taps (all ๐ก). 3 `git commit` calls โ 3 taps. You approve from bed, Claude finishes by 2am.
**Example 2 โ Overnight CI fix loop**
Tests fail. Claude fixes, commits, pushes to a feature branch (๐ก โ you approve), CI re-runs. Nightwatch blocks any attempt to `git push --force` to `main` (๐ด โ hard deny + alert). By morning, CI is green on the feature branch waiting for your PR merge.
**Example 3 โ Mid-stream AskUserQuestion relay**
Claude hits an ambiguous decision mid-codebase migration and calls `AskUserQuestion`. Nightwatch intercepts, formats the question + options as a Telegram message with inline buttons. You tap your choice. Claude resumes with your answer โ no terminal required.
## Tools Used
- `Read` โ inspect hook config and env vars
- `Bash` โ send curl webhooks, verify token setup, test channel connectivity
- `AskUserQuestion` โ channel picker and setup confirmation
## Privacy Note
Message content is scrubbed before relay. Nightwatch sends **tool name + argument summary only** โ no file contents, no secret values, no code snippets. Example relay: `"Write file: src/auth/login.ts (42 lines) โ allow?"` not the file content.
## When NOT to Use
- Short interactive sessions (< 30 min) โ just watch the terminal
- Quick single-file fixes โ YOLO mode overhead not worth it
- Sessions where you need continuous creative input โ Nightwatch is for execution, not ideation
## Limitations
- Requires phone connectivity at relay time (offline = auto-deny on timeout)
- Approval latency: 2โ5s per ๐ก call (network round-trip)
- Telegram bot requires a token registered with @BotFather โ 2 min one-time setup
- Discord inline buttons (โ
/โ) require a bot with interactions enabled; webhook-only mode falls back to reaction-based approval
- Not a substitute for reviewing the session log after โ always audit `~/.claude/commander/nightwatch.log`
+ ---
+
+ > โ๏ธ **Fable contract:** plan before build ยท verifier โ worker ยท prove before alarm ยท loops need gates ยท leave durable state โ `rules/fable-method.md`
+