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: normalize stale Claude model flags

auroracapital02eee4f16c56
diff --git a/claude-ops/scripts/account-rotation/__tests__/model-args.test.mjs b/claude-ops/scripts/account-rotation/__tests__/model-args.test.mjs
new file mode 100644
index 00000000..f63cd89c
--- /dev/null
+++ b/claude-ops/scripts/account-rotation/__tests__/model-args.test.mjs
@@ -0,0 +1,78 @@
+#!/usr/bin/env node
+import assert from 'node:assert/strict';
+import { chmodSync, mkdtempSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { dirname, join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { spawnSync } from 'node:child_process';
+import { normalizeClaudeModelArgs, normalizeClaudeModelValue } from '../model-args.mjs';
+
+const accountRotationDir = dirname(fileURLToPath(import.meta.url));
+const scriptsDir = dirname(accountRotationDir);
+
+for (const stale of ['fable', 'FABLE', 'fable[1m]', 'claude-fable-5', 'claude-fable-5[1m]']) {
+ assert.equal(normalizeClaudeModelValue(stale), 'claude-opus-4-6');
+}
+
+for (const supported of ['opus', 'opus[1m]', 'claude-opus-4-6', 'claude-sonnet-4-6', 'claude-haiku-4-5']) {
+ assert.equal(normalizeClaudeModelValue(supported), supported);
+}
+
+assert.deepEqual(normalizeClaudeModelArgs(['-p', 'hello', '--model', 'fable[1m]', '--effort', 'high']), [
+ '-p',
+ 'hello',
+ '--model',
+ 'claude-opus-4-6',
+ '--effort',
+ 'high',
+]);
+assert.deepEqual(normalizeClaudeModelArgs(['--model=claude-fable-5', '--model', 'claude-sonnet-4-6']), [
+ '--model=claude-opus-4-6',
+ '--model',
+ 'claude-sonnet-4-6',
+]);
+
+const temp = mkdtempSync(join(tmpdir(), 'launch-claude-model-'));
+const fakeClaude = join(temp, 'bin', 'claude');
+const capturedArgs = join(temp, 'captured-args.json');
+mkdirSync(dirname(fakeClaude), { recursive: true });
+writeFileSync(
+ fakeClaude,
+ `#!/bin/sh\nprintf '%s\\n' "$@" | node -e "const fs=require('fs');const lines=fs.readFileSync(0,'utf8').trimEnd().split('\\n');fs.writeFileSync(process.env.CAPTURED_ARGS,JSON.stringify(lines));"\n`,
+);
+chmodSync(fakeClaude, 0o700);
+const launched = spawnSync(process.execPath, [join(scriptsDir, 'launch-claude.mjs'), 'status', '--model=fable[1m]'], {
+ encoding: 'utf8',
+ env: {
+ ...process.env,
+ HOME: temp,
+ CLAUDE_REAL_BIN: fakeClaude,
+ CAPTURED_ARGS: capturedArgs,
+ ADMISSION_FORCE: '1',
+ },
+});
+assert.equal(launched.status, 0, launched.stderr);
+const launchedArgs = JSON.parse(readFileSync(capturedArgs, 'utf8'));
+assert.equal(launchedArgs.includes('--model=claude-opus-4-6'), true);
+assert.equal(
+ launchedArgs.some((arg) => /fable/i.test(arg)),
+ false,
+);
+
+const launcherSource = readFileSync(join(scriptsDir, 'launch-claude.mjs'), 'utf8');
+assert.match(launcherSource, /const rawArgs = normalizeClaudeModelArgs\(process\.argv\.slice\(2\)\);/);
+assert.ok(
+ launcherSource.indexOf('normalizeClaudeModelArgs(process.argv.slice(2))') <
+ launcherSource.indexOf('spawnSync(CLAUDE_BIN, args'),
+ 'launcher normalizes raw CLI args before spawning Claude',
+);
+
+const respawnSource = readFileSync(join(scriptsDir, 'bg-respawn.mjs'), 'utf8');
+assert.match(respawnSource, /const flags = originalFlags \? normalizeClaudeModelArgs\(originalFlags\) : null;/);
+assert.ok(
+ respawnSource.indexOf('state.respawnFlags = flags') <
+ respawnSource.indexOf("execFileSync(claudeBin(), ['respawn', String(session.id)]"),
+ 'background respawn persists normalized flags before claude respawn',
+);
+
+console.log('Claude model argument normalization tests: PASS');
diff --git a/claude-ops/scripts/account-rotation/bg-respawn.mjs b/claude-ops/scripts/account-rotation/bg-respawn.mjs
index f1002963..ab2161e5 100644
--- a/claude-ops/scripts/account-rotation/bg-respawn.mjs
+++ b/claude-ops/scripts/account-rotation/bg-respawn.mjs
@@ -1,4 +1,5 @@
import { loadClaudeHarnessEnv } from './claude-harness-env.mjs';
+import { normalizeClaudeModelArgs } from './model-args.mjs';
// ── Background-session respawn after rotation ────────────────────────────────
// Daemon-hosted `claude --bg` sessions have no TTY, so the /login-injection
// path in rotate.mjs can never reach them. They also never register in the
@@ -441,11 +442,12 @@ export function doRespawn(session, log, opts = {}) {
// the SOLE authority for CRS routing: add the CRS settings flag iff crsActive,
// remove it otherwise. Persisted to state.json so `claude respawn` re-reads it.
try {
- const flags = Array.isArray(state.respawnFlags) ? [...state.respawnFlags] : null;
+ const originalFlags = Array.isArray(state.respawnFlags) ? state.respawnFlags : null;
+ const flags = originalFlags ? normalizeClaudeModelArgs(originalFlags) : null;
if (flags) {
const isCrsSettingsVal = (v) => typeof v === 'string' && v.endsWith('crs-session-settings.json');
const hasCrsSettings = flags.some((f, i) => f === '--settings' && isCrsSettingsVal(flags[i + 1]));
- let mutated = false;
+ let mutated = flags.some((flag, index) => flag !== originalFlags[index]);
if (!crsActive && hasCrsSettings) {
for (let i = flags.length - 1; i >= 0; i--) {
if (flags[i] === '--settings' && isCrsSettingsVal(flags[i + 1])) {
diff --git a/claude-ops/scripts/account-rotation/launch-claude.mjs b/claude-ops/scripts/account-rotation/launch-claude.mjs
index 57f0d766..1aac9a28 100755
--- a/claude-ops/scripts/account-rotation/launch-claude.mjs
+++ b/claude-ops/scripts/account-rotation/launch-claude.mjs
@@ -1,5 +1,6 @@
#!/usr/bin/env node
import { loadClaudeHarnessEnv } from './claude-harness-env.mjs';
+import { normalizeClaudeModelArgs } from './model-args.mjs';
import { readFileSync, existsSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
import { join, dirname } from 'node:path';
@@ -72,7 +73,7 @@ const CLAUDE_BIN = (() => {
}
return process.platform === 'win32' ? 'claude.exe' : 'claude';
})();
-const rawArgs = process.argv.slice(2);
+const rawArgs = normalizeClaudeModelArgs(process.argv.slice(2));
__admissionAllow(rawArgs);
const CONTROL_SUBCOMMANDS = new Set([
diff --git a/claude-ops/scripts/account-rotation/model-args.mjs b/claude-ops/scripts/account-rotation/model-args.mjs
new file mode 100644
index 00000000..b38b5b72
--- /dev/null
+++ b/claude-ops/scripts/account-rotation/model-args.mjs
@@ -0,0 +1,23 @@
+const UNSUPPORTED_FABLE_MODELS = /^(?:fable|claude-fable-5)(?:\[[^\]]+\])?$/i;
+const CANONICAL_FABLE_REPLACEMENT = 'claude-opus-4-6';
+
+export function normalizeClaudeModelValue(value) {
+ if (typeof value !== 'string' || !UNSUPPORTED_FABLE_MODELS.test(value)) return value;
+ return CANONICAL_FABLE_REPLACEMENT;
+}
+
+export function normalizeClaudeModelArgs(args) {
+ if (!Array.isArray(args)) return args;
+
+ const normalized = [...args];
+ for (let i = 0; i < normalized.length; i += 1) {
+ const arg = normalized[i];
+ if (arg === '--model' && i + 1 < normalized.length) {
+ normalized[i + 1] = normalizeClaudeModelValue(normalized[i + 1]);
+ i += 1;
+ } else if (typeof arg === 'string' && arg.startsWith('--model=')) {
+ normalized[i] = `--model=${normalizeClaudeModelValue(arg.slice('--model='.length))}`;
+ }
+ }
+ return normalized;
+}
diff --git a/claude-ops/tests/run-all.sh b/claude-ops/tests/run-all.sh
index 9b7414d9..0fd6de8e 100755
--- a/claude-ops/tests/run-all.sh
+++ b/claude-ops/tests/run-all.sh
@@ -40,6 +40,7 @@ run_suite "$TESTS_DIR/test-ops-speedup.sh"
run_suite "$TESTS_DIR/test-hooks.sh"
run_suite "$TESTS_DIR/test-specialist-agent-swap.sh"
run_suite "$TESTS_DIR/test-rotate-cliproxy-integration.sh"
+run_suite "$TESTS_DIR/test-model-args.sh"
run_suite "$TESTS_DIR/test-staged-enrollment.sh"
run_suite "$TESTS_DIR/test-coordination-provisioning.sh"
run_suite "$TESTS_DIR/test-template.sh"
diff --git a/claude-ops/tests/test-model-args.sh b/claude-ops/tests/test-model-args.sh
new file mode 100755
index 00000000..a1f92463
--- /dev/null
+++ b/claude-ops/tests/test-model-args.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+set -euo pipefail
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+node "$ROOT/scripts/account-rotation/__tests__/model-args.test.mjs"