plugins/ruflo-cost-tracker/commands/ruflo-cost.md
Cost tracking commands:
cost report [--period today|week|month] -- Generate a cost report for the specified period.
cost-tracking namespace for the periodcost breakdown [--by agent|model|task] -- Detailed cost breakdown by dimension.
cost-tracking namespacecost budget set <amount> -- Set a budget limit in USD (real implementation, persisted to cost-tracking:budget-config).
node plugins/ruflo-cost-tracker/scripts/budget.mjs set <amount> to write the config to the cost-tracking namespacecost budget get -- Show the current budget config.
node plugins/ruflo-cost-tracker/scripts/budget.mjs getcost budget check [--period today|week|month|all] -- Compute utilization + alert level (50/75/90/100% ladder).
node plugins/ruflo-cost-tracker/scripts/budget.mjs checkBUDGET_PERIOD=today|week|month|all (default all)total_cost_usd across all session-* records in cost-trackingbudget check && spawn ... to fail closedcost optimize -- Analyze usage and suggest cost optimizations.
cost-tracking namespacecost track -- Auto-capture token usage for the active Claude Code session and persist to the cost-tracking namespace. Run after significant work or at session end so cost report has real data.
node plugins/ruflo-cost-tracker/scripts/track.mjs (no flags = current cwd's most-recent session)cost-tracking namespace record at key session-<sessionId> (consumed by cost-report step 1)cost outcome <task> <model> <outcome> -- Emit a hooks_model-outcome event so the router learns from applied recommendations. Auto-wired into cost-optimize step 8.
outcome ∈ {success, escalated, failure}node plugins/ruflo-cost-tracker/scripts/outcome.mjs "<task>" <model> <outcome>npx @claude-flow/cli hooks model-outcome -t ... -m ... -o ... with explicit-argv spawnSync so quoting is safecost summary [--format json|markdown] -- Single-shot programmatic dump of all cost data. Other plugins/scripts can shell out and parse the JSON.
node plugins/ruflo-cost-tracker/scripts/summary.mjs --format json--format markdown; JSON contract is stable for programmatic consumerscost federation -- Consumer-side wiring for ADR-097 Phase 3 federation_spend events. Aggregates per-peer 1h/24h/7d rolling windows and flags peers exceeding the suspension threshold (default $5/24h).
node plugins/ruflo-cost-tracker/scripts/federation.mjsFED_FORMAT=json, FED_NAMESPACE=federation-spend, FED_SUSPEND_THRESHOLD_USD=5.0{peerId, taskId, tokensUsed, usdSpent, ts} to the federation-spend namespacecost export [--prometheus <path>] [--webhook <url>] -- Export cost-tracking telemetry to external observability systems.
--prometheus <path> writes the node_exporter textfile-collector format (gauges + counters with session labels)--webhook <url> POSTs JSON; auth via EXPORT_WEBHOOK_HEADER='K: V'cost_tracker_total_usd, cost_tracker_tier_total_usd{tier=...}, cost_tracker_session_total_usd{session=...}, cost_tracker_session_messages{session=...}, cost_tracker_budget_usd, cost_tracker_budget_utilizationcost conversation -- Per-conversation cost view: list every session in cost-tracking with started-at, message count, top model, total cost. Different lens from cost report (which is per-agent/per-model).
node plugins/ruflo-cost-tracker/scripts/conversation.mjsCONV_FORMAT=json, CONV_LIMIT=N, CONV_NAMESPACE=...cost trend -- Read all docs/benchmarks/runs/*.json and surface drift in the gate metrics — win rate, avg latency, p99, escalation rate, speedup vs LLM. Flags regressions the binary smoke gate misses.
node plugins/ruflo-cost-tracker/scripts/trend.mjsTREND_FORMAT=json for machine-readable output, TREND_LIMIT=N to truncatecost benchmark [--llm] [--anthropic] -- Run the corpus benchmark to verify booster claims with measured numbers.
--llm: also run Gemini 2.0 Flash baseline (uses GCP GOOGLE_AI_API_KEY secret)--anthropic: also run Claude Sonnet 4.6 + Opus 4.7 (uses GCP ANTHROPIC_API_KEY secret)docs/benchmarks/runs/latest.json and timestamped siblingwinRate < 0.80. See cost-benchmark skill for env-var overrides.cost workers -- Inspect the optimize and benchmark background workers consumed from ruflo-loop-workers.
mcp__claude-flow__hooks_worker-status --worker optimize -- report last-run timestamp, outcome, and any pending recommendationsmcp__claude-flow__hooks_worker-status --worker benchmark -- report last-run timestamp, outcome, and any pending benchmark deltascost history -- Show cost tracking history over time.
cost-tracking namespace