pre-turn-budget-guardian
OfficialEnforce token budgets in Claude Code.
Authorm2ai-portfolio
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Enforce a token budget ceiling on Claude Code sessions by checking projected usage BEFORE each turn and halting with a structured stop reason if the budget would be exceeded. Prevents runaway loops and silent token burn. Completes the token management trilogy alongside boot-tax-monitor (measures startup) and token-burn-auditor (measures waste).
Core Features & Use Cases
- Configurable budget knobs: budget_tokens, budget_usd, warning_threshold, enforcement, and model (auto-detected).
- Real-time projection: estimates next-turn cost and remaining budget from current session data.
- Enforcement modes: soft warnings or hard stops with structured stop reasons.
- Use cases: long-running Claude Code sessions with heavy code generation, tool use, or multi-turn planning that risk overspending.
Quick Start
Set a token budget (e.g., 500000 tokens) and enable enforcement to prevent overspend during this Claude Code session.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: pre-turn-budget-guardian Download link: https://github.com/m2ai-portfolio/m2ai-skills-pack/archive/main.zip#pre-turn-budget-guardian Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 510,000+ vetted skills library on demand.