Token-Guard — Caching & Autonomy Optimizer

    by Rachid Houmayni

    1

    Lower your AI costs and prevent expensive infinite loops by cleaning up chat memory and setting task limits.

    $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

    What it does

    • Moves large documents to local folders to keep the chat fast and cheap
    • Sets hard limits on how many times the AI can repeat a task before stopping
    • Creates a simple list of where every large file is stored for easy retrieval
    • Protects the first few messages of your chat to keep the AI focused and accurate

    Token-Guard — Caching & Autonomy Optimizer

    Example session with this skill installed

    I have a huge 50KB build log that is making our chat slow. Can you offload it and set a limit of 10 retries for fixing the errors?

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

    I will help you clean up the chat and set safety limits.

    First, I have moved that 50KB build log into a local folder so it doesn't slow us down anymore. I have left a note in our chat so I can look at it again if I need to check a specific error.

    Next, I have set up a Budget Ledger to keep us on track:

    • Max Tries: 10
    • Current Tries: 0
    • Status: Active

    Offload Record:

    • File: .tg-offload/build-log.jsonl
    • Summary: Contains 3 failing tests in the login section.

    I am ready to start fixing the errors now. If I reach 10 tries without finishing, I will stop and ask you for help. Should I begin with the first failing test?

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

    About this skill

    When you work with an AI agent for a long time, the chat gets crowded. It starts costing more money, runs slower, and can even get stuck repeating the same mistake forever. This skill gives your AI agent a set of tools to keep things tidy and cheap. It works by shrinking down the middle of your conversation while keeping the start and the most recent parts crystal clear.

    If you have huge files or long reports, this skill tells your AI to move them to a side folder instead of keeping them in the chat memory. It leaves a small note so it can find the file later if needed. Most importantly, it sets a hard limit on how many times the AI can try something. If the AI hits that limit, it stops and asks you what to do instead of wasting your budget.

    How it works

    1. Ask your AI agent to start the skill at the beginning of a long task.
    2. Review the plan your AI suggests for shrinking the chat or moving large files.
    3. Check the progress reports to see how many tokens and steps you have used.
    4. Give your approval before the AI cleans up old parts of the chat history.

    What you get: A system that lowers your AI costs by up to 80% and stops runaway loops.

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

    Built using SKILL.md for context management. Uses a Python helper script (token_guard.py) for deterministic budget enforcement. Implements byte-stable prefixing for prompt caching and JSONL-based artifact offloading to local storage. Compatible with agents that support local file system access and system prompt extensions.

    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 buying a skill.

    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.

    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

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skill Creator Skills.