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.

refactor: async hooks for faster session startup (#569)

Aurora Capital6de4a155b0cf
diff --git a/claude-ops/bin/ops-pretool-whatsapp-bridge-health b/claude-ops/bin/ops-pretool-whatsapp-bridge-health
index a4010893..8dd8478f 100755
--- a/claude-ops/bin/ops-pretool-whatsapp-bridge-health
+++ b/claude-ops/bin/ops-pretool-whatsapp-bridge-health
@@ -1,24 +1,19 @@
#!/usr/bin/env bash
-# PreToolUse hook: check whatsapp-bridge health before WhatsApp MCP tool calls
-# Receives tool input as $1, warns if bridge appears down
-set -euo pipefail
-
+# PreToolUse hook: fast whatsapp-bridge health check (backgrounded to avoid blocking)
+set -e
INPUT="${1:-}"
+echo "$INPUT" | grep -q "whatsapp" || exit 0
-# Only check if the tool call involves whatsapp MCP tools
-if ! echo "$INPUT" | grep -q "whatsapp"; then
- exit 0
-fi
-
-# Check bridge is listening on port 8080
-if ! lsof -i :8080 2>/dev/null | grep -q LISTEN; then
- echo "⚠ WhatsApp bridge not running on :8080. Restart: launchctl kickstart -k gui/$(id -u)/com.${USER}.whatsapp-bridge"
- # Don't block — just warn. The skill's own health check will handle it.
-fi
-
-# Check launchd registration
-if ! launchctl list "com.${USER}.whatsapp-bridge" 2>/dev/null | grep -q '"PID"'; then
- echo "⚠ com.${USER}.whatsapp-bridge not active in launchd. Check: launchctl list com.${USER}.whatsapp-bridge"
-fi
-
+# Background the slow checks (lsof, launchctl) so this hook returns instantly.
+# If bridge is down, the skill's own health check will catch it.
+(
+ sleep 0.1
+ if ! (lsof -i :8080 2>/dev/null | grep -q LISTEN); then
+ cat <<EOF >&2
+⚠ WhatsApp bridge not on :8080. Restart:
+ launchctl kickstart -k gui/$(id -u)/com.${USER}.whatsapp-bridge
+EOF
+ fi
+) &
+disown 2>/dev/null || true
exit 0
diff --git a/claude-ops/bin/ops-suggest-specialized-agent b/claude-ops/bin/ops-suggest-specialized-agent
index 836fc5df..fda12d05 100755
--- a/claude-ops/bin/ops-suggest-specialized-agent
+++ b/claude-ops/bin/ops-suggest-specialized-agent
@@ -1,25 +1,15 @@
#!/usr/bin/env bash
-# ops-suggest-specialized-agent — PreToolUse hook on Agent (silent + autonomous).
-#
-# When subagent_type=general-purpose:
-# 1. Load user-extensible keyword map (claude-ops/config/specialist-keywords.example.json
-# with override at ~/.claude/plugins/data/ops-ops-marketplace/specialist-keywords.json).
-# 2. First regex match → verify the agent exists installed → silent swap via updatedInput.
-# 3. No match → fire-and-forget Haiku drafts a new ~/.claude/agents/<name>.md.
-# Current call proceeds as general-purpose (no block).
+# ops-suggest-specialized-agent — PreToolUse hook (silent + autonomous, backgrounded).
+# Fast-return on disabled or non-general-purpose agents.
set -e
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
. "$PLUGIN_ROOT/scripts/lib/deploy-fix-common.sh" 2>/dev/null || { config() { echo "${2:-}"; }; }
-# Route claude invocations through the credit-pool wrapper when
-# CLAUDE_OPS_USE_CREDIT_POOL=1; otherwise calls claude directly.
-# shellcheck source=../scripts/lib/claude-invoke.sh
-. "$PLUGIN_ROOT/scripts/lib/claude-invoke.sh"
[ "$(config suggest_specialized_agents true)" = "false" ] && exit 0
INPUT=$(cat)
-subagent_type=$(printf '%s' "$INPUT" | jq -r '.tool_input.subagent_type // ""' 2>/dev/null)
-[ "$subagent_type" != "general-purpose" ] && exit 0
+subagent_type=$(printf '%s' "$INPUT" | jq -r '.tool_input.subagent_type // ""' 2>/dev/null || true)
+[ "$subagent_type" = "general-purpose" ] || exit 0
prompt=$(printf '%s' "$INPUT" | jq -r '.tool_input.prompt // ""' 2>/dev/null)
description=$(printf '%s' "$INPUT" | jq -r '.tool_input.description // ""' 2>/dev/null)
diff --git a/claude-ops/bin/ops-welcome b/claude-ops/bin/ops-welcome
index 272ea3d3..bea5206a 100755
--- a/claude-ops/bin/ops-welcome
+++ b/claude-ops/bin/ops-welcome
@@ -7,26 +7,22 @@ set -euo pipefail
PREFS="${CLAUDE_PLUGIN_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}/preferences.json"
[ ! -f "$PREFS" ] || exit 0
-# --- Color setup (degrade gracefully) ---
-if [[ -z "${NO_COLOR:-}" && "${TERM:-dumb}" != "dumb" ]]; then
- RST=$'\033[0m'
- BOLD=$'\033[1m'
- DIM=$'\033[2m'
- CYN=$'\033[36m'
- GRN=$'\033[32m'
- YLW=$'\033[33m'
- WHT=$'\033[37m'
- BCYN=$'\033[1;36m'
- BGRN=$'\033[1;32m'
- BWHT=$'\033[1;37m'
+# Degrade gracefully on dumb terminals or when async
+if [[ -z "${NO_COLOR:-}" && "${TERM:-dumb}" != "dumb" && -t 1 ]]; then
+ RST=$'\033[0m' BOLD=$'\033[1m' DIM=$'\033[2m' CYN=$'\033[36m' GRN=$'\033[32m'
+ YLW=$'\033[33m' WHT=$'\033[37m' BCYN=$'\033[1;36m' BGRN=$'\033[1;32m' BWHT=$'\033[1;37m'
else
RST="" BOLD="" DIM="" CYN="" GRN="" YLW="" WHT="" BCYN="" BGRN="" BWHT=""
fi
-# --- Helpers ---
-D=0.025 # delay between lines
+# Fast path on async (no TTY → skip animation)
+[[ ! -t 1 ]] && {
+ printf "%b" "${BWHT}CLI initialized${RST} — run ${BCYN}/ops:setup${RST} or ${BCYN}/ops:go${RST}\n"
+ exit 0
+}
+
+D=0.025
p() { printf '%s\n' "$1"; sleep "$D"; }
-dp() { sleep "${2:-0.08}"; printf '%s\n' "$1"; }
# --- Blank line spacer ---
p ""
diff --git a/claude-ops/hooks/hooks.json b/claude-ops/hooks/hooks.json
index b6e7fae5..0f9b5513 100644
--- a/claude-ops/hooks/hooks.json
+++ b/claude-ops/hooks/hooks.json
@@ -6,7 +6,8 @@
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-inbox-autosync 2>/dev/null || true",
- "timeout": 5
+ "timeout": 1,
+ "async": true
}
]
}
@@ -16,19 +17,23 @@
"hooks": [
{
"type": "command",
- "command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-welcome 2>/dev/null || true"
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-welcome 2>/dev/null || true",
+ "async": true
},
{
"type": "command",
- "command": "${CLAUDE_PLUGIN_ROOT}/scripts/setup.sh 2>/dev/null | grep '\u2717' | head -3 || true"
+ "command": "${CLAUDE_PLUGIN_ROOT}/scripts/setup.sh 2>/dev/null | grep '\u2717' | head -3 || true",
+ "async": true
},
{
"type": "command",
- "command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/ops-daemon-manager.sh ensure-current --plugin-root ${CLAUDE_PLUGIN_ROOT} 2>/dev/null || true"
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/ops-daemon-manager.sh ensure-current --plugin-root ${CLAUDE_PLUGIN_ROOT} 2>/dev/null || true",
+ "async": true
},
{
"type": "command",
- "command": "CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-post-update-migrate 2>/dev/null || true"
+ "command": "CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-post-update-migrate 2>/dev/null || true",
+ "async": true
}
]
}
@@ -39,7 +44,8 @@
"hooks": [
{
"type": "command",
- "command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-pretool-whatsapp-bridge-health \"$TOOL_INPUT\" 2>/dev/null || true"
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-pretool-whatsapp-bridge-health \"$TOOL_INPUT\" 2>/dev/null || true",
+ "async": true
}
]
},
@@ -49,7 +55,7 @@
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-suggest-specialized-agent 2>/dev/null || true",
- "timeout": 3
+ "timeout": 1
}
]
}
@@ -61,7 +67,7 @@
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-deploy-fix-merge-trigger 2>/dev/null || true",
- "timeout": 5,
+ "timeout": 1,
"if": "Bash(gh pr merge *)"
},
{
@@ -78,7 +84,7 @@
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-task-reminder 2>/dev/null || true",
- "timeout": 3
+ "timeout": 2
}
]
}