cost-guard

cost-guard is a skill for Claude Code from XuanRanL/loamwright-SEO-Skill. It costs 42 tokens per session (306 once invoked), scanned A, original, Apache-2.0.

A budget control system for API-based work that estimates, checks, records, and summarises spending against configured limits.

In plain words
What is it for?
Estimating a call's cost, enforcing spending caps, recording API usage, viewing the day's total, and resetting the daily ledger when authorised.
Why use it?
It can stop work from exceeding daily, task, article, or image-batch budgets before more paid API calls are made.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the xuanran-seo-blog-writer plugin — 68 skills, 34 agents, 4 hooks shipped together

Good fit Estimating a call's cost, enforcing spending caps, recording API usage, viewing the day's total, and resetting the daily ledger when authorised.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/xuanranl/loamwright-seo-skill/cost-guard
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add XuanRanL/loamwright-SEO-Skill --skill cost-guard
Clone the repo
git clone --depth 1 https://github.com/XuanRanL/loamwright-SEO-Skill

Made for: Claude Code.

Or install xuanran-seo-blog-writer, the plugin that ships this one along with the rest of its 68 skills, 34 agents, 4 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cost-guard

README.md
[![agentmods](https://agentmods.dev/badge/skills/xuanranl/loamwright-seo-skill/cost-guard/github.svg)](https://agentmods.dev/skills/xuanranl/loamwright-seo-skill/cost-guard)
Your own site
<a href="https://agentmods.dev/skills/xuanranl/loamwright-seo-skill/cost-guard"><img src="https://agentmods.dev/badge/skills/xuanranl/loamwright-seo-skill/cost-guard/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cost-guard

Your own site · 80×15
<a href="https://agentmods.dev/skills/xuanranl/loamwright-seo-skill/cost-guard"><img src="https://agentmods.dev/badge/skills/xuanranl/loamwright-seo-skill/cost-guard.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 306 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00042 $0.00306
Opus 5 $0.00021 $0.00153
Sonnet 5 $0.00008 $0.00061
Haiku 4.5 $0.00004 $0.00031

Measured 11d ago against content hash 11b006f59605, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

cost-guard scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

subskills/cross-cutting/cost-guard/SKILL.md · 41 lines

What it actually says

Cost Guard

Implementation: scripts/_core/cost_ledger.py.

This skill is mostly a wrapper to expose cost-guard ops via slash commands.

CLI commands

# Estimate cost for an upcoming API call
python -m scripts._core.cost_ledger --estimate --model claude-opus-4-7 --in 5000 --out 2000

# Get current day's spend summary
python -m scripts._core.cost_ledger --summary --period day --json

# Reset today's ledger (admin only)
python -m scripts._core.cost_ledger --reset-today

Caps (from ~/.xuanran-seo/config.yaml)

cost_limits:
  daily_total_usd: 50
  per_init_usd: 1.5
  per_article_usd: 3.0
  per_image_batch_usd: 2.0

Hook integration

  • hooks/pre_tool_use_cost_guard.py enforces caps before Bash commands
  • Every API-calling script logs to ledger after call

See also

  • scripts/_core/cost_ledger.py
  • hooks/pre_tool_use_cost_guard.py
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 41 lines · 42 tokens per session scan A 11b006f59605

Subscribe to this mod's changes

cost-guard is a skill published in the GitHub repository XuanRanL/loamwright-SEO-Skill (49 stars, last pushed 24d ago), licensed Apache-2.0. It adds 42 tokens to every session and 306 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.