New to Claude Skills? Learn how to install them →

ruvnet on GitHub

Cost Federation

Free

Monitor and manage federation spending effectively.

by ruvnet67.6k stars on ruvnet/ruflo
2 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What Cost Federation does

Cost Federation is a skill designed to facilitate the tracking and management of spending in federated computing environments. Specifically, it implements the consumer-side wiring for the ADR-097 Phase 3 specification, which introduces a federation_spend event bus. This event bus publishes data for each completed federation_send, providing insights into the costs associated with federation tasks, including metrics such as tokens used, USD spent, and timestamps.

The skill aggregates spending data on a per-peer basis across different time windows (1 hour, 24 hours, and 7 days). This allows users to monitor costs effectively and identify peers that exceed configured spending thresholds. The integration of this skill is particularly useful for developers and system administrators looking to establish baseline costs before opening federation traffic to new peers or for ongoing monitoring of existing peers.

While the skill is currently in a pre-release state—waiting for the upstream publication of events—it is ready to report a clean status when no events are found. Once the upstream events are available, the skill will automatically activate and provide valuable insights into spending patterns, enabling users to make informed decisions based on real-time data.

This tool is aimed at developers and engineers who need to manage costs in federated systems, especially those who are implementing or transitioning to ADR-097 Phase 3. By using this skill, users can ensure that they are aware of spending behaviors and can react accordingly to prevent overspending or misuse of resources.

When to use it

Use this skill before opening federation traffic to new peers to establish baseline costs, or periodically to monitor spending across existing peers.

When not to use it

This skill may not be suitable for environments not utilizing the ADR-097 framework or where federation spending is not a concern.

What you can build with it

Establishing Baseline Costs

Before integrating a new peer into the federation, use this skill to track and establish baseline costs.

Ongoing Spending Monitoring

Set up periodic checks (e.g., every 5 minutes) to continuously monitor per-peer spending across different time windows.

Verifying Suspension Reasons

After the ADR-097 Phase 3 events are published, use this skill to verify the reasons for suspending peers that exceed spending thresholds.

How to install Cost Federation

View source

1. Install with the skills CLI

npx skills add ruvnet/ruflo/cost-federation --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by ruvnet

Cost Federation

ADR-097 Phase 3 specifies a federation_spend event bus that publishes one event per federation_send completion: {peerId, taskId, tokensUsed, usdSpent, ts}. Cost-tracker is the declared consumer — it aggregates per-peer rolling windows (1h / 24h / 7d) and the federation breaker queries that aggregate to suspend peers exceeding the configured threshold.

Phase 3 isn't landed upstream yet. This skill is the consumer-side wiring; it activates the moment upstream publishes events to the federation-spend namespace. Until then it reports cleanly with a "no events found" notice.

When to use

  • Before opening federation traffic to a new peer — establish baseline.
  • Periodically (e.g. /loop 5m) to monitor per-peer spend across windows.
  • After ADR-097 Phase 2/3 lands — to verify breaker suspension reasoning.

Steps

  1. Run the script:

    node plugins/ruflo-cost-tracker/scripts/federation.mjs
    

    Optional env:

    • FED_FORMAT=json — JSON instead of markdown
    • FED_NAMESPACE=federation-spend — override target namespace
    • FED_SUSPEND_THRESHOLD_USD=5.0 — breaker threshold (ADR-097 default)
  2. Inspect — per-peer 1h/24h/7d windows of count + USD spent, plus a "Suspension threshold check" block flagging peers over the breaker line.

Storage contract (consumer side)

When Phase 3 lands, events should be persisted to namespace federation-spend with key prefix fed-spend- and JSON value matching:

{
  "peerId": "<peer-uuid>",
  "taskId": "<task-uuid>",
  "tokensUsed": 12345,
  "usdSpent": 0.0287,
  "ts": "2026-05-05T..."
}

The script reads any record matching that prefix, regardless of how upstream produces them. Multiple events per peer accumulate cleanly into the rolling-window sums.

Cross-references

  • ADR-097: Federation budget circuit breaker — the complete spec
  • cost-report — same data, different lens (cost-report focuses on local agent spend; this skill on per-peer federated spend)
  • ruflo-federation plugin — the producer side (when Phase 3 lands)

Frequently asked questions about Cost Federation

Similar skills