Skip to content

Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.

feat: add /ops:daemon skill + fix stale-plist & wait bugs in ops-daemon.sh

auroracapitalcd929b6e2565
diff --git a/claude-ops/scripts/ops-daemon-manager.sh b/claude-ops/scripts/ops-daemon-manager.sh
new file mode 100755
index 00000000..a325cc1c
--- /dev/null
+++ b/claude-ops/scripts/ops-daemon-manager.sh
@@ -0,0 +1,368 @@
+#!/usr/bin/env bash
+# ops-daemon-manager.sh — Cross-OS daemon install / upgrade / status / uninstall
+#
+# Subcommands:
+# install Generate plist (or systemd unit), register with OS, start
+# upgrade Re-point plist at current PLUGIN_ROOT and reload (idempotent)
+# uninstall Stop, unregister, remove plist
+# status Emit JSON: {installed, running, pid, script_path, plugin_root, plist_version_matches}
+# restart Stop + start without reconfiguring
+#
+# Exit codes:
+# 0 success
+# 1 generic failure
+# 64 EX_USAGE (bad arguments)
+# 69 EX_UNAVAILABLE (OS not supported for install)
+# 78 EX_CONFIG (missing plist template, bad PLUGIN_ROOT)
+#
+# Portable: no hardcoded user paths. Reads PLUGIN_ROOT from env, argv, or auto-detect.
+
+set -euo pipefail
+
+usage() {
+ cat >&2 <<EOF
+Usage: ops-daemon-manager.sh <install|upgrade|uninstall|status|restart> [options]
+
+Options:
+ --plugin-root PATH Override auto-detected plugin root
+ --dry-run Print what would happen, do not execute
+
+Environment:
+ CLAUDE_PLUGIN_ROOT Plugin install directory (preferred over auto-detect)
+ OPS_DATA_DIR Data directory (default: \$HOME/.claude/plugins/data/ops-ops-marketplace)
+
+Examples:
+ ops-daemon-manager.sh install
+ ops-daemon-manager.sh status
+ ops-daemon-manager.sh upgrade --plugin-root \$HOME/.claude/plugins/cache/ops-marketplace/ops/1.3.0
+EOF
+}
+
+# ── Arg parsing ──────────────────────────────────────────────────────────
+if (( $# < 1 )); then
+ usage
+ exit 64
+fi
+
+CMD="$1"; shift
+DRY_RUN=0
+CLI_PLUGIN_ROOT=""
+while (( $# > 0 )); do
+ case "$1" in
+ --plugin-root) CLI_PLUGIN_ROOT="$2"; shift 2 ;;
+ --dry-run) DRY_RUN=1; shift ;;
+ -h|--help) usage; exit 0 ;;
+ *) echo "Unknown option: $1" >&2; usage; exit 64 ;;
+ esac
+done
+
+# ── OS detection ─────────────────────────────────────────────────────────
+detect_os() {
+ local uname_s
+ uname_s="$(uname -s 2>/dev/null || echo unknown)"
+ case "$uname_s" in
+ Darwin) echo macos ;;
+ Linux)
+ if grep -qi microsoft /proc/version 2>/dev/null; then echo wsl; else echo linux; fi
+ ;;
+ MINGW*|MSYS*|CYGWIN*) echo windows ;;
+ *) echo unknown ;;
+ esac
+}
+OS="$(detect_os)"
+
+# ── Plugin root resolution ───────────────────────────────────────────────
+resolve_plugin_root() {
+ if [[ -n "$CLI_PLUGIN_ROOT" ]]; then
+ echo "$CLI_PLUGIN_ROOT"
+ return
+ fi
+ if [[ -n "${CLAUDE_PLUGIN_ROOT:-}" ]] && [[ -d "${CLAUDE_PLUGIN_ROOT}/scripts" ]]; then
+ echo "$CLAUDE_PLUGIN_ROOT"
+ return
+ fi
+ # Auto-detect: newest installed version under ~/.claude/plugins/cache/ops-marketplace/ops/
+ local newest
+ newest=$(ls -d "$HOME/.claude/plugins/cache/ops-marketplace/ops"/*/ 2>/dev/null \
+ | sed 's:/$::' \
+ | awk -F/ '{ver=$NF; print ver"\t"$0}' \
+ | sort -V -k1,1 \
+ | tail -1 \
+ | cut -f2-)
+ if [[ -z "$newest" ]]; then
+ echo "" ; return
+ fi
+ echo "$newest"
+}
+
+PLUGIN_ROOT="$(resolve_plugin_root)"
+DATA_DIR="${OPS_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}"
+LOG_DIR="$DATA_DIR/logs"
+PLIST_LABEL="com.claude-ops.daemon"
+PLIST_DEST="$HOME/Library/LaunchAgents/${PLIST_LABEL}.plist"
+HEALTH_FILE="$DATA_DIR/daemon-health.json"
+SERVICES_FILE="$DATA_DIR/daemon-services.json"
+
+log() { printf '[daemon-manager] %s\n' "$*" >&2; }
+run() {
+ if (( DRY_RUN )); then
+ echo "DRY: $*" >&2
+ else
+ "$@"
+ fi
+}
+
+# ── Resolve bash binary (must be v4+) ────────────────────────────────────
+resolve_bash_path() {
+ # Check known homebrew locations first (most common on macOS with new bash)
+ local candidates=(
+ /opt/homebrew/bin/bash
+ /usr/local/bin/bash
+ )
+ for c in "${candidates[@]}"; do
+ if [[ -x "$c" ]]; then
+ local v
+ v=$("$c" -c 'echo $BASH_VERSINFO' 2>/dev/null || echo 0)
+ if [[ "$v" =~ ^[0-9]+$ ]] && (( v >= 4 )); then
+ echo "$c"; return
+ fi
+ fi
+ done
+ # Fall back to `bash` on PATH if it is >=4
+ if command -v bash >/dev/null 2>&1; then
+ local v
+ v=$(bash -c 'echo $BASH_VERSINFO' 2>/dev/null || echo 0)
+ if [[ "$v" =~ ^[0-9]+$ ]] && (( v >= 4 )); then
+ command -v bash; return
+ fi
+ fi
+ echo "" # not found
+}
+
+# ── macOS launchctl helpers ──────────────────────────────────────────────
+mac_generate_plist() {
+ local template="$PLUGIN_ROOT/scripts/com.claude-ops.daemon.plist"
+ local bash_path
+ bash_path="$(resolve_bash_path)"
+ if [[ -z "$bash_path" ]]; then
+ log "ERROR: bash 4+ not found. Install with: brew install bash"
+ exit 78
+ fi
+ if [[ ! -f "$template" ]]; then
+ log "ERROR: plist template not found at $template"
+ exit 78
+ fi
+ mkdir -p "$(dirname "$PLIST_DEST")" "$LOG_DIR"
+ local tmp="$PLIST_DEST.tmp"
+ sed \
+ -e "s|__BASH_PATH__|$bash_path|g" \
+ -e "s|__DAEMON_SCRIPT_PATH__|$PLUGIN_ROOT/scripts/ops-daemon.sh|g" \
+ -e "s|__LOG_DIR__|$LOG_DIR|g" \
+ -e "s|__HOME__|$HOME|g" \
+ -e "s|__PLUGIN_ROOT__|$PLUGIN_ROOT|g" \
+ "$template" > "$tmp"
+ # Validate before installing
+ if command -v plutil >/dev/null 2>&1; then
+ if ! plutil -lint "$tmp" >/dev/null 2>&1; then
+ log "ERROR: generated plist is invalid"
+ rm -f "$tmp"
+ exit 1
+ fi
+ fi
+ run mv "$tmp" "$PLIST_DEST"
+ log "wrote $PLIST_DEST"
+}
+
+mac_is_loaded() {
+ launchctl list 2>/dev/null | grep -q "[[:space:]]${PLIST_LABEL}$"
+}
+
+mac_current_pid() {
+ launchctl list 2>/dev/null | awk -v l="$PLIST_LABEL" '$3==l { print $1 }'
+}
+
+mac_unload() {
+ if mac_is_loaded; then
+ run launchctl bootout "gui/$(id -u)" "$PLIST_DEST" 2>/dev/null || \
+ run launchctl unload "$PLIST_DEST" 2>/dev/null || true
+ fi
+}
+
+mac_load() {
+ run launchctl bootstrap "gui/$(id -u)" "$PLIST_DEST" 2>/dev/null || \
+ run launchctl load "$PLIST_DEST"
+}
+
+mac_plist_script_path() {
+ # Extract the second <string> inside ProgramArguments.
+ # Portable across GNU and BSD awk — no 3-arg match().
+ if [[ ! -f "$PLIST_DEST" ]]; then return; fi
+ awk '
+ /<key>ProgramArguments<\/key>/ { in_pa=1; next }
+ in_pa && /<string>/ {
+ if (!bash_seen) { bash_seen=1; next }
+ line=$0
+ sub(/^[[:space:]]*<string>/, "", line)
+ sub(/<\/string>[[:space:]]*$/, "", line)
+ print line
+ exit
+ }
+ ' "$PLIST_DEST" 2>/dev/null
+}
+
+# ── Commands ─────────────────────────────────────────────────────────────
+cmd_install() {
+ if [[ -z "$PLUGIN_ROOT" ]] || [[ ! -d "$PLUGIN_ROOT/scripts" ]]; then
+ log "ERROR: plugin root not found. Set CLAUDE_PLUGIN_ROOT or install the plugin."
+ exit 78
+ fi
+ log "plugin root: $PLUGIN_ROOT"
+ log "os: $OS"
+ case "$OS" in
+ macos)
+ if [[ -f "$PLIST_DEST" ]]; then
+ log "plist already exists — running upgrade instead"
+ cmd_upgrade
+ return
+ fi
+ mac_generate_plist
+ mac_load
+ log "installed — verify with: launchctl list | grep $PLIST_LABEL"
+ ;;
+ linux|wsl)
+ log "Linux/WSL systemd install is not yet supported by this helper."
+ log "Run manually: nohup $PLUGIN_ROOT/scripts/ops-daemon.sh >> $LOG_DIR/ops-daemon.log 2>&1 &"
+ exit 69
+ ;;
+ windows)
+ log "Windows native is not supported. Use WSL."
+ exit 69
+ ;;
+ *)
+ log "unknown OS: $OS"
+ exit 69
+ ;;
+ esac
+}
+
+cmd_upgrade() {
+ if [[ -z "$PLUGIN_ROOT" ]] || [[ ! -d "$PLUGIN_ROOT/scripts" ]]; then
+ log "ERROR: plugin root not found"
+ exit 78
+ fi
+ case "$OS" in
+ macos)
+ mac_unload
+ sleep 1
+ mac_generate_plist
+ mac_load
+ log "upgraded to point at $PLUGIN_ROOT"
+ ;;
+ *)
+ log "upgrade only supported on macOS"
+ exit 69
+ ;;
+ esac
+}
+
+cmd_uninstall() {
+ case "$OS" in
+ macos)
+ mac_unload
+ run rm -f "$PLIST_DEST"
+ log "removed $PLIST_DEST"
+ ;;
+ *) exit 69 ;;
+ esac
+}
+
+cmd_restart() {
+ case "$OS" in
+ macos)
+ mac_unload
+ sleep 1
+ mac_load
+ log "restarted"
+ ;;
+ *) exit 69 ;;
+ esac
+}
+
+cmd_status() {
+ local installed=false
+ local running=false
+ local pid="null"
+ local script_path=""
+ local plist_version_match=false
+ local health_fresh=false
+ local health_mtime=""
+ local current_script_path="$PLUGIN_ROOT/scripts/ops-daemon.sh"
+
+ if [[ -f "$PLIST_DEST" ]]; then
+ installed=true
+ script_path="$(mac_plist_script_path)"
+ if [[ "$script_path" == "$current_script_path" ]]; then
+ plist_version_match=true
+ fi
+ fi
+
+ case "$OS" in
+ macos)
+ if mac_is_loaded; then
+ local p
+ p="$(mac_current_pid)"
+ if [[ -n "$p" ]] && [[ "$p" != "-" ]]; then
+ pid="$p"
+ if kill -0 "$p" 2>/dev/null; then
+ running=true
+ fi
+ fi
+ fi
+ ;;
+ esac
+
+ if [[ -f "$HEALTH_FILE" ]]; then
+ local now mtime age
+ now=$(date +%s)
+ # Portable mtime: GNU vs BSD stat
+ if stat --version >/dev/null 2>&1; then
+ mtime=$(stat -c %Y "$HEALTH_FILE" 2>/dev/null || echo 0)
+ else
+ mtime=$(stat -f %m "$HEALTH_FILE" 2>/dev/null || echo 0)
+ fi
+ age=$(( now - mtime ))
+ health_mtime="$(date -u -r "$mtime" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || \
+ date -u -d "@$mtime" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || echo '')"
+ if (( age < 120 )); then
+ health_fresh=true
+ fi
+ fi
+
+ cat <<EOF
+{
+ "os": "$OS",
+ "plugin_root": "${PLUGIN_ROOT:-null}",
+ "installed": $installed,
+ "running": $running,
+ "pid": $( [[ "$pid" == "null" ]] && echo null || echo "$pid" ),
+ "plist_path": "$PLIST_DEST",
+ "plist_script_path": "$script_path",
+ "expected_script_path": "$current_script_path",
+ "plist_version_match": $plist_version_match,
+ "health_file": "$HEALTH_FILE",
+ "health_fresh": $health_fresh,
+ "health_mtime": "$health_mtime",
+ "services_file": "$SERVICES_FILE"
+}
+EOF
+}
+
+# ── Dispatch ─────────────────────────────────────────────────────────────
+case "$CMD" in
+ install) cmd_install ;;
+ upgrade) cmd_upgrade ;;
+ uninstall) cmd_uninstall ;;
+ restart) cmd_restart ;;
+ status) cmd_status ;;
+ *) usage; exit 64 ;;
+esac
diff --git a/claude-ops/scripts/ops-daemon.sh b/claude-ops/scripts/ops-daemon.sh
index c8e71ebb..0bbae707 100755
--- a/claude-ops/scripts/ops-daemon.sh
+++ b/claude-ops/scripts/ops-daemon.sh
@@ -4,6 +4,19 @@
# daemon registration: launchd on macOS, systemd on Linux, Task Scheduler on Windows
set -euo pipefail
+# ── Bash version guard ───────────────────────────────────────────────────
+# This script uses associative arrays (`declare -A`) which require bash 4+.
+# macOS ships bash 3.2 at /bin/bash; callers must use a newer bash (e.g.
+# `/opt/homebrew/bin/bash` on Apple Silicon, `/usr/local/bin/bash` on Intel).
+# Fail loud with a clear message instead of the cryptic `declare -A` error.
+if (( BASH_VERSINFO[0] < 4 )); then
+ echo "ERROR: ops-daemon.sh requires bash 4 or newer (current: $BASH_VERSION)" >&2
+ echo " macOS ships /bin/bash 3.2 — install GNU bash via Homebrew:" >&2
+ echo " brew install bash" >&2
+ echo " then invoke with /opt/homebrew/bin/bash (or /usr/local/bin/bash)." >&2
+ exit 78 # EX_CONFIG
+fi
+
# ── OS detection (sourced) ────────────────────────────────────────────────
# Resolves to the claude-ops plugin root (parent of scripts/).
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
@@ -374,6 +387,7 @@ prefetch_briefing_cache() {
local tmpdir
tmpdir=$(mktemp -d)
+ local -a _refresh_pids=()
# Unread counts
(command -v wacli &>/dev/null && wacli chats list --json 2>/dev/null | python3 -c "
@@ -383,6 +397,7 @@ cutoff=(datetime.datetime.now(datetime.timezone.utc)-datetime.timedelta(days=7))
recent=[c for c in data if c.get('LastMessageTS','')>cutoff]
print(json.dumps({'total_chats':len(recent),'count':len(data)}))
" > "$tmpdir/wa.json" 2>/dev/null) &
+ _refresh_pids+=($!)
# Email count
(command -v gog &>/dev/null && gog gmail search -j --results-only --no-input --max 10 "in:inbox" 2>/dev/null | python3 -c "
@@ -390,17 +405,23 @@ import json,sys
data=json.load(sys.stdin)
print(json.dumps({'unread_count':len(data)}))
" > "$tmpdir/email.json" 2>/dev/null) &
+ _refresh_pids+=($!)
# Open PRs
(command -v gh &>/dev/null && gh pr list --json number,title,headRefName,createdAt --limit 20 2>/dev/null > "$tmpdir/prs.json") &
+ _refresh_pids+=($!)
# Projects placeholder with timestamp
(python3 -c "
import json
print(json.dumps({'cached_at':'$(date -u +%Y-%m-%dT%H:%M:%SZ)'}))
" > "$tmpdir/projects.json" 2>/dev/null) &
+ _refresh_pids+=($!)
- wait
+ # Wait only on the 4 gather subshells above. Bare `wait` blocks on ALL
+ # children — including long-lived services like message-listener — which
+ # would freeze the monitor loop on the first refresh.
+ wait "${_refresh_pids[@]}" 2>/dev/null || true
# Merge all into briefing cache
python3 -c "
diff --git a/claude-ops/skills/ops-daemon/SKILL.md b/claude-ops/skills/ops-daemon/SKILL.md
new file mode 100644
index 00000000..94b40100
--- /dev/null
+++ b/claude-ops/skills/ops-daemon/SKILL.md
@@ -0,0 +1,186 @@
+---
+name: ops-daemon
+description: Check claude-ops background daemon end-to-end and auto-fix common issues. Detects stale plist paths after plugin upgrades, missing service commands, dead processes, corrupt health files, and bash version mismatches.
+argument-hint: "[check|fix|restart|status|uninstall]"
+allowed-tools:
+ - Bash
+ - Read
+ - Write
+ - Edit
+ - Glob
+ - Grep
+ - AskUserQuestion
+effort: low
+maxTurns: 20
+---
+
+## Runtime Context
+
+Before diagnosing, load:
+
+1. **Plugin root**: `echo "${CLAUDE_PLUGIN_ROOT:-$(ls -d "$HOME/.claude/plugins/cache/ops-marketplace/ops"/*/ 2>/dev/null | sort -V | tail -1)}"` — newest installed version
+2. **Daemon health**: `cat ${CLAUDE_PLUGIN_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}/daemon-health.json` — primary diagnostic input
+3. **Services config**: `cat ${CLAUDE_PLUGIN_DATA_DIR}/daemon-services.json` — per-service command + cron definitions
+4. **OS**: `uname -s` — daemon install is macOS-only (launchd). Linux/WSL/Windows fall back to manual invocation.
+
+# OPS ► DAEMON
+
+Diagnostic + auto-fix surface for the background `ops-daemon` process. Acts like `ops-doctor` but scoped to the one subsystem users actually see break: the launchd daemon that keeps `briefing-pre-warm`, `memory-extractor`, `message-listener`, `inbox-digest`, and `competitor-intel` alive.
+
+## CLI/API Reference
+
+### bin/ops-daemon-manager.sh
+
+| Command | Usage | Output |
+|---------|-------|--------|
+| `${CLAUDE_PLUGIN_ROOT}/scripts/ops-daemon-manager.sh status` | Emit JSON snapshot | `{os, installed, running, pid, plist_version_match, health_fresh, ...}` |
+| `${CLAUDE_PLUGIN_ROOT}/scripts/ops-daemon-manager.sh install` | First-time install (idempotent) | Writes plist, loads launchd |
+| `${CLAUDE_PLUGIN_ROOT}/scripts/ops-daemon-manager.sh upgrade` | Re-point plist at current PLUGIN_ROOT + reload | Fixes stale version paths |
+| `${CLAUDE_PLUGIN_ROOT}/scripts/ops-daemon-manager.sh restart` | Unload + reload without reconfiguring | Clears stuck state |
+| `${CLAUDE_PLUGIN_ROOT}/scripts/ops-daemon-manager.sh uninstall` | Stop + remove plist | Returns system to pre-install state |
+
+Accepts `--plugin-root PATH` to override auto-detection and `--dry-run` to preview without side effects.
+
+### Health file schema
+
+`${CLAUDE_PLUGIN_DATA_DIR}/daemon-health.json`:
+
+```json
+{
+ "timestamp": "<ISO-8601 UTC>",
+ "pid": <int>,
+ "uptime_seconds": <int>,
+ "services": {
+ "<name>": {
+ "status": "running|polling|scheduled|dead|needs_reauth",
+ "pid": <int|null>,
+ "last_health": "<string|null>",
+ "last_run": "<ISO-8601|empty>",
+ "next_run": "<ISO-8601|empty>",
+ "restarts": <int>
+ }
+ },
+ "action_needed": null | {"kind": "...", "service": "...", "message": "..."}
+}
+```
+
+A healthy daemon refreshes this file every 30s. An `mtime` older than 120s is a strong fail signal.
+
+---
+
+## Your task
+
+Route on the first argument:
+
+| Argument | Action |
+|----------|--------|
+| `check` (default) | Run all diagnostics, print a colored report, exit 0 if green / 1 otherwise |
+| `fix` | Run `check`, then per detected issue ask the user for confirmation and apply the fix |
+| `restart` | Call `ops-daemon-manager.sh restart` |
+| `status` | Print the JSON output of `ops-daemon-manager.sh status` verbatim — consumed by other skills |
+| `uninstall` | Ask `[Uninstall]` / `[Cancel]` via `AskUserQuestion`, then call the manager |
+
+### Diagnostic checklist
+
+Run each check and track results as `pass` / `fail` / `warn`:
+
+1. **Plugin root resolved** — `CLAUDE_PLUGIN_ROOT` env var set OR `~/.claude/plugins/cache/ops-marketplace/ops/<version>/scripts/ops-daemon.sh` exists.
+2. **OS supported** — `uname -s` is `Darwin`. On Linux/WSL print the manual invocation and exit 0 with a `warn` note. On native Windows print "not supported".
+3. **Plist installed** — `~/Library/LaunchAgents/com.claude-ops.daemon.plist` exists.
+4. **Plist points at current version** — the second `<string>` inside `ProgramArguments` equals `${PLUGIN_ROOT}/scripts/ops-daemon.sh`. Mismatch = **stale after upgrade** (the most common failure mode).
+5. **Plist is valid XML** — `plutil -lint` passes.
+6. **Launchctl registered** — `launchctl list` shows the label with a real PID (not `-`).
+7. **Process alive** — `kill -0 <pid>` succeeds.
+8. **Bash binary exists** — the first `<string>` in `ProgramArguments` is executable and reports `BASH_VERSINFO >= 4` (required for `declare -A` in the daemon script).
+9. **Health file fresh** — `daemon-health.json` exists, `mtime` within last 120 seconds.
+10. **Every service has a command** — iterate `daemon-services.json` services; each enabled entry must have a non-empty `command` field. Missing `command` silently skips the service (historical bug).
+11. **Running services alive** — for each service in the health file with `status=running|polling`, verify `kill -0 <pid>` succeeds.
+12. **Cron services have future `next_run`** — `scheduled` services must have a `next_run` timestamp in the future.
+13. **wacli-sync path resolves** — if enabled, `~/.wacli/.health` exists and is fresh. (Optional — mark warn not fail if missing.)
+14. **No zombie children** — no orphaned `ops-message-listener.sh` or `wacli-keepalive.sh` processes without a parent `ops-daemon.sh`.
+
+### Fix playbook
+
+For each failed check, `fix` mode proposes a specific repair and asks the user with `AskUserQuestion` (**max 4 options** — always include `[Skip]`):
+
+| Failure | Fix | Destructive? |
+|---------|-----|--------------|
+| Plist stale version path | `ops-daemon-manager.sh upgrade` | Yes — unloads + reloads |
+| Plist missing | `ops-daemon-manager.sh install` | No |
+| Plist invalid XML | Regenerate via `install` (after backup) | Yes — overwrites |
+| Process dead but plist ok | `ops-daemon-manager.sh restart` | Yes — restarts |
+| Health file stale (>120s) | `ops-daemon-manager.sh restart` | Yes |
+| Service missing `command` | Merge from `scripts/daemon-services.example.json` into user's `daemon-services.json` after showing a diff | Yes — writes config |
+| Bash binary missing/<4 | `brew install bash` on macOS; on Linux check `$(command -v bash)` version; ask user to install | No (reports only) |
+| Zombie child processes | `kill <pid>` with per-process confirmation (Rule 5) | Yes |
+| Services config corrupt JSON | Restore from `scripts/daemon-services.default.json` after confirmation + backup | Yes |
+
+**Never batch fixes.** Per Rule 5, each destructive action needs its own `AskUserQuestion` with `[Apply]` / `[Skip]` options.
+
+### Output format for `check`
+
+```
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+ OPS ► DAEMON CHECK
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+ OS: macos
+ Plugin root: ${CLAUDE_PLUGIN_ROOT}
+ Daemon PID: 57004
+ Uptime: 1h 12m
+
+ ✓ Plist installed
+ ✓ Plist points at current version
+ ✓ Plist is valid XML
+ ✓ Launchctl registered, PID alive
+ ✓ Bash binary found (5.3)
+ ✓ Health file fresh (mtime 23s ago)
+ ✓ All 5 enabled services have commands
+ ✓ Running services alive
+ ✓ Cron services have future next_run
+
+ STATUS: GREEN — daemon healthy
+```
+
+On failure, replace `✓` with `✗` and append a one-line remediation hint. Exit 1 so `/ops:ops-status` can surface red.
+
+### Output format for `status`
+
+Print the JSON from `ops-daemon-manager.sh status` verbatim. No wrapping. This is the machine-readable contract consumed by `ops-status`, `ops-go`, and other skills.
+
+### Output format for `fix`
+
+Render the `check` report, then for each failing check enter a confirmation loop:
+
+```
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+ OPS ► DAEMON FIX — 3 issues found
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+ ✗ Plist points at old version 1.0.0
+ → Proposed: ops-daemon-manager.sh upgrade
+```
+
+Then `AskUserQuestion` with `[Apply fix]` / `[Skip this issue]` / `[Cancel all]`. Repeat for each issue. After all actions, re-run `check` and print a before/after diff.
+
+## Cross-OS notes
+
+- **macOS**: full support via launchd. All subcommands available.
+- **Linux / WSL**: `ops-daemon-manager.sh install` exits `EX_UNAVAILABLE` (69) and prints the manual `nohup` invocation. `check` still validates the daemon script and services config.
+- **Windows native**: unsupported. Use WSL.
+
+Do not hardcode `launchctl` in this SKILL — always route through the manager script so future systemd / Task Scheduler support is a one-line addition.
+
+## Examples
+
+```
+# Morning habit: confirm the daemon survived overnight
+/ops:daemon check
+
+# After a plugin upgrade (`/plugin upgrade claude-ops`):
+/ops:daemon fix
+# → detects stale plist, asks [Apply upgrade], reloads, verifies
+
+# Embedded in another skill:
+/ops:daemon status | jq -r '.health_fresh'
+```
diff --git a/claude-ops/tests/run-all.sh b/claude-ops/tests/run-all.sh
index f4eba14f..7cde2795 100755
--- a/claude-ops/tests/run-all.sh
+++ b/claude-ops/tests/run-all.sh
@@ -40,6 +40,7 @@ run_suite "$TESTS_DIR/test-template.sh"
run_suite "$TESTS_DIR/test-claude-md.sh"
run_suite "$TESTS_DIR/test-no-secrets.sh"
run_suite "$TESTS_DIR/test-agent-teams.sh"
+run_suite "$TESTS_DIR/test-ops-daemon-manager.sh"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "SUMMARY"
diff --git a/claude-ops/tests/test-ops-daemon-manager.sh b/claude-ops/tests/test-ops-daemon-manager.sh
new file mode 100755
index 00000000..cb0cd527
--- /dev/null
+++ b/claude-ops/tests/test-ops-daemon-manager.sh
@@ -0,0 +1,169 @@
+#!/usr/bin/env bash
+# test-ops-daemon-manager.sh — Unit tests for scripts/ops-daemon-manager.sh
+#
+# Focus: syntax, argument handling, status JSON shape, and plist path
+# extraction. Does NOT touch launchctl (CI runs on Linux).
+
+set -euo pipefail
+
+PLUGIN_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+MANAGER="$PLUGIN_ROOT/scripts/ops-daemon-manager.sh"
+DAEMON_SCRIPT="$PLUGIN_ROOT/scripts/ops-daemon.sh"
+
+pass=0
+fail=0
+
+ok() { echo " PASS: $1"; pass=$((pass+1)); }
+err() { echo " FAIL: $1"; fail=$((fail+1)); }
+
+echo "Testing $MANAGER"
+echo ""
+
+# 1. Manager script exists and is executable
+if [[ -x "$MANAGER" ]]; then
+ ok "manager script is executable"
+else
+ err "manager script missing or not executable: $MANAGER"
+fi
+
+# 2. Bash syntax check
+if bash -n "$MANAGER" 2>/dev/null; then
+ ok "bash -n syntax check"
+else
+ err "bash syntax check failed"
+fi
+
+# 3. Daemon script has bash version guard
+if head -20 "$DAEMON_SCRIPT" | grep -q "BASH_VERSINFO\[0\] < 4"; then
+ ok "ops-daemon.sh has bash 4+ guard"
+else
+ err "ops-daemon.sh is missing bash version guard"
+fi
+
+# 4. Daemon script does not use bare `wait` in refresh_briefing
+if grep -Pzo 'refresh_briefing\(\)[\s\S]*?^\}' "$DAEMON_SCRIPT" 2>/dev/null | grep -qE '^\s*wait\s*$'; then
+ err "refresh_briefing still contains a bare 'wait' — will block on long-lived services"
+else
+ ok "refresh_briefing uses targeted wait (no bare 'wait')"
+fi
+
+# 5. No hardcoded user paths
+if grep -n "/Users/[a-z]" "$MANAGER" >&2; then
+ err "manager contains hardcoded /Users/ paths"
+else
+ ok "no hardcoded /Users/ paths"
+fi
+
+# 6. Usage shown with no arguments
+set +e
+usage_output="$("$MANAGER" 2>&1)"
+set -e
+if echo "$usage_output" | grep -qi "usage:"; then
+ ok "prints usage with no arguments"
+else
+ err "did not print usage on empty invocation"
+fi
+
+# 7. Exit 64 (EX_USAGE) with no arguments
+set +e
+"$MANAGER" >/dev/null 2>&1
+rc=$?
+set -e
+if [[ "$rc" == "64" ]]; then
+ ok "exit 64 (EX_USAGE) on empty invocation"
+else
+ err "expected exit 64 on empty invocation, got $rc"
+fi
+
+# 8. Unknown option exits 64
+set +e
+"$MANAGER" status --bogus-flag >/dev/null 2>&1
+rc=$?
+set -e
+if [[ "$rc" == "64" ]]; then
+ ok "exit 64 on unknown option"
+else
+ err "expected exit 64 on unknown option, got $rc"
+fi
+
+# 9. Status command emits valid JSON (even with no plist installed, in a sandbox)
+# Use a temp HOME so we don't depend on the tester's real install.
+STATUS_HOME=$(mktemp -d)
+STATUS_DATA="$STATUS_HOME/.claude/plugins/data/ops-ops-marketplace"
+mkdir -p "$STATUS_DATA/logs" "$STATUS_HOME/Library/LaunchAgents"
+set +e
+HOME="$STATUS_HOME" OPS_DATA_DIR="$STATUS_DATA" \
+ CLAUDE_PLUGIN_ROOT="$PLUGIN_ROOT" \
+ "$MANAGER" status > "$STATUS_HOME/status.json" 2>"$STATUS_HOME/status.err"
+rc=$?
+set -e
+if [[ "$rc" == "0" ]] && [[ -s "$STATUS_HOME/status.json" ]]; then
+ ok "status subcommand exits 0 with output"
+else
+ err "status subcommand failed (rc=$rc)"
+ cat "$STATUS_HOME/status.err" >&2 || true
+fi
+
+# 10. Status output is parseable JSON with expected keys
+if command -v python3 >/dev/null 2>&1; then
+ if python3 -c "
+import json, sys
+with open('$STATUS_HOME/status.json') as f:
+ d = json.load(f)
+required = ['os', 'plugin_root', 'installed', 'running', 'pid', 'plist_path',
+ 'plist_script_path', 'expected_script_path', 'plist_version_match',
+ 'health_file', 'health_fresh', 'services_file']
+missing = [k for k in required if k not in d]
+if missing:
+ print('missing keys:', missing, file=sys.stderr)
+ sys.exit(1)
+" 2>/dev/null; then
+ ok "status JSON has all required keys"
+ else
+ err "status JSON is malformed or missing keys"
+ fi
+fi
+
+# 11. On a fresh temp HOME, installed=false and plist_version_match=false
+if command -v python3 >/dev/null 2>&1; then
+ if python3 -c "
+import json
+d = json.load(open('$STATUS_HOME/status.json'))
+assert d['installed'] == False, f'expected installed=false, got {d[\"installed\"]}'
+assert d['plist_version_match'] == False, f'expected plist_version_match=false'
+" 2>/dev/null; then
+ ok "clean-HOME status reports installed=false"
+ else
+ err "clean-HOME status did not report installed=false"
+ fi
+fi
+
+# 12. Help flag works
+set +e
+help_output="$("$MANAGER" --help 2>&1)"
+set -e
+if echo "$help_output" | grep -qi usage; then
+ ok "--help prints usage"
+else
+ err "--help did not print usage"
+fi
+
+# 13. Dry-run flag accepted
+set +e
+OPS_DATA_DIR="$STATUS_DATA" HOME="$STATUS_HOME" \
+ CLAUDE_PLUGIN_ROOT="$PLUGIN_ROOT" \
+ "$MANAGER" restart --dry-run >/dev/null 2>&1
+rc=$?
+set -e
+# On non-macOS hosts this will exit 69 (EX_UNAVAILABLE); on macOS it should exit 0
+if [[ "$rc" == "0" ]] || [[ "$rc" == "69" ]]; then
+ ok "restart --dry-run exits 0 or 69"
+else
+ err "restart --dry-run unexpected exit $rc"
+fi
+
+rm -rf "$STATUS_HOME"
+
+echo ""
+echo "Results: $pass passed, $fail failed"
+[[ "$fail" == "0" ]]