openclaw-cost-guard

Track OpenClaw/Clawdbot token and cost usage from session JSONL logs (prefer real usage.cost when present), generate daily/weekly summaries and top expensive sessions, and run budget checks (exit code on breach). Use to monitor spend, enforce budgets via cron/alerts, and apply a token-saving playbook to reduce output/tool-call cost.

7 stars

Best use case

openclaw-cost-guard is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Track OpenClaw/Clawdbot token and cost usage from session JSONL logs (prefer real usage.cost when present), generate daily/weekly summaries and top expensive sessions, and run budget checks (exit code on breach). Use to monitor spend, enforce budgets via cron/alerts, and apply a token-saving playbook to reduce output/tool-call cost.

Teams using openclaw-cost-guard should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/openclaw-cost-guard/SKILL.md --create-dirs "https://raw.githubusercontent.com/Demerzels-lab/elsamultiskillagent/main/public/skills/dasweltall/openclaw-cost-guard/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/openclaw-cost-guard/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How openclaw-cost-guard Compares

Feature / Agentopenclaw-cost-guardStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Track OpenClaw/Clawdbot token and cost usage from session JSONL logs (prefer real usage.cost when present), generate daily/weekly summaries and top expensive sessions, and run budget checks (exit code on breach). Use to monitor spend, enforce budgets via cron/alerts, and apply a token-saving playbook to reduce output/tool-call cost.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# OpenClaw Cost Guard

Use this skill when you need:
- **accurate cost reports** (daily/weekly/lifetime)
- **top expensive sessions**
- **guardrails to reduce token burn** (without changing config unless user asks)

## 1) Data source (important)

Prefer **session JSONL** logs (they contain per-call `usage`, often with **real USD cost**):
- OpenClaw: `~/.openclaw/agents/*/sessions/*.jsonl`
- Legacy/compat: `~/.clawdbot/agents/*/sessions/*.jsonl`

Do **not** estimate from “current context window” style token fields.

## 2) Quick commands

### Daily costs (last 7 days)
```bash
python3 {baseDir}/scripts/extract_cost.py --last-days 7
```

### Today / yesterday
```bash
python3 {baseDir}/scripts/extract_cost.py --today
python3 {baseDir}/scripts/extract_cost.py --yesterday
```

### Top expensive sessions
```bash
python3 {baseDir}/scripts/extract_cost.py --top-sessions 10
```

### JSON output (for dashboards)
```bash
python3 {baseDir}/scripts/extract_cost.py --last-days 30 --json
```

## 3) If cost is missing (fallback estimate)

Some providers may omit `usage.cost`. You can provide per-1M-token prices:

```bash
export PRICE_INPUT=1.75
export PRICE_OUTPUT=14
export PRICE_CACHE_READ=0.175
export PRICE_CACHE_WRITE=0
python3 {baseDir}/scripts/extract_cost.py --last-days 7
```

## 4) Budget alerts

The extractor can run as a **budget check**:

```bash
python3 {baseDir}/scripts/extract_cost.py --today --budget-usd 5
```

- If budget is exceeded, it prints an **ALERT** and exits with code **2** (default).
- For non-failing checks:

```bash
python3 {baseDir}/scripts/extract_cost.py --today --budget-usd 5 --budget-mode warn
```

### Wiring it to a cron alert (recommended)
Run it daily (or hourly) and if exit code is 2, send yourself a Telegram message.
(Implementation depends on your OpenClaw channel setup; do not embed secrets in scripts.)

## 5) Token-saving playbook (teach the AI)

When the user says “use as few tokens as possible”, apply:
- **Default response budget:** 1–6 lines, bullets > paragraphs
- **Ask 1 question max** (only if truly blocking)
- **Progressive disclosure:** offer details only if asked
- **Tool calls:** batch; avoid repeated `status`/browser calls
- **No log dumps** into chat; summarize + point to file path
- **Hard limits:** max 3 web iterations (search/fetch) per task

Optional phrasing to keep yourself in check:
> "Answer in <=6 lines. If more is needed, ask permission."

Related Skills

OpenClaw-Finnhub

7
from Demerzels-lab/elsamultiskillagent

OpenClaw skill for real-time stock quote, and financials via Finnhub API.

openclaw-nextcloud

7
from Demerzels-lab/elsamultiskillagent

Manage Notes, Tasks, Calendar, Files, and Contacts in your Nextcloud instance via CalDAV, WebDAV, and Notes API. Use for creating notes, managing todos and calendar events, uploading/downloading files, and managing contacts.

openclaw-safety-coach

7
from Demerzels-lab/elsamultiskillagent

Safety coach for OpenClaw users. Refuses harmful, illegal, or unsafe requests and provides practical guidance to reduce ecosystem risk (malicious skills, tool abuse, secret exfiltration, prompt injection).

openclaw

7
from Demerzels-lab/elsamultiskillagent

openclaw

openclaw-spacesuit

7
from Demerzels-lab/elsamultiskillagent

**A framework scaffold for OpenClaw workspaces.**

toolguard-daemon-control

7
from Demerzels-lab/elsamultiskillagent

Manage long-running processes as macOS launchd services.

nutrient-openclaw

7
from Demerzels-lab/elsamultiskillagent

Document processing for OpenClaw — convert, extract, OCR, redact, sign, and watermark PDFs and Office documents using the Nutrient DWS API. Use when asked to convert documents (DOCX/XLSX/PPTX to PDF, PDF to images or Office formats), extract text or tables from PDFs, apply OCR to scanned documents, redact sensitive information or PII, add watermarks, or digitally sign documents. Triggers on "convert to PDF", "extract text", "OCR this", "redact PII", "watermark", "sign document", or any document processing request.

lobsterguard

7
from Demerzels-lab/elsamultiskillagent

Bilingual security auditor for OpenClaw. 68 checks across 6 categories, 11 auto-fixes, OWASP Agentic AI Top 10.

skill-guard

7
from Demerzels-lab/elsamultiskillagent

Scan ClawHub skills for security vulnerabilities BEFORE installing. Use when installing new skills from ClawHub to detect prompt injections, malware payloads, hardcoded secrets, and other threats. Wraps clawhub install with mcp-scan pre-flight checks.

openclaw-setup

7
from Demerzels-lab/elsamultiskillagent

Set up a complete OpenClaw personal AI assistant from scratch using Claude Code. Walks through AWS provisioning, OpenClaw installation, Telegram bot creation, API configuration, Google Workspace integration, security hardening, and all power features. Give this to Claude Code and it handles the rest.

OpenClaw Optimizer Skill

7
from Demerzels-lab/elsamultiskillagent

## Overview

openclaw-backup

7
from Demerzels-lab/elsamultiskillagent

Enhanced backup and restore for openclaw configuration, skills, commands, and settings. Sync across devices, version control with git, automate backups, and migrate to new machines with advanced compression.