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.

Fix hooks duplicate key, rotation scoring, daemon session flag, and state persistence

Cursor Agent655e9601fec7
diff --git a/claude-ops/hooks/hooks.json b/claude-ops/hooks/hooks.json
index c4ffc14b..98f29af2 100644
--- a/claude-ops/hooks/hooks.json
+++ b/claude-ops/hooks/hooks.json
@@ -72,35 +72,6 @@
]
}
],
- "PostToolUse": [
- {
- "matcher": "Bash",
- "hooks": [
- {
- "type": "command",
- "command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-deploy-fix-merge-trigger 2>/dev/null || true",
- "timeout": 5,
- "if": "Bash(gh pr merge *)"
- },
- {
- "type": "command",
- "command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-deploy-fix-build-trigger 2>/dev/null || true",
- "timeout": 5,
- "if": "Bash(npm run build:*)"
- }
- ]
- },
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "bash ${CLAUDE_PLUGIN_ROOT}/bin/ops-task-reminder 2>/dev/null || true",
- "timeout": 3
- }
- ]
- }
- ],
"Stop": [
{
"hooks": [
diff --git a/claude-ops/scripts/account-rotation/daemon.mjs b/claude-ops/scripts/account-rotation/daemon.mjs
index 23953419..688ba056 100644
--- a/claude-ops/scripts/account-rotation/daemon.mjs
+++ b/claude-ops/scripts/account-rotation/daemon.mjs
@@ -508,13 +508,13 @@ async function doRotation(reason) {
try {
// --no-browser: no Chrome, no API calls (works when rate limited)
// --to: daemon controls which account to rotate to (pre-validated token)
- // NO --session: keychain swap only. Running sessions can't accept /login mid-work.
- // When sessions hit the wall they show "not logged in" — user runs /login → instant
- // success because the fresh token is already in the keychain.
- // --session: inject /login into running sessions (safe — keychain token is pre-validated)
- const result = execFileSync(process.execPath, [ROTATE_SCRIPT, '--no-browser', '--session', '--to', targetKey], {
+ // NO --session: keychain swap only. Background rotation must not inject /login
+ // into running sessions — that interrupts active work. When sessions hit the wall
+ // they show "not logged in" — user runs /login → instant success because the fresh
+ // token is already in the keychain.
+ const result = execFileSync(process.execPath, [ROTATE_SCRIPT, '--no-browser', '--to', targetKey], {
cwd: __dirname,
- timeout: 300_000, // 5min — session restart takes ~15s per session × up to 8 sessions
+ timeout: 120_000, // keychain swap only — no session restarts
env: { ...process.env, NODE_NO_WARNINGS: '1' },
}).toString();
log(`Rotation result: ${result.substring(0, 200)}`);
diff --git a/claude-ops/scripts/account-rotation/rotate.mjs b/claude-ops/scripts/account-rotation/rotate.mjs
index dcd1eb36..25f3e1bf 100644
--- a/claude-ops/scripts/account-rotation/rotate.mjs
+++ b/claude-ops/scripts/account-rotation/rotate.mjs
@@ -364,12 +364,14 @@ function pickNextAccount(config, state, liveUtil = {}, opts = {}) {
}
// Score: max of (5h, 7d) — an account is only viable if BOTH windows have
- // headroom. Unknown util → 50 (neutral). Lower is better.
+ // headroom. Both unknown → 50 (neutral). Partial data → 100 (never treat a
+ // missing window as 0%). Lower is better.
function score(a) {
const u5 = getUtil5h(a);
const u7 = getUtil7d(a);
if (u5 === null && u7 === null) return 50;
- return Math.max(u5 ?? 0, u7 ?? 0);
+ if (u5 === null || u7 === null) return 100;
+ return Math.max(u5, u7);
}
// Log + hard-exclude accounts with extra_usage enabled (pay-per-use overage billing).
@@ -2503,6 +2505,7 @@ async function rotate(targetEmail, opts = {}) {
ts: Date.now(),
};
}
+ writeState(state, dryRun);
const next = pickNextAccount(config, state, liveUtil, {
allowExtraUsage: opts.allowExtraUsage === true,
});