Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

cost-export — Claude Code skill: what it does, how to install

Exports cost telemetry into Prometheus textfile or webhook JSON formats for external dashboards like Grafana or Datadog.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add ruvnet/ruflo --skill cost-export -a claude-code
Open on GitHub

What cost-export does

The skill pulls session-* and budget-config-* records from the cost-tracking namespace in AgentDB, formatting them for external observability systems. Without this step, spending data stays locked inside the agent storage. Running the underlying export.mjs script with no flags outputs JSON directly to stdout.

Supplying --prometheus <path> writes metrics formatted for the Prometheus node_exporter textfile collector. Emitted values include total dollar spend, per-tier breakdowns, session message counters, and the cost_tracker_budget_utilization gauge. For remote dashboards, --webhook <url> sends the payload as a POST request.

The script produces nothing useful unless cost-track has already populated the records. Custom authorization headers for the webhook payload must be passed through the EXPORT_WEBHOOK_HEADER environment variable.

What it helps with

  • export agent cost metrics into Prometheus textfile format
  • stream session spending payloads to an external webhook endpoint
  • track budget utilization gauges inside Grafana dashboards

Example prompts for the agent

  • Export cost telemetry to Prometheus textfile at /tmp/cost_tracker.prom
  • Send cost tracking JSON payload via webhook to my endpoint

How to install cost-export

1Skills CLI (Vercel)

npx skills add ruvnet/ruflo --skill cost-export -a claude-code

2Manually: put the files in place

~/.claude/skills/cost-export/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cost-export/

From the same set104

The whole set →
ruflo ruvnet This skill adds multi-agent orchestration, memory, routing, and MCP tools to a project. Use it for swarm tasks and multi-step workflows. Claude Code CX Codex Cursor +1 4,000installs Swarm Orchestration ruvnet Skill for managing agent swarms with parallel execution, dynamic topology, and automatic load balancing. Use when a single agent is not enough and you need to orchestrate specialists of different types. Claude Code CX Codex Cursor +1 2,100installs github-project-management ruvnet Turns issue triage and board upkeep into gh and ruv-swarm calls: labels, subtasks, duplicate lookup. Useful when the tracker holds more tickets than order. Claude Code CX Codex Cursor +1 1,400installs github-workflow-automation ruvnet Automates GitHub Actions with AI agent coordination. Generates optimised pipelines, manages pull requests, analyzes failed runs, and deploys updates with risk assessment. Claude Code CX Codex Cursor +1 1,300installs github-code-review ruvnet Runs a swarm of specialized AI agents to inspect GitHub pull requests for security, performance, and architecture issues. Claude Code CX Codex Cursor +1 1,300installs stream-chain ruvnet Chains sequential agent steps together using streaming JSON flow and provides ready-to-run pipelines. Claude Code CX Codex Cursor +1 1,200installs flow-nexus-swarm ruvnet Deploy cloud-based AI agent swarms and define event-driven workflows with message queues. Use it to coordinate tasks, inspect runs, and scale a swarm. Claude Code CX Codex Cursor +1 1,200installs performance-analysis ruvnet Detects bottlenecks in Claude Flow swarms, profiles agent operations, and generates reports with actionable optimization recommendations. Claude Code CX Codex Cursor +1 1,200installs

Similar

git-pushing sickn33 Safely creates Conventional Commits and pushes branch changes using an isolated Git index. It prevents stray dirty files from leaking into remote branches during routine pushes. Claude Code CX Codex Cursor +1 916installs aws-iam aws Verified corrections for the IAM mistakes agents keep making, plus step-by-step workflows for roles and baseline policies. Claude Code CX Codex Cursor +1 10,200installs github-release official github github-release takes a GitHub library through release preparation: it reviews changes, selects a SemVer bump, writes a changelog, and opens a PR. GitHub Copilot 741installs wizard Matt Pocock This skill creates an interactive bash wizard for manual setup steps, CI secrets, third-party dashboards, and one-off migrations. Claude Code 553,369installs hyperframes-cli heygen-com Controls HyperFrames video workflows from the CLI: audits layouts and contrast, edits timeline clips, captures snapshots, and renders locally or in cloud runtimes. Claude Code CX Codex Cursor +1 1,200,000installs setup-pre-commit Matt Pocock This skill configures pre-commit checks for a JavaScript repository, running Prettier, type checking, and tests before each commit. Claude Code 489,289installs using-git-worktrees Jesse Vincent Prepares an isolated workspace before feature work or plan execution. It checks the repository first, then uses native worktree support or Git. Claude Code CX Codex 217,153installs finishing-a-development-branch Jesse Vincent This skill checks the test suite and guides branch completion: merge locally, open a Pull Request, or leave the work in place. Claude Code CX Codex 214,439installs

Questions about cost-export

How to install cost-export in Claude Code?

Run npx skills add ruvnet/ruflo --skill cost-export -a claude-code. The skill file installs to ~/.claude/skills/cost-export/SKILL.md.

What does cost-export do?

It extracts session costs and budget records from AgentDB and formats them as Prometheus gauges or webhook JSON.

What headers can be sent with the webhook?

Set authorization or custom headers using the EXPORT_WEBHOOK_HEADER environment variable as comma-separated key-value pairs.

Source text

SKILL.md · MIT
---
name: cost-export
description: Export cost-tracking telemetry in Prometheus textfile or webhook JSON formats — for external observability (Grafana, Datadog, custom dashboards)
argument-hint: "[--prometheus <path>] [--webhook <url>]"
allowed-tools: Bash
---

# Cost Export

Pulls every `session-*` and `budget-config-*` record from `cost-tracking` and emits in formats consumable by external observability systems. Without this, cost data lives only inside the AgentDB namespace; with it, the same data lights up dashboards.

## When to use

- After any cost-track run, to refresh metrics for Grafana / Datadog / Prometheus.
- Cron-friendly via `/loop 5m` to keep external dashboards near-real-time.
- One-shot to a webhook for ad-hoc reporting (Slack, custom endpoint).

## Steps

1. **Pick a format** — textfile collector for Prometheus / Grafana, or webhook POST for everything else:

   ```bash
   # Prometheus node_exporter textfile collector
   node plugins/ruflo-cost-tracker/scripts/export.mjs --prometheus /var/lib/node_exporter/textfile_collector/cost_tracker.prom

   # Webhook (POSTs JSON; add auth via env)
   EXPORT_WEBHOOK_HEADER='Authorization: Bearer $TOKEN' \
     node plugins/ruflo-cost-tracker/scripts/export.mjs --webhook https://hooks.example.com/cost-tracker

   # Stdout JSON (default if no flag)
   node plugins/ruflo-cost-tracker/scripts/export.mjs
   ```

2. **Inspect what's emitted** — Prometheus output includes:

   ```
   cost_tracker_total_usd                                    <gauge>
   cost_tracker_tier_total_usd{tier="opus|sonnet|haiku"}     <gauge>
   cost_tracker_session_total_usd{session="<8-char>"}        <gauge>
   cost_tracker_session_messages{session="<8-char>"}         <counter>
   cost_tracker_budget_usd                                   <gauge>  (if budget configured)
   cost_tracker_budget_utilization                           <gauge>  (spent / budget)
   ```

3. **Webhook payload shape** — the JSON the webhook receives matches the stdout JSON: `{ exportedAt, sessions: [...], budget, totalUsd, byTier }`. Headers may be added via `EXPORT_WEBHOOK_HEADER='K1: V1, K2: V2'` (comma-separated).

## Env overrides

| Env | Default | Purpose |
|---|---|---|
| `EXPORT_NAMESPACE` | `cost-tracking` | Override target namespace |
| `EXPORT_WEBHOOK_HEADER` | unset | Comma-separated `K: V` pairs for webhook auth |
| `EXPORT_QUIET=1` | unset | Suppress non-error confirmation output |

## Cross-references

- `cost-track` — produces the data this skill exports
- `cost-budget-check` — the same `cost_tracker_budget_*` metrics are alertable in Prometheus
- node_exporter textfile collector docs (Prometheus convention) — drop the `.prom` file in the collector directory and Prometheus picks it up

© ruvnet · MIT · ruvnet/ruflo

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor