pre-turn-budget-guardian

Enforce token budget ceilings on Claude Code sessions before each turn.

4|1|Updated Apr 11, 2026
One-click install
npx skills add https://github.com/m2ai-portfolio/m2ai-skills-pack --skill pre-turn-budget-guardian
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pre-turn-budget-guardian
Source: https://github.com/m2ai-portfolio/m2ai-skills-pack/tree/main/skills/pre-turn-budget-guardian
Command: npx skills add https://github.com/m2ai-portfolio/m2ai-skills-pack --skill pre-turn-budget-guardian

SYSTEM DOCUMENTATION & REQUIREMENTS

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.

Frequently Asked Questions about pre-turn-budget-guardian

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce a token budget ceiling in Claude Code sessions?

To enforce a token budget ceiling in Claude Code sessions, configure the budget_tokens, budget_usd, warning_threshold, enforcement, and model parameters in the frontmatter to halt execution when projected usage exceeds limits.

How does Claude Code estimate next-turn token costs before execution?

Claude Code estimates next-turn token costs by reading current usage data from the session store or JSONL logs, then projecting the remaining budget against the upcoming interactive turn before applying soft or hard stops.

Can I set spending limits for multi-turn code generation in Claude Code?

Yes, you can set spending limits for multi-turn code generation in Claude Code by defining a USD or token budget threshold that triggers configurable enforcement actions to prevent overspending.

What is the difference between soft warnings and hard stops for token cost control?

Soft warnings for token cost control alert you when approaching the budget threshold, whereas hard stops completely halt the Claude Code session with a structured stop reason once the token or USD limit is exceeded.

Why do my long-running Claude Code sessions burn tokens in runaway loops?

Long-running Claude Code sessions burn tokens in runaway loops due to silent continuous execution without budget tracking. Pre-turn budget projection prevents this by checking estimated usage before each turn executes.

What configuration parameters do I need to prevent token overspend in Claude Code?

To prevent token overspend in Claude Code, you need to configure budget_tokens and budget_usd for limits, warning_threshold for alerts, enforcement for stop modes, and model for accurate cost estimation in the frontmatter.