OpenClaw Cost Guard for Openclaw

A powerful monitoring and budgeting tool for tracking token consumption and USD costs across Openclaw Skills sessions.

dasweltall
v0.1.0
Feb 3, 2026
4
3.6k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install openclaw-cost-guard

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install openclaw-cost-guard using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is OpenClaw Cost Guard?

OpenClaw Cost Guard is an essential utility designed to provide transparent financial oversight for AI agent operations. By parsing session JSONL logs, it extracts real-time token usage and cost data, allowing developers to maintain strict control over their API spend. Whether you are running a single agent or a fleet, this skill ensures you never encounter unexpected billing surprises within the Openclaw Skills ecosystem.

The tool emphasizes data-driven decision-making by offering detailed reports on daily and weekly expenditures. Beyond just reporting, it enables the enforcement of hard budgets and provides a token-saving playbook to guide agents toward more concise, cost-effective interactions. This makes it an indispensable asset for developers who need to balance agent performance with financial efficiency.

OpenClaw Cost Guard Use Cases

  • Monitoring daily and weekly API spend across all agent sessions.
  • Identifying the most expensive sessions to debug token-heavy workflows.
  • Setting up automated budget alerts via cron jobs to prevent cost overruns.
  • Applying token-saving strategies for cost-sensitive environments.
  • Generating JSON reports for custom dashboards and financial analysis in Openclaw Skills.

How OpenClaw Cost Guard Works

  1. The skill accesses local JSONL log files generated by agents during active sessions located in the agents directory.
  2. It extracts usage and cost metadata from each call recorded within the logs.
  3. Users execute CLI scripts with specific flags to filter data by timeframes, such as today, yesterday, or custom day ranges.
  4. If cost data is missing from the provider, the skill applies fallback estimation based on user-defined token pricing for input, output, and cache.
  5. The system compares current spend against a defined budget and issues alerts or exit codes upon breach.

OpenClaw Cost Guard Setup

Ensure your session logs are available in the standard Openclaw Skills directory. You can then use the provided script for various reporting tasks:

# Track costs for the last 7 days
python3 scripts/extract_cost.py --last-days 7

# Set a budget check for today and exit with code 2 if exceeded
python3 scripts/extract_cost.py --today --budget-usd 5

For providers that do not return cost metadata, set your pricing via environment variables:

export PRICE_INPUT=1.75
export PRICE_OUTPUT=14
python3 scripts/extract_cost.py --today

OpenClaw Cost Guard Data Schema & Taxonomy

The skill organizes reporting data by parsing the JSONL session logs. The following data points are prioritized:

Attribute Description
usage.cost The primary metric for real USD spend reported by the API.
usage.tokens Detailed breakdown of input, output, and cache tokens.
session_id Derived from the folder structure to group costs by task.
timestamp Used to aggregate daily and weekly summary reports.

OpenClaw Cost Guard Advanced Features

  • Automated budget enforcement with specific exit codes for integration into alerting systems.
  • Token-saving playbook that instructs the AI to use bullet points, limit response length, and batch tool calls.
  • Progressive disclosure techniques to minimize output tokens unless specifically requested by the user.
  • Hard limits on web iterations and tool calls to prevent runaway loops in Openclaw Skills.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*