Unlike prompt-clarity tools, this one doesn't call an LLM to check your prompt — it tells you the token count and cost, across Claude/GPT/Gemini, before you spend it, for free, instantly, on every prompt, slash-command, and skill.
Runs automatically on every submission in Claude Code (UserPromptSubmit +
UserPromptExpansion hooks). 100% local, zero API calls, zero added latency
by default. Shows:
- Token count
- Cost estimate across 6 models (Claude Sonnet/Opus/Haiku, GPT-5/mini, Gemini 2.5 Pro)
- Flags for: duplicate paragraphs, oversized pastes, structured requests (list/compare/table) with no output format specified
Never blocks. Informational only — this is a deliberate design decision, not a missing feature. See "Design decisions" below.
Add #optimize anywhere in your prompt to get a trimmed rewrite. This is the
only thing in this plugin that costs money or adds latency, and it only
runs when you explicitly ask for it:
Please review this whole file and tell me what's wrong with it #optimize
The #optimize tag is stripped before analysis. Requires ANTHROPIC_API_KEY
in your environment — if it's not set, the check still runs (free), and
optimize just tells you it was skipped, no charge.
/plugin marketplace add YOUR_GITHUB_USERNAME/claude-cost-guard
/plugin install claude-cost-guard
Or test locally without installing:
claude --plugin-dir /path/to/claude-cost-guard
Ask Claude to use the cost-guard-check skill on any text — useful for
checking a draft before you've decided where to send it.
Or run the engine directly:
echo "your prompt text" | node engine/layer1.js --check
- Non-blocking by default. An earlier design always paused for confirmation on every submission — that means every prompt costs a minimum of two submissions, which fights the tool's own purpose. Informational, always-visible, never-blocking is the actual default.
- Optimize is opt-in per prompt, not automatic. A tool whose pitch is "reduce spend" can't itself add a guaranteed API call to every single prompt. Layer 1 (free) always runs; Layer 2 (paid) only runs on request.
- Skills and slash-commands are checked too, not bypassed — same guard as freeform prompts, since that's where real token cost also accumulates.
- Claude Code only for V1. GitHub Copilot Chat has no public API for
automatic pre-send interception (only opt-in
@mentionchat participants, or an unofficial local proxy) — revisit once this has real usage.
claude-cost-guard/
├── .claude-plugin/
│ ├── plugin.json # plugin manifest
│ └── marketplace.json # makes it installable via /plugin marketplace add
├── hooks/
│ ├── hooks.json # registers UserPromptSubmit + UserPromptExpansion
│ └── guard.js # thin dispatcher, non-blocking
├── engine/
│ ├── layer1.js # free/local checks (token count, flags) + CLI mode
│ ├── layer2-optimize.js # paid rewrite, only called on #optimize
│ └── pricing.json # per-model $/1M token estimates, update periodically
├── skills/
│ └── cost-guard-check/SKILL.md # manual on-demand check
└── tests/run.sh # lightweight regression check
Layer 1 and Layer 2 logic are implemented and tested standalone (all paths:
normal input, short input, malformed input, missing API key, invalid API key
— see tests/run.sh). Not yet verified inside a live Claude Code session
— that's the next real-world test before calling this done end-to-end.
- Configurable hard-block threshold (opt-in, off by default)
- GitHub Copilot support
- CI/CD repo-context auditing (
CLAUDE.md/.cursorruleshygiene) — deferred, different problem than this plugin solves