agentguard

agentguard is a skill for Claude Code, Codex from bmdhodl/agent47. It costs 37 tokens per session (965 once invoked), scanned A, original, MIT.

A local Python library that adds runtime limits and tracing to AI coding agents. It can monitor model calls and stop repeated actions, excessive spending, retries, or long-running tasks.

In plain words
What is it for?
Use it to set cost, repetition, timeout, rate, and retry limits, while recording activity from supported OpenAI calls.
Why use it?
It helps prevent an agent from getting stuck in a loop, retrying a failing tool, exceeding a budget, or running longer than allowed.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to set cost, repetition, timeout, rate, and retry limits, while recording activity from supported OpenAI calls.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/bmdhodl/agent47/agentguard
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add bmdhodl/agent47 --skill agentguard
Clone the repo
git clone --depth 1 https://github.com/bmdhodl/agent47

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for agentguard

README.md
[![agentmods](https://agentmods.dev/badge/skills/bmdhodl/agent47/agentguard/github.svg)](https://agentmods.dev/skills/bmdhodl/agent47/agentguard)
Your own site
<a href="https://agentmods.dev/skills/bmdhodl/agent47/agentguard"><img src="https://agentmods.dev/badge/skills/bmdhodl/agent47/agentguard/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for agentguard

Your own site · 80×15
<a href="https://agentmods.dev/skills/bmdhodl/agent47/agentguard"><img src="https://agentmods.dev/badge/skills/bmdhodl/agent47/agentguard.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 965 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00037 $0.00965
Opus 5.5 $0.00015 $0.00386
Sonnet 5.5 $0.00007 $0.00193
Haiku 4.5 $0.00004 $0.00097

Measured 1mo ago against content hash 65968a135492, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

agentguard scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/agentguard/SKILL.md · 125 lines

How it starts

The opening of the file, as written. The whole thing — 125 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AgentGuard

Runtime guardrails for coding agents. Recorded-budget preflight, loops, retries, and timeouts on instrumented Python paths. Zero dependencies. Local-first. This skill is onboarding, not host enforcement. See docs/enforcement-boundary.md.

Install

pip install agentguard47

Verify the install:

agentguard doctor

Quick Start (4 lines)

from agentguard import Tracer, BudgetGuard, patch_openai

budget = BudgetGuard(max_cost_usd=5.00, warn_at_pct=0.8)
tracer = Tracer(service="support-agent")
patch_openai(tracer, budget_guard=budget)
# Chat Completions are tracked. Exhausted recorded budget refuses the next dispatch.

Guards

Guard What it stops Example
BudgetGuard Dollar/token/call overruns BudgetGuard(max_cost_usd=5.00)
LoopGuard Exact repeated tool calls LoopGuard(max_repeats=3)
FuzzyLoopGuard Similar calls, A-B-A-B patterns FuzzyLoopGuard(max_tool_repeats=5)
TimeoutGuard Wall-clock time limits TimeoutGuard(max_seconds=300)
RateLimitGuard Calls-per-minute throttling RateLimitGuard(max_calls_per_minute=60)
RetryGuard Retry storms on flaky tools RetryGuard(max_retries=3)

Guards raise exceptions (BudgetExceeded, LoopDetected, TimeoutExceeded, RetryLimitExceeded) on instrumented paths. They do not intercept host tools or provider invoices.

One-Liner Init with Defaults

import agentguard

agentguard.init(local_only=True)
# Reads .agentguard.json if present, sets up tracer + budget guard with sensible defaults

Or drop a .agentguard.json in your repo root:

{
  "profile": "coding-agent",
  "service": "my-agent",
  "trace_file": ".agentguard/traces.jsonl",
  "budget_usd": 5.0
}

Tracing

from agentguard import Tracer, JsonlFileSink, BudgetGuard

tracer = Tracer(
    sink=JsonlFileSink("traces.jsonl"),
    guards=[BudgetGuard(max_cost_usd=5.00)],
)

with tracer.trace("agent.run") as span:
    span.event("reasoning", data={"thought": "search docs"})
    span.cost.add("gpt-4o", input_tokens=1200, output_tokens=450)

Read the full file on GitHub · 125 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed 65968a135492
  2. 2mo ago Changed 3f6130f585fd
  3. 2mo ago Changed · +1 lines · -1 tokens per session 21bdb36400e5
  4. 2mo ago Changed 77092084f2d4
  5. 2mo ago Changed 189cddfbde52
  6. 2mo ago Changed 0ba6a2cadf74
  7. 3mo ago First seen · 124 lines · 38 tokens per session scan A c2a75bd6797d

Subscribe to this mod's changes

agentguard is a skill published in the GitHub repository bmdhodl/agent47 (4 stars, last pushed 18d ago), licensed MIT. It adds 37 tokens to every session and 965 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

agentguard compared with skills from other repositories

agentguard next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
agentguardbmdhodl/agent47Skill418d agoMITA37Claude Code, Codex
llamaguarddavila7/claude-code-templatesSkill35ktodayMITA74Claude Code, Codex
safety-scanningMaxwellCalkin/sentinel-aiSkill278mo agoApache-2.0A52Claude Code
shieldkobepaw/goop-shield-communitySkill27mo agoApache-2.0A67Claude Code
nemo-guardrailsdavila7/claude-code-templatesSkill35ktodayMITB61Claude Code, Codex
rust-string-enumsBerriAI/litellmSkill64ktodaynoneA41Claude Code, Codex
rust-tracingBerriAI/litellmSkill64ktodaynoneA28Claude Code, Codex