Token-Guard — Caching & Autonomy Optimizer

    1

    Cut agent input-token cost up to 80% and hard-stop runaway loops with cache-aware compaction, non-destructive offload, and deterministic loop guards.

    $39

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Token-Guard — Caching & Autonomy Optimizer

    Example session with this skill installed

    I'm starting a large refactor. Initialize Token-Guard to manage this session. Set a budget of 50 iterations and offload any tool outputs larger than 2KB.

    • Read your context and instructions
    • Compiled the token-guard

    I have initialized the Token-Guard control layer for this refactoring session. I will monitor the execution budget and apply cache-aware compaction as the context grows. Tool outputs exceeding 2KB will be offloaded to local storage with pointer references maintained in the active window.

    Session Optimization Plan

    ComponentPolicy / LimitStrategy
    Loop Guard50 IterationsHard-stop at iteration 45 for manual review.
    Token Budget200k Input TokensMonitor via scripts/token_guard.py.
    Offload Trigger> 2,048 BytesMove to logs/offload_[timestamp].jsonl.
    CompactionEvery 5 turnsPreserve system prefix; emit delta summaries.

    Initial Budget Ledger

    {
      "max_iterations": 50,
      "token_budget": 200000,
      "used": 450,
      "halted": false,
      "session_start": "2023-10-27T10:00:00Z"
    }
    

    Next steps

    1. Run python scripts/token_guard.py --limit 50 in a separate terminal to enable external process monitoring.
    2. Approve the creation of the ./logs directory for artifact offloading.
    3. Proceed with the first step of the refactor; I will alert you before any destructive compaction occurs.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Token-Guard keeps long-horizon coding-agent sessions cheap and bounded. It's a bundled control layer of three cooperating SKILL.md sub-skills:

    • Cache-aware compaction — protects a byte-stable system+early prefix and emits incremental delta summaries, so prompt-cache hits stay near 90% (no cache-miss spikes from naive rewrites).
    • Non-destructive offload — moves verbose tool output and documents to local JSONL/temp files with a searchable pointer, so nothing is deleted and the agent can re-read on demand.
    • Deterministic loop guards — enforce hard max-iteration, step-wise token-budget, and retry caps the model cannot override, stopping Infinite Agentic Loops that otherwise burn $50/day.

    What you get: a root SKILL.md orchestrator + 3 sub-skills (compaction, offload, loop-guard), an MIT-licensed helper script, and worked examples. Net effect: up to ~80% lower input-token cost on long sessions, and a hard stop on runaway loops.

    Human-in-the-Loop by design: before any destructive compaction or offload, Token-Guard presents a plan and waits for your explicit approval. It never invents metrics or silently drops your code.

    Works with Claude Code, Cursor, Gemini CLI, Codex CLI, and any agent that loads SKILL.md.

    Requires local file system write access for offloading. The loop-guard helper script requires manual execution to enforce hard process termination.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 2 months ago

    Permissions

    Write Files
    Listed2 months ago

    What's inside

    Frequently Asked Questions

    Token Guard uses cache-aware compaction to keep context prefixes stable, significantly increasing the likelihood of provider-side cache hits and reducing input token costs by up to 80%.

    It is designed for any agent that supports SKILL.md integration, with optimized workflows for Claude Code, Cursor, and Gemini CLI environments.

    You receive the core SKILL.md instruction protocol, a set of Python helper scripts for budget enforcement, and documentation for setting up the local JSONL artifact storage.

    Token Guard moves verbose tool outputs and data to local JSONL files, replacing them with one-line pointers so the agent remembers *where* information is without it clogging the context window.

    Yes, the included budget enforcement scripts allow you to set deterministic hard caps on iterations and token spend, preventing agents from entering expensive infinite loops.

    Installation is straightforward: you simply add the SKILL.md file to your agent's project directory and ensure the agent has permissions to write to a local artifacts folder.

    New in Agents & Orchestration