Fleet Auditor: Cross-Platform Agent Token Waste Auditor Detects installed agent systems, collects token usage data, identifies waste patterns, and recommends fixes with dollar savings estimates. Everyone tracks. Nobody coaches. Until now. Use when : Running multiple agent systems, spending $2-5/day on agents, suspecting idle heartbeats are burning tokens, or want a cross-system cost audit. --- Phase 0: Initialize 1. Resolve runtime and fleet.py path (works for both skill and plugin installs): Use for all subsequent fleet.py calls. 2. Detect systems : Parse the JSON output. Report what was fou…

+ n.toLocaleString(undefined, {{maximumFractionDigits:0}}) : '

Fleet Auditor: Cross-Platform Agent Token Waste Auditor Detects installed agent systems, collects token usage data, identifies waste patterns, and recommends fixes with dollar savings estimates. Everyone tracks. Nobody coaches. Until now. Use when : Running multiple agent systems, spending $2-5/day on agents, suspecting idle heartbeats are burning tokens, or want a cross-system cost audit. --- Phase 0: Initialize 1. Resolve runtime and fleet.py path (works for both skill and plugin installs): Use for all subsequent fleet.py calls. 2. Detect systems : Parse the JSON output. Report what was fou…

+ n.toFixed(2); }}\n\n// Nav switching\ndocument.querySelectorAll('.nav-item[data-view]').forEach(function(lnk) {{\n lnk.addEventListener('click', function(e) {{\n e.preventDefault();\n var v = this.getAttribute('data-view');\n document.querySelectorAll('.view').forEach(function(el) {{ el.classList.remove('active'); }});\n document.querySelectorAll('.nav-item').forEach(function(n) {{ n.classList.remove('active'); }});\n var target = document.getElementById('view-' + v);\n if (target) target.classList.add('active');\n this.classList.add('active');\n document.querySelector('.main-col').scrollTop = 0;\n }});\n}});\n\n// Daily cost chart\n(function() {{\n var chart = document.getElementById('daily-chart');\n var labels = document.getElementById('daily-labels');\n if (!chart || !dailyData.length) return;\n\n // Aggregate by date\n var byDate = {{}};\n dailyData.forEach(function(d) {{\n byDate[d.date] = (byDate[d.date] || 0) + d.cost;\n }});\n var dates = Object.keys(byDate).sort();\n var maxCost = Math.max.apply(null, dates.map(function(d) {{ return byDate[d]; }})) || 1;\n\n dates.forEach(function(date) {{\n var bar = document.createElement('div');\n bar.className = 'bar';\n bar.style.height = Math.max(2, (byDate[date] / maxCost) * 100) + '%';\n bar.title = date + ': ' + fmtCost(byDate[date]);\n chart.appendChild(bar);\n }});\n\n if (dates.length > 0) {{\n labels.innerHTML = '\u003cspan>' + dates[0] + '\u003c/span>\u003cspan>' + dates[dates.length - 1] + '\u003c/span>';\n }}\n\n // Runs chart\n var runsChart = document.getElementById('runs-chart');\n var runsLabels = document.getElementById('runs-labels');\n if (!runsChart) return;\n var byDateRuns = {{}};\n dailyData.forEach(function(d) {{\n byDateRuns[d.date] = (byDateRuns[d.date] || 0) + d.runs;\n }});\n var maxRuns = Math.max.apply(null, dates.map(function(d) {{ return byDateRuns[d] || 0; }})) || 1;\n dates.forEach(function(date) {{\n var bar = document.createElement('div');\n bar.className = 'bar';\n bar.style.height = Math.max(2, ((byDateRuns[date] || 0) / maxRuns) * 100) + '%';\n bar.style.background = '#3b82f6';\n bar.title = date + ': ' + (byDateRuns[date] || 0) + ' runs';\n runsChart.appendChild(bar);\n }});\n if (dates.length > 0) {{\n runsLabels.innerHTML = '\u003cspan>' + dates[0] + '\u003c/span>\u003cspan>' + dates[dates.length - 1] + '\u003c/span>';\n }}\n}})();\n\n// Model mix\n(function() {{\n var container = document.getElementById('model-mix-content');\n if (!container) return;\n var html = '';\n var modelColors = {{ opus: '#a855f7', sonnet: '#3b82f6', haiku: '#22c55e' }};\n\n for (var sys in modelData) {{\n var models = modelData[sys];\n var totalCost = 0;\n models.forEach(function(m) {{ totalCost += m.cost; }});\n if (totalCost \u003c= 0) continue;\n\n html += '\u003cdiv style=\"margin-bottom: var(--s-3);\">\u003cdiv style=\"font-size:13px;color:var(--c-text-dim);margin-bottom:4px;\">' + esc(sys) + '\u003c/div>';\n html += '\u003cdiv class=\"model-bar\">';\n models.forEach(function(m) {{\n var pct = (m.cost / totalCost * 100).toFixed(1);\n var cls = m.model.replace(/[^a-z0-9-]/g, '');\n html += '\u003cdiv class=\"model-segment ' + cls + '\" style=\"width:' + pct + '%\" title=\"' + esc(m.model) + ': ' + pct + '% (' + fmtCost(m.cost) + ')\">\u003c/div>';\n }});\n html += '\u003c/div>\u003cdiv class=\"model-legend\">';\n models.forEach(function(m) {{\n var pct = (m.cost / totalCost * 100).toFixed(0);\n var cls = m.model.replace(/[^a-z0-9-]/g, '');\n html += '\u003cdiv class=\"model-legend-item\">\u003cdiv class=\"model-legend-dot ' + cls + '\">\u003c/div>' + esc(m.model) + ' ' + pct + '% (' + fmtCost(m.cost) + ')\u003c/div>';\n }});\n html += '\u003c/div>\u003c/div>';\n }}\n\n container.innerHTML = html || '\u003cdiv class=\"empty-state\" style=\"padding:var(--s-3);\">No model data.\u003c/div>';\n}})();\n\u003c/script>\n\u003c/body>\n\u003c/html>'''\n\n\ndef _open_in_browser(path: Path):\n \"\"\"Open a file in the default browser.\"\"\"\n import subprocess\n import platform as _platform\n system = _platform.system()\n if system == \"Darwin\":\n subprocess.run([\"open\", str(path)], check=False)\n elif system == \"Linux\":\n subprocess.run([\"xdg-open\", str(path)], check=False)\n elif system == \"Windows\":\n subprocess.run([\"start\", str(path)], shell=True, check=False)\n\n\ndef _serve_dashboard(host: str, port: int):\n \"\"\"Serve the fleet dashboard over HTTP.\"\"\"\n import http.server\n import functools\n\n handler = functools.partial(\n http.server.SimpleHTTPRequestHandler,\n directory=str(FLEET_DASHBOARD_PATH.parent),\n )\n with http.server.HTTPServer((host, port), handler) as server:\n print(f\" Serving fleet dashboard at http://{host}:{port}/fleet-dashboard.html\")\n print(\" Press Ctrl+C to stop.\")\n try:\n server.serve_forever()\n except KeyboardInterrupt:\n print(\"\\n Server stopped.\")\n\n\n# ===================================================================\n# CLI ENTRY POINT\n# ===================================================================\n\ndef fleet_cli(args: list[str] | None = None):\n \"\"\"Main CLI entry point. Can be called from measure.py via lazy import.\"\"\"\n if args is None:\n args = sys.argv[1:]\n\n if not args or args[0] == \"--help\" or args[0] == \"-h\":\n print(\"\"\"\n Fleet Auditor: Cross-Platform Agent Token Waste Auditor\n\n Commands:\n detect Detect installed agent systems\n scan [--system X] [--days 30] Collect agent runs into fleet.db\n audit [--system X] [--days 30] Run waste pattern detection\n report [--system X] [--json] Full report with cost breakdown\n dashboard [--serve] Generate and open fleet dashboard\n\n Flags:\n --json Output as JSON\n --days N Look back N days (default: 30)\n --system X Filter to one system (claude, openclaw, hermes, etc.)\n --serve Start HTTP server for dashboard\n --quiet, -q Suppress non-essential output\n\"\"\")\n return\n\n cmd = args[0]\n cmd_args = args[1:]\n\n if cmd == \"detect\":\n cmd_detect(cmd_args)\n elif cmd == \"scan\":\n cmd_scan(cmd_args)\n elif cmd == \"audit\":\n cmd_audit(cmd_args)\n elif cmd == \"report\":\n cmd_report(cmd_args)\n elif cmd == \"dashboard\":\n cmd_dashboard(cmd_args)\n else:\n print(f\" Unknown command: {cmd}\")\n print(\" Run 'fleet.py --help' for usage.\")\n sys.exit(1)\n\n\nif __name__ == \"__main__\":\n fleet_cli()\n","content_type":"text/x-python; charset=utf-8","language":"python","size":112359,"content_sha256":"d2a62392ca9f874cd791d663edd15be80499c36c8ba828b8cfde95adf9dc93e6"},{"filename":"scripts/shared.py","content":"\"\"\"Shared utilities for Token Optimizer fleet and measurement tools.\n\nExtracted from measure.py to prevent duplicate maintenance of JSONL parsing,\nmodel normalization, SQLite initialization, and file discovery patterns.\n\nZero external dependencies. Python 3.10+ (for match/case and type unions).\n\"\"\"\n\nfrom __future__ import annotations # PEP 604 union syntax compat for Python 3.9\n\nimport json\nimport re\nimport sqlite3\nfrom datetime import datetime\nfrom pathlib import Path\n\n# ---------------------------------------------------------------------------\n# Constants\n# ---------------------------------------------------------------------------\n\nHOME = Path.home()\nCLAUDE_DIR = HOME / \".claude\"\nCHARS_PER_TOKEN = 4.0\n\n# ---------------------------------------------------------------------------\n# Model normalization\n# ---------------------------------------------------------------------------\n\ndef normalize_model_name(model_id: str) -> str | None:\n \"\"\"Collapse model IDs like 'claude-sonnet-4-6' into 'sonnet'.\n\n Returns None for synthetic/internal model IDs that should be skipped.\n Handles non-Claude models (gpt-4o, gemini, etc.) by returning as-is.\n \"\"\"\n if not model_id or model_id.startswith(\"\u003c\"):\n return None\n m = model_id.lower()\n # Match OpenClaw behavior: provider-qualified IDs like openai/gpt-4o,\n # openrouter/openai/gpt-4o, or anthropic:claude-sonnet-4-6 should price as\n # their underlying model.\n while re.match(r\"^[a-z0-9_.-]+[/:]\", m):\n m = re.sub(r\"^[a-z0-9_.-]+[/:]\", \"\", m, count=1)\n if \"opus\" in m:\n return \"opus\"\n if \"sonnet\" in m:\n return \"sonnet\"\n if \"haiku\" in m:\n return \"haiku\"\n # OpenAI GPT-5 family (most-specific first to prevent prefix shadowing)\n for alias in (\n \"gpt-5.5-pro\",\n \"gpt-5.4-mini\",\n \"gpt-5.4-nano\",\n \"gpt-5.1-codex-mini\",\n \"gpt-5.1-codex\",\n \"gpt-5.3-codex\",\n \"gpt-5.2-codex\",\n \"gpt-5-codex\",\n \"gpt-5.5\",\n \"gpt-5.4\",\n \"gpt-5.2\",\n \"gpt-5.1\",\n \"gpt-4.1-mini\",\n \"gpt-4.1-nano\",\n \"gpt-4.1\",\n \"gpt-4o-mini\",\n \"gpt-4o\",\n \"o3-pro\",\n \"o3-mini\",\n \"o4-mini\",\n \"o3\",\n ):\n if m == alias or m.startswith(alias + \"-\"):\n return alias\n for alias in (\n \"gemini-3.1-pro-preview\",\n \"gemini-3.1-flash-lite\",\n \"gemini-3.5-flash\",\n \"gemini-2.5-flash-lite\",\n \"gemini-2.5-flash\",\n \"gemini-2.5-pro\",\n ):\n if m == alias or m.startswith(alias + \"-\"):\n return alias\n return m\n\n\n# ---------------------------------------------------------------------------\n# JSONL streaming parser\n# ---------------------------------------------------------------------------\n\ndef iter_jsonl(filepath: Path):\n \"\"\"Yield parsed JSON objects from a JSONL file, skipping bad lines.\n\n Handles corrupted UTF-8, permission errors, and malformed JSON gracefully.\n \"\"\"\n try:\n with open(filepath, \"r\", encoding=\"utf-8\", errors=\"replace\") as f:\n for line in f:\n try:\n yield json.loads(line)\n except json.JSONDecodeError:\n continue\n except (PermissionError, OSError):\n return\n\n\ndef parse_timestamp(ts_str: str | None) -> datetime | None:\n \"\"\"Parse an ISO-8601 timestamp string, handling 'Z' suffix.\"\"\"\n if not ts_str:\n return None\n try:\n return datetime.fromisoformat(ts_str.replace(\"Z\", \"+00:00\"))\n except (ValueError, TypeError):\n return None\n\n\n# ---------------------------------------------------------------------------\n# Claude Code JSONL file discovery\n# ---------------------------------------------------------------------------\n\ndef find_claude_jsonl_files(days: int = 30) -> list[tuple[Path, float, str]]:\n \"\"\"Find all Claude Code JSONL session files within a day window.\n\n Returns list of (filepath, mtime, project_dir_name) sorted newest-first.\n \"\"\"\n projects_base = CLAUDE_DIR / \"projects\"\n if not projects_base.exists():\n return []\n\n cutoff = datetime.now().timestamp() - (days * 86400)\n results = []\n for project_dir in projects_base.iterdir():\n if not project_dir.is_dir():\n continue\n for jf in project_dir.glob(\"*.jsonl\"):\n try:\n mtime = jf.stat().st_mtime\n if mtime >= cutoff:\n results.append((jf, mtime, project_dir.name))\n except OSError:\n continue\n results.sort(key=lambda x: x[1], reverse=True)\n return results\n\n\ndef find_subagent_jsonl_files(session_jsonl_path: Path) -> list[Path]:\n \"\"\"Find subagent JSONL files for a given session.\n\n Claude Code stores subagent logs in {session-uuid}/subagents/*.jsonl\n next to the parent {session-uuid}.jsonl file.\n \"\"\"\n subagent_dir = session_jsonl_path.parent / session_jsonl_path.stem / \"subagents\"\n if not subagent_dir.is_dir():\n return []\n results = []\n for jf in subagent_dir.glob(\"*.jsonl\"):\n try:\n if jf.stat().st_size > 0:\n results.append(jf)\n except OSError:\n continue\n return results\n\n\n# ---------------------------------------------------------------------------\n# Project name cleanup\n# ---------------------------------------------------------------------------\n\ndef clean_project_name(raw_project: str) -> str:\n \"\"\"Map Claude Code dashed directory names to human-readable labels.\n\n e.g. '-Users-jane' -> 'home'\n '-Users-jane-projects-acme-api' -> 'acme/api'\n \"\"\"\n if not raw_project:\n return \"unknown\"\n cleaned = re.sub(r\"^-Users-[^-]+-?\", \"\", raw_project)\n if not cleaned:\n return \"home\"\n parts = [p for p in cleaned.split(\"-\") if p]\n if not parts:\n return \"home\"\n if len(parts) > 2:\n return \"/\".join(parts[-2:])\n return \"/\".join(parts)\n\n\n# ---------------------------------------------------------------------------\n# SQLite initialization\n# ---------------------------------------------------------------------------\n\ndef init_sqlite_db(db_path: Path, schema: str, wal: bool = True) -> sqlite3.Connection:\n \"\"\"Initialize a SQLite database with schema and pragmas.\n\n Uses WAL mode and busy_timeout by default (same pattern as measure.py).\n \"\"\"\n db_path.parent.mkdir(parents=True, exist_ok=True)\n conn = sqlite3.connect(str(db_path))\n if wal:\n conn.execute(\"PRAGMA journal_mode=WAL\")\n conn.execute(\"PRAGMA busy_timeout=5000\")\n conn.executescript(schema)\n return conn\n\n\ndef migrate_add_columns(conn: sqlite3.Connection, table: str, columns: dict[str, str]):\n \"\"\"Add columns to a table if they don't already exist.\n\n columns: dict of {column_name: column_type} e.g. {\"slug\": \"TEXT\", \"score\": \"REAL\"}\n \"\"\"\n try:\n existing = {r[1] for r in conn.execute(f\"PRAGMA table_info({table})\").fetchall()}\n for col_name, col_type in columns.items():\n if col_name not in existing:\n conn.execute(f\"ALTER TABLE {table} ADD COLUMN {col_name} {col_type}\")\n conn.commit()\n except sqlite3.Error:\n pass\n\n\n# ---------------------------------------------------------------------------\n# Token estimation\n# ---------------------------------------------------------------------------\n\ndef estimate_tokens_from_text(text: str) -> int:\n \"\"\"Estimate token count from text content (character count / 4).\"\"\"\n return int(len(text) / CHARS_PER_TOKEN)\n\n\ndef estimate_tokens_from_file(filepath: Path) -> int:\n \"\"\"Estimate tokens by reading file content.\"\"\"\n try:\n with open(filepath, \"r\", encoding=\"utf-8\", errors=\"replace\") as f:\n content = f.read()\n return int(len(content) / CHARS_PER_TOKEN)\n except (PermissionError, OSError):\n return 0\n","content_type":"text/x-python; charset=utf-8","language":"python","size":7882,"content_sha256":"1912362d35e9ac4fce37f87ad8355c0c772d474cdf31395a10470b276a1280d0"}],"content_json":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"text":"Fleet Auditor: Cross-Platform Agent Token Waste Auditor","type":"text"}]},{"type":"paragraph","content":[{"text":"Detects installed agent systems, collects token usage data, identifies waste patterns, and recommends fixes with dollar savings estimates. Everyone tracks. Nobody coaches. Until now.","type":"text"}]},{"type":"paragraph","content":[{"text":"Use when","type":"text","marks":[{"type":"strong"}]},{"text":": Running multiple agent systems, spending $2-5/day on agents, suspecting idle heartbeats are burning tokens, or want a cross-system cost audit.","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 0: Initialize","type":"text"}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Resolve runtime and fleet.py path","type":"text","marks":[{"type":"strong"}]},{"text":" (works for both skill and plugin installs):","type":"text"}]}]}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"RUNTIME=\"${TOKEN_OPTIMIZER_RUNTIME:-}\"\nif [ -z \"$RUNTIME\" ]; then\n if [ -n \"$CLAUDE_PLUGIN_ROOT\" ] || [ -n \"$CLAUDE_PLUGIN_DATA\" ]; then\n RUNTIME=\"claude\"\n elif [ -n \"$CODEX_HOME\" ] || [ -d \"$HOME/.codex\" ]; then\n RUNTIME=\"codex\"\n else\n RUNTIME=\"claude\"\n fi\nfi\n\nFLEET_PY=\"\"\nfor f in \"$HOME/.codex/skills/fleet-auditor/scripts/fleet.py\" \\\n \"$HOME/.codex/plugins/cache\"/*/token-optimizer/*/skills/fleet-auditor/scripts/fleet.py \\\n \"$HOME/.claude/skills/fleet-auditor/scripts/fleet.py\" \\\n \"$HOME/.claude/plugins/cache\"/*/token-optimizer/*/skills/fleet-auditor/scripts/fleet.py; do\n [ -f \"$f\" ] && FLEET_PY=\"$f\" && break\ndone\n[ -z \"$FLEET_PY\" ] && { echo \"[Error] fleet.py not found. Is Fleet Auditor installed?\"; exit 1; }\necho \"Using: $FLEET_PY\"\nexport TOKEN_OPTIMIZER_RUNTIME=\"$RUNTIME\"","type":"text"}]},{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"$FLEET_PY","type":"text","marks":[{"type":"code_inline"}]},{"text":" for all subsequent fleet.py calls.","type":"text"}]},{"type":"ordered_list","attrs":{"order":2,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Detect systems","type":"text","marks":[{"type":"strong"}]},{"text":":","type":"text"}]}]}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python3 \"$FLEET_PY\" detect --json","type":"text"}]},{"type":"paragraph","content":[{"text":"Parse the JSON output. Report what was found.","type":"text"}]},{"type":"paragraph","content":[{"text":"If nothing detected, explain: \"No agent systems found. Fleet Auditor supports: Claude Code, Codex, OpenClaw, NanoClaw, Hermes, OpenCode, IronClaw.\"","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 1: Scan","type":"text"}]},{"type":"paragraph","content":[{"text":"Collect token usage data from detected systems:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python3 \"$FLEET_PY\" scan --days 30","type":"text"}]},{"type":"paragraph","content":[{"text":"Report how many runs were collected per system. If this is the first scan, it may take a moment to parse all session files.","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 2: Audit","type":"text"}]},{"type":"paragraph","content":[{"text":"Run waste pattern detection:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python3 \"$FLEET_PY\" audit --json","type":"text"}]},{"type":"paragraph","content":[{"text":"Parse the JSON output. Present findings ordered by severity and monthly savings.","type":"text"}]},{"type":"paragraph","content":[{"text":"If no waste found: \"Your fleet looks clean. No significant waste patterns detected.\"","type":"text"}]},{"type":"paragraph","content":[{"text":"For Codex findings, be careful with dollars: if a model's pricing is not in the local pricing table, present token waste confidently and say dollar impact depends on current model pricing instead of inventing a cost.","type":"text"}]},{"type":"paragraph","content":[{"text":"OpenClaw Security + Cost Check","type":"text","marks":[{"type":"strong"}]},{"text":" (March 2026):","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"If OpenClaw is detected and version \u003c 2026.3.12: flag as HIGH severity. 31 CVEs including ClawJacked (full agent takeover). Compromised instances run rogue agents that burn tokens undetected. Recommend immediate upgrade.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Check for ClawHub skills matching ClawHavoc campaign patterns (1,184+ malicious skills). These skills exfiltrate data via extra API calls, inflating token spend.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Flag if gateway rate limiting is disabled (CVE-2026-25253). Without it, brute-force attacks can spawn unlimited agent sessions. Recommend: ","type":"text"},{"text":"openclaw config set security.rateLimit.enabled true","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 3: Present Findings","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"[Fleet Auditor Results]\n\nSYSTEMS DETECTED\n- Claude Code: X runs ($Y.YY)\n- Codex: X runs ($Y.YY)\n- OpenClaw: X runs ($Y.YY)\n\nWASTE PATTERNS FOUND\n1. [SEVERITY] Description\n Est. savings: $X.XX/month\n Fix: recommendation\n\n2. [SEVERITY] Description\n ...\n\nTOTAL POTENTIAL SAVINGS: $X.XX/month\n\nReady to act? I can:\n1. Show detailed fix snippets for each finding\n2. Generate the fleet dashboard for visual analysis\n3. Run /token-optimizer for deeper Claude Code optimization","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 4: Dashboard (optional)","type":"text"}]},{"type":"paragraph","content":[{"text":"If user wants visual analysis:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python3 \"$FLEET_PY\" dashboard","type":"text"}]},{"type":"paragraph","content":[{"text":"This generates ","type":"text"},{"text":"~/.claude/_backups/token-optimizer/fleet-dashboard.html","type":"text","marks":[{"type":"code_inline"}]},{"text":" in Claude Code, or ","type":"text"},{"text":"~/.codex/_backups/token-optimizer/fleet-dashboard.html","type":"text","marks":[{"type":"code_inline"}]},{"text":" when ","type":"text"},{"text":"TOKEN_OPTIMIZER_RUNTIME=codex","type":"text","marks":[{"type":"code_inline"}]},{"text":".","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 5: Deep Dive (optional)","type":"text"}]},{"type":"paragraph","content":[{"text":"For Claude Code specifically, offer ","type":"text"},{"text":"/token-optimizer","type":"text","marks":[{"type":"code_inline"}]},{"text":" for full audit (","type":"text"},{"text":"CLAUDE.md","type":"text","marks":[{"type":"code_inline"}]},{"text":", skills, MCP, hooks, etc.).","type":"text"}]},{"type":"paragraph","content":[{"text":"For Codex specifically, offer ","type":"text"},{"text":"token-optimizer","type":"text","marks":[{"type":"code_inline"}]},{"text":" for full audit (","type":"text"},{"text":"AGENTS.md","type":"text","marks":[{"type":"code_inline"}]},{"text":", Codex memories, plugin skills, MCP, balanced hooks, compact prompt, status line).","type":"text"}]},{"type":"paragraph","content":[{"text":"For other systems, show the fix snippets from the audit and guide the user through implementing them.","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Reference Files","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Phase","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Read","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Adapter development","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/fleet-systems.md","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Detector development","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/waste-patterns.md","type":"text","marks":[{"type":"code_inline"}]}]}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Error Handling","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"No systems detected","type":"text","marks":[{"type":"strong"}]},{"text":": Report cleanly, list supported systems","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Empty scan results","type":"text","marks":[{"type":"strong"}]},{"text":": System detected but no session data in window. Suggest increasing ","type":"text"},{"text":"--days","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Permission errors","type":"text","marks":[{"type":"strong"}]},{"text":": Report which files couldn't be read, continue with available data","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Corrupted data","type":"text","marks":[{"type":"strong"}]},{"text":": Skip bad files, report count of skipped files","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"fleet.py not found","type":"text","marks":[{"type":"strong"}]},{"text":": Check both skill and plugin install paths","type":"text"}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Core Rules","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Quantify everything in dollars AND tokens","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Never read or expose message content (privacy-first)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Report confidence levels alongside findings","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Suppress findings below 0.4 confidence threshold","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Always show fix snippets with recommendations","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Frame savings as monthly recurring, not one-time","type":"text"}]}]}]},{"type":"hr","attrs":{"markup":"---"}}]},"metadata":{"date":"2026-06-05","name":"fleet-auditor","author":"@skillopedia","source":{"stars":1181,"repo_name":"token-optimizer","origin_url":"https://github.com/alexgreensh/token-optimizer/blob/HEAD/skills/fleet-auditor/SKILL.md","repo_owner":"alexgreensh","body_sha256":"8037e863851b1b6701f8807d9b2e55e3d7e53c78b4127531b9a49e31605cc4be","cluster_key":"8857dd24aa977122e123f711009268ba79d6633fefe68248cadc470a68863379","clean_bundle":{"format":"clean-skill-bundle-v1","source":"alexgreensh/token-optimizer/skills/fleet-auditor/SKILL.md","attachments":[{"id":"33cc0b9b-f75e-51a3-b190-b9003a79c817","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/33cc0b9b-f75e-51a3-b190-b9003a79c817/attachment.md","path":"references/fleet-systems.md","size":3767,"sha256":"078dbfe73bd3b86b03b65655c61a2d8bf84d95df9861c454ea753aba416e4fdb","contentType":"text/markdown; charset=utf-8"},{"id":"ce271efe-9aea-5653-ae3a-c0c3d307ca6b","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/ce271efe-9aea-5653-ae3a-c0c3d307ca6b/attachment.md","path":"references/waste-patterns.md","size":4614,"sha256":"3e5203b719acb1d4fed1a6d742c3bcae08f4f64f2210cd566f2e95bec5c34249","contentType":"text/markdown; charset=utf-8"},{"id":"9489de1c-165b-5586-bb77-24283e7385d8","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/9489de1c-165b-5586-bb77-24283e7385d8/attachment.py","path":"scripts/fleet.py","size":112359,"sha256":"d2a62392ca9f874cd791d663edd15be80499c36c8ba828b8cfde95adf9dc93e6","contentType":"text/x-python; charset=utf-8"},{"id":"d92756d1-f4c3-5182-b8d8-427476e189dd","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/d92756d1-f4c3-5182-b8d8-427476e189dd/attachment.py","path":"scripts/shared.py","size":7882,"sha256":"1912362d35e9ac4fce37f87ad8355c0c772d474cdf31395a10470b276a1280d0","contentType":"text/x-python; charset=utf-8"}],"bundle_sha256":"b90570054f02d966186ecfa54902f722ea9771598fcce30ac22361cf43085631","attachment_count":4,"text_attachments":4,"attachment_storage":"skillopedia-attachments-v1","binary_attachments":0,"excluded_attachments":[]},"cluster_size":1,"skill_md_path":"skills/fleet-auditor/SKILL.md","import_metadata":{"date":"2026-06-05","author":"@skillopedia","version":"v1","category":"security","category_label":"Security"},"exact_dupes_collapsed_into_this":0},"version":"v1","category":"security","import_tag":"clean-skills-v1","description":"Audit token waste across agent systems (Claude Code, Codex, OpenClaw, Hermes, OpenCode). Detect idle burns, model misrouting, and config bloat with dollar savings."}},"renderedAt":1782987336535}

Fleet Auditor: Cross-Platform Agent Token Waste Auditor Detects installed agent systems, collects token usage data, identifies waste patterns, and recommends fixes with dollar savings estimates. Everyone tracks. Nobody coaches. Until now. Use when : Running multiple agent systems, spending $2-5/day on agents, suspecting idle heartbeats are burning tokens, or want a cross-system cost audit. --- Phase 0: Initialize 1. Resolve runtime and fleet.py path (works for both skill and plugin installs): Use for all subsequent fleet.py calls. 2. Detect systems : Parse the JSON output. Report what was fou…