Commands
Command overview
Section titled “Command overview”| Command | Purpose |
|---|---|
preflight | Scan Claude project logs, report oversized dirs/files, optionally auto-fix |
doctor | Generate a diagnostics bundle (zip) with system info, log tails, journal |
run -- <cmd> | Launch any command with watchdog monitoring, auto-bundle on crash/hang |
status | One-shot health check: disk free, log sizes, warnings |
watch | Background daemon: continuous monitoring, incident tracking, budget enforcement |
budget | View and manage the concurrency budget (show/acquire/release) |
mcp | Start MCP server (10 tools) for Claude Code self-monitoring |
preflight
Section titled “preflight”Scans ~/.claude/projects/ for oversized log directories and files.
# Report onlyclaude-guardian preflight
# Auto-fix: rotate + trim oversized logsclaude-guardian preflight --fix
# Aggressive mode: shorter retention, lower thresholdsclaude-guardian preflight --fix --aggressiveRotation compresses old logs with gzip (reversible). Trimming keeps the last N lines of oversized files. No files are deleted.
doctor
Section titled “doctor”Creates a zip bundle containing:
summary.json— system info, file size report, preflight resultslog-tails/— last 500 lines of each log filejournal.jsonl— every action the guardian has ever takenprocess.json— snapshot of running Claude processes at bundle timetimeline.json— reconstructed chronological event timelinestate.json— current daemon state (if daemon was running)incidents.jsonl— incident history (if any)
claude-guardian doctorclaude-guardian doctor --out ./my-bundle.zipSpawns a child process with watchdog monitoring.
claude-guardian run -- claudeclaude-guardian run --hang-timeout 120 -- node server.jsclaude-guardian run --auto-restart -- npm startThe watchdog uses three independent signals (log mtime, CPU activity, grace window) to detect hangs. No single false positive can trigger a hang declaration.
status
Section titled “status”Quick one-shot health check.
claude-guardian statusclaude-guardian status --bannerReports disk free space, log sizes, and a summary banner.
Background daemon for continuous monitoring.
claude-guardian watchclaude-guardian watch --verboseclaude-guardian watch --auto-fix --hang-timeout 120Options:
| Flag | Default | Description |
|---|---|---|
--hang-timeout <seconds> | 300 | Seconds of inactivity before warning |
--auto-fix | false | Auto-run preflight fixes when disk is low |
--verbose | false | Print every poll cycle |
Tracks incidents through an ok → warn → critical lifecycle with automatic bundle capture and deduplication. The daemon persists state to ~/.claude-guardian/state.json every 2 seconds so the MCP server can read it.
budget
Section titled “budget”Manage the concurrency budget.
claude-guardian budget showclaude-guardian budget acquire 2 --reason "build" --ttl 60claude-guardian budget release <lease-id>Deterministic cap transitions (4 → 2 → 1 slots) prevent dogpiling when under pressure.