{
  "schemaVersion": "1.0",
  "item": {
    "slug": "tokenguard",
    "name": "TokenGuard",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/G0HEAD/tokenguard",
    "canonicalUrl": "https://clawhub.ai/G0HEAD/tokenguard",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/tokenguard",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=tokenguard",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "scripts/tokenguard.py",
      "skill.json"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-07T17:22:31.273Z",
      "expiresAt": "2026-05-14T17:22:31.273Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
        "contentDisposition": "attachment; filename=\"afrexai-annual-report-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/tokenguard"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/tokenguard",
    "agentPageUrl": "https://openagent3.xyz/skills/tokenguard/agent",
    "manifestUrl": "https://openagent3.xyz/skills/tokenguard/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/tokenguard/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "🛡️ TokenGuard — API Cost Guardian",
        "body": "Protect your wallet from runaway API costs.\n\nTokenGuard tracks your agent's spending per session, enforces configurable limits, and alerts you before you blow your budget."
      },
      {
        "title": "Why TokenGuard?",
        "body": "AI agents can rack up serious API costs fast. One runaway loop = hundreds of dollars. TokenGuard gives you:\n\nSession-based tracking — Costs reset daily (or on demand)\nHard limits — Actions blocked when budget exceeded\nPre-flight checks — Verify budget BEFORE expensive calls\nOverride controls — Extend limits or bypass when needed\nFull audit trail — Every cost logged with timestamps"
      },
      {
        "title": "Installation",
        "body": "clawhub install tokenguard\n\nOr manually:\n\nmkdir -p ~/.openclaw/workspace/skills/tokenguard\n# Copy SKILL.md and scripts/tokenguard.py\nchmod +x scripts/tokenguard.py"
      },
      {
        "title": "Quick Start",
        "body": "# Check current status\npython3 scripts/tokenguard.py status\n\n# Set a $20 limit\npython3 scripts/tokenguard.py set 20\n\n# Before an expensive call, check budget\npython3 scripts/tokenguard.py check 5.00\n\n# After the call, log actual cost\npython3 scripts/tokenguard.py log 4.23 \"Claude Sonnet - code review\"\n\n# View spending history\npython3 scripts/tokenguard.py history"
      },
      {
        "title": "Commands",
        "body": "CommandDescriptionstatusShow current limit, spent, remainingset <amount>Set spending limit (e.g., set 50)check <cost>Check if estimated cost fits budgetlog <amount> [desc]Log a cost after API callresetClear session spendinghistoryShow all logged entriesextend <amount>Add to current limitoverrideOne-time bypass for next checkexport [--full]Export data as JSON"
      },
      {
        "title": "Exit Codes",
        "body": "0 — Success / within budget\n1 — Budget exceeded (check command)\n2 — Limit exceeded after logging\n\nUse exit codes in scripts:\n\nif python3 scripts/tokenguard.py check 10.00; then\n    # proceed with expensive operation\nelse\n    echo \"Over budget, skipping\"\nfi"
      },
      {
        "title": "Budget Exceeded Alert",
        "body": "When a check would exceed your limit:\n\n🚫 BUDGET EXCEEDED\n╭──────────────────────────────────────────╮\n│  Current spent:  $    4.0000            │\n│  This action:    $   10.0000            │\n│  Would total:    $   14.0000            │\n│  Limit:          $   10.00              │\n│  Over by:        $    4.0000            │\n╰──────────────────────────────────────────╯\n\n💡 Options:\n   tokenguard extend 5    # Add to limit\n   tokenguard set <amt>   # Set new limit\n   tokenguard reset       # Clear session\n   tokenguard override    # One-time bypass"
      },
      {
        "title": "Integration Pattern",
        "body": "For agents using paid APIs:\n\nimport subprocess\nimport sys\n\ndef check_budget(estimated_cost: float) -> bool:\n    \"\"\"Check if action fits budget.\"\"\"\n    result = subprocess.run(\n        [\"python3\", \"scripts/tokenguard.py\", \"check\", str(estimated_cost)],\n        capture_output=True\n    )\n    return result.returncode == 0\n\ndef log_cost(amount: float, description: str):\n    \"\"\"Log actual cost after API call.\"\"\"\n    subprocess.run([\n        \"python3\", \"scripts/tokenguard.py\", \"log\",\n        str(amount), description\n    ])\n\n# Before expensive operation\nif not check_budget(5.00):\n    print(\"Budget exceeded, asking user...\")\n    sys.exit(1)\n\n# Make API call\nresponse = call_expensive_api()\n\n# Log actual cost\nlog_cost(4.23, \"GPT-4 code analysis\")"
      },
      {
        "title": "Configuration",
        "body": "Environment variables:\n\nVariableDefaultDescriptionTOKENGUARD_DIR~/.tokenguardStorage directoryTOKENGUARD_DEFAULT_LIMIT20.0Default limit in USDTOKENGUARD_WARNING_PCT0.8Warning threshold (0-1)"
      },
      {
        "title": "Cost Reference",
        "body": "Common API pricing (per 1M tokens):\n\nModelInputOutputClaude 3.5 Sonnet$3$15Claude 3 Haiku$0.25$1.25GPT-4o$2.50$10GPT-4o-mini$0.15$0.60GPT-4-turbo$10$30\n\nRule of thumb: 1000 tokens ≈ 750 words"
      },
      {
        "title": "Storage",
        "body": "Data stored in ~/.tokenguard/ (or TOKENGUARD_DIR):\n\nlimit.json — Current limit configuration\nsession.json — Today's spending + entries\noverride.flag — One-time bypass flag"
      },
      {
        "title": "Best Practices",
        "body": "Set realistic limits — Start with $10-20 for development\nCheck before expensive calls — Always check before big operations\nLog everything — Even small costs add up\nUse extend, not reset — Keep audit trail intact\nMonitor warnings — 80% threshold = time to evaluate"
      },
      {
        "title": "v1.0.0",
        "body": "Initial release\nCore commands: status, set, check, log, reset, history, extend, override\nEnvironment variable configuration\nJSON export for integrations\nDaily auto-reset\n\nBuilt by PaxSwarm — a murmuration-class swarm intelligence"
      }
    ],
    "body": "🛡️ TokenGuard — API Cost Guardian\n\nProtect your wallet from runaway API costs.\n\nTokenGuard tracks your agent's spending per session, enforces configurable limits, and alerts you before you blow your budget.\n\nWhy TokenGuard?\n\nAI agents can rack up serious API costs fast. One runaway loop = hundreds of dollars. TokenGuard gives you:\n\nSession-based tracking — Costs reset daily (or on demand)\nHard limits — Actions blocked when budget exceeded\nPre-flight checks — Verify budget BEFORE expensive calls\nOverride controls — Extend limits or bypass when needed\nFull audit trail — Every cost logged with timestamps\nInstallation\nclawhub install tokenguard\n\n\nOr manually:\n\nmkdir -p ~/.openclaw/workspace/skills/tokenguard\n# Copy SKILL.md and scripts/tokenguard.py\nchmod +x scripts/tokenguard.py\n\nQuick Start\n# Check current status\npython3 scripts/tokenguard.py status\n\n# Set a $20 limit\npython3 scripts/tokenguard.py set 20\n\n# Before an expensive call, check budget\npython3 scripts/tokenguard.py check 5.00\n\n# After the call, log actual cost\npython3 scripts/tokenguard.py log 4.23 \"Claude Sonnet - code review\"\n\n# View spending history\npython3 scripts/tokenguard.py history\n\nCommands\nCommand\tDescription\nstatus\tShow current limit, spent, remaining\nset <amount>\tSet spending limit (e.g., set 50)\ncheck <cost>\tCheck if estimated cost fits budget\nlog <amount> [desc]\tLog a cost after API call\nreset\tClear session spending\nhistory\tShow all logged entries\nextend <amount>\tAdd to current limit\noverride\tOne-time bypass for next check\nexport [--full]\tExport data as JSON\nExit Codes\n0 — Success / within budget\n1 — Budget exceeded (check command)\n2 — Limit exceeded after logging\n\nUse exit codes in scripts:\n\nif python3 scripts/tokenguard.py check 10.00; then\n    # proceed with expensive operation\nelse\n    echo \"Over budget, skipping\"\nfi\n\nBudget Exceeded Alert\n\nWhen a check would exceed your limit:\n\n🚫 BUDGET EXCEEDED\n╭──────────────────────────────────────────╮\n│  Current spent:  $    4.0000            │\n│  This action:    $   10.0000            │\n│  Would total:    $   14.0000            │\n│  Limit:          $   10.00              │\n│  Over by:        $    4.0000            │\n╰──────────────────────────────────────────╯\n\n💡 Options:\n   tokenguard extend 5    # Add to limit\n   tokenguard set <amt>   # Set new limit\n   tokenguard reset       # Clear session\n   tokenguard override    # One-time bypass\n\nIntegration Pattern\n\nFor agents using paid APIs:\n\nimport subprocess\nimport sys\n\ndef check_budget(estimated_cost: float) -> bool:\n    \"\"\"Check if action fits budget.\"\"\"\n    result = subprocess.run(\n        [\"python3\", \"scripts/tokenguard.py\", \"check\", str(estimated_cost)],\n        capture_output=True\n    )\n    return result.returncode == 0\n\ndef log_cost(amount: float, description: str):\n    \"\"\"Log actual cost after API call.\"\"\"\n    subprocess.run([\n        \"python3\", \"scripts/tokenguard.py\", \"log\",\n        str(amount), description\n    ])\n\n# Before expensive operation\nif not check_budget(5.00):\n    print(\"Budget exceeded, asking user...\")\n    sys.exit(1)\n\n# Make API call\nresponse = call_expensive_api()\n\n# Log actual cost\nlog_cost(4.23, \"GPT-4 code analysis\")\n\nConfiguration\n\nEnvironment variables:\n\nVariable\tDefault\tDescription\nTOKENGUARD_DIR\t~/.tokenguard\tStorage directory\nTOKENGUARD_DEFAULT_LIMIT\t20.0\tDefault limit in USD\nTOKENGUARD_WARNING_PCT\t0.8\tWarning threshold (0-1)\nCost Reference\n\nCommon API pricing (per 1M tokens):\n\nModel\tInput\tOutput\nClaude 3.5 Sonnet\t$3\t$15\nClaude 3 Haiku\t$0.25\t$1.25\nGPT-4o\t$2.50\t$10\nGPT-4o-mini\t$0.15\t$0.60\nGPT-4-turbo\t$10\t$30\n\nRule of thumb: 1000 tokens ≈ 750 words\n\nStorage\n\nData stored in ~/.tokenguard/ (or TOKENGUARD_DIR):\n\nlimit.json — Current limit configuration\nsession.json — Today's spending + entries\noverride.flag — One-time bypass flag\nBest Practices\nSet realistic limits — Start with $10-20 for development\nCheck before expensive calls — Always check before big operations\nLog everything — Even small costs add up\nUse extend, not reset — Keep audit trail intact\nMonitor warnings — 80% threshold = time to evaluate\nChangelog\nv1.0.0\nInitial release\nCore commands: status, set, check, log, reset, history, extend, override\nEnvironment variable configuration\nJSON export for integrations\nDaily auto-reset\n\nBuilt by PaxSwarm — a murmuration-class swarm intelligence"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/G0HEAD/tokenguard",
    "publisherUrl": "https://clawhub.ai/G0HEAD/tokenguard",
    "owner": "G0HEAD",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/tokenguard",
    "downloadUrl": "https://openagent3.xyz/downloads/tokenguard",
    "agentUrl": "https://openagent3.xyz/skills/tokenguard/agent",
    "manifestUrl": "https://openagent3.xyz/skills/tokenguard/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/tokenguard/agent.md"
  }
}