En

@agentoom/pi-spending-guard

Track LLM call costs and automatically pause when exceeding a threshold

开发流程 控制费用支出监控AI调用成本防止API滥用 通用 ★ 51 Updated 2026-08-02

Install & Use

Copy this prompt and send it to your AI assistant (Claude / Cursor / TRAE / Codex / WorkBuddy etc.) to auto-install:

Help me install this AI Skill: @agentoom/pi-spending-guard.
It is used for: Track LLM call costs and automatically pause when exceeding a threshold
Full Skill content: https://321skill.com/skills/agentoom-pi-spending-guard/raw/index.md
Read that page and install it.

The prompt includes a link to the full Skill content. You can also view the full content.

This Skill addresses the pain point of uncontrolled LLM API costs. In practical development, developers often need to frequently call large models to complete multi-turn tasks or batch inference, but struggle to monitor the cost of each call in real-time, leading to budget overruns and end-of-month billing surprises. Pi-Spending-Guard allows you to precisely track each AI expense during task execution and set a configurable threshold. When the cumulative cost reaches this value, the task is automatically paused, preventing costs from ballooning indefinitely.

Usage is straightforward: simply install the extension first, then manage spending via natural language instructions or commands. For example, type /spending to view current spending and the limit, and /spending limit 5 to set the threshold to $5. When the actual spending reaches the limit, the system displays a dialog with four options: Continue (double the limit or reset the counter), Optimize prompt, or Stop the task. Simultaneously, the status bar shows a real-time spending progress bar like 💵 $1.23 / $3.00, keeping you informed of costs at all times.

It is ideal for teams or individuals who need fine-grained control over LLM call costs, especially users already leveraging pi.dev as an AI assistant platform for frequent multi-turn conversations or batch task processing, such as project managers, full-stack developers, and agent developers. For enterprises needing to manage AI budgets across multiple users or projects, hierarchical control can be achieved through global and project-level configuration files, preventing a single project from exhausting the overall budget.

It is recommended to configure a global default limit (default $3) uniformly at project startup and adjust the threshold based on the actual business complexity and call frequency. Note that it currently only supports the pi.dev platform and cannot be directly used with other LLM calling frameworks (e.g., direct OpenAI API calls). Additionally, if you choose "Continue (reset counter)" after a pause, the cumulative spending will be cleared, so pay attention to the continuity of budget tracking.

Key Features

Unlike OpenAI's built-in usage monitoring, pi-spending-guard directly pauses the task upon reaching the threshold and provides interactive options (Continue/Optimize/Stop), rather than sending a post-facto billing alert. This allows users to make immediate decisions before actual overspending occurs, avoiding passive cost overruns.

Limitations

Only supports the pi.dev platform. Requires installation of the pi CLI and npm package manager. The default limit is $3. Modifying the configuration file (.pi/spending-guard.json) is required to adjust the threshold.

FAQ

How do I change the default $3 limit?

You can temporarily set it via the command `/spending limit 5`, or edit the `limit` field in the project-level configuration file `.pi/spending-guard.json` for a permanent change.

Can I resume the previous task after a pause?

Yes. The dialog that appears after pausing supports selecting "Continue (double limit)" or "Continue (reset counter)". The task does not need to be restarted.

Installation guide for AI assistants

If your AI coding assistant (Claude Code, Cursor, TRAE etc.) can see this page, send it this message to auto-install:

Visit https://321skill.com/skills/agentoom-pi-spending-guard/raw/index.md to read the original Skill definition (Markdown format) for @agentoom/pi-spending-guard, and install it according to the instructions.