💸 AI PR Cost & Secret Guard (GitHub Action + CLI)

⭐ Part of the MCP Shieldwall Open-Source AI Security & FinOps Suite — if this tool saves you time or API spend, please star our main repository on GitHub!
Prevent surprise $5,000 LLM API bills and leaked keys before merge.
Try the live interactive demo on Hugging Face Spaces:
👉 https://huggingface.co/spaces/snsnshnwh/ai-pr-cost-guard
Zero-Install Quickstart (uvx)
Run directly against your repo or staged git changes with uvx — no installation required:
# Scan a directory or file
uvx ai-pr-cost-guard ./src
# Scan staged git changes before committing
uvx ai-pr-cost-guard --git-diff --format text
# Emit a Markdown summary report
uvx ai-pr-cost-guard --git-diff --markdown
GitHub Action
Drop this 6-line GitHub Action into any repository using OpenAI, Anthropic, or Gemini SDKs:
name: AI Cost Guard
on: [pull_request]
jobs:
cost-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: andrejpimenov122-lab444/ai-pr-cost-guard@v1
Pre-commit Hook
Add to .pre-commit-config.yaml to scan staged Python, TypeScript, and JavaScript files:
repos:
- repo: https://github.com/andrejpimenov122-lab444/ai-pr-cost-guard
rev: v0.2.1
hooks:
- id: ai-pr-cost-guard
What It Catches
COST-001 (HIGH): Exposed OpenAI, Anthropic, and Google Gemini API keys (redacted; including .env and .ipynb outputs).
COST-002 (HIGH): LLM SDK calls inside unbounded while/for loops or unbounded retry decorators.
COST-003 (MEDIUM): Endpoint-aware missing, invalid, or policy-exceeding output token caps (max_tokens / max_output_tokens).
COST-004 (LOW): Missing finite timeout on SDK client or per-request calls.
Local CLI Usage
python3 cost_guard.py ./src
License
MIT