guard

A safety tool for analysing JSON before it is submitted as context to a language model. It can reduce data, estimate token use, sample records, detect targeted queries, and decide whether to allow or block submission.

In plain words
What is it for?
Use it to inspect inline JSON or files in analysis, summary, or forensic mode, with options for sampling, token budgets, warnings, and report-only output.
Why use it?
It helps avoid making confident decisions from incomplete context and helps keep large JSON inputs within a chosen size.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/pjuniszewski/cook/guard
Any agent
npx skills add PJuniszewski/cook --skill guard
Clone the repo
git clone --depth 1 https://github.com/PJuniszewski/cook

Made for: Claude Code, Codex.

Per session 12 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 530 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00012 $0.00530
Opus 5 $0.00006 $0.00265
Sonnet 5 $0.00002 $0.00106
Haiku 4.5 $0.00001 $0.00053

Measured 2d ago against content hash db502425cacf, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

guard 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 2d 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.

.claude/skills/guard/SKILL.md · 76 lines

How it starts

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

Context Guard Skill

Epistemic safety analysis for JSON data in prompts. Prevents LLMs from reasoning with unjustified certainty when input data is incomplete.

Features

  • Lossless reduction - Minify, columnar transform, remove nulls
  • Token counting - API or heuristic fallback
  • Decision engine - ALLOW / SAMPLE / BLOCK
  • Intelligent trimming - First + last + evenly-spaced sampling
  • Forensic detection - Warns when specific record queries detected

Usage

When /guard is invoked, execute the guard script:

For file paths:

python3 "${CLAUDE_PLUGIN_ROOT}/scripts/guard_cmd.py" "<file_path>" [options]

For inline JSON data:

python3 "${CLAUDE_PLUGIN_ROOT}/scripts/guard_cmd.py" - [options] <<'GUARD_INPUT'
<json_data>
GUARD_INPUT

Options

Option Description
--mode analysis|summary|forensics (default: auto-detect)
--force Bypass blocks, emit warnings only
--allow-sampling Permit sampling for forensic queries
--no-reduce Skip lossless reduction phase
--budget-tokens N Token budget (default: 3500)
--print-only Output report only, never auto-send
--json Output result as JSON

Semantic Modes

Mode Sampling Use Case
analysis Allowed "What categories exist?", "Price range?"
summary Aggressive "Describe the data structure"
forensics BLOCKED "Why did request id=X fail?"

Output

============================================================
CONTEXT GUARD ANALYSIS
============================================================

Decision: [OK] ALLOW | [~] SAMPLE | [X] BLOCK
Mode: analysis | summary | forensics

TOKEN ANALYSIS:
  Original:     5,234 tokens
  After reduce: 4,891 tokens (-343)
  Budget:       3,500 tokens
============================================================

Requirements

  • Python 3.8+
  • ANTHROPIC_API_KEY environment variable (for token counting)

Read the full file on GitHub · 76 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. 2d ago First seen · 76 lines · 12 tokens per session scan A db502425cacf

Subscribe to this mod's changes

guard is a skill published in the GitHub repository PJuniszewski/cook (13 stars, last pushed 6mo ago), licensed MIT. It adds 12 tokens to every session and 530 once invoked, about $0.0001 per session on Opus 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-30.

Related

Other skills, from other repositories

ai-cost-token-optimizer

Expert guide for LLM API cost optimization, Prompt Caching, model routing (Flash/Pro/Opus), semantic caching, and token budgeting / Panduan ahli optimasi biaya API LLM, Prompt Caching, model routing, dan semantic caching.

roedyrustam/vibes-plug · 57 tokens

ai-prompt-engineering-expert

Expert guide for systematic Prompt Engineering, Chain-of-Thought, few-shot prompting, structured output (JSON mode), prompt versioning, and LLM evaluation / Panduan ahli rekayasa prompt dan evaluasi LLM.

roedyrustam/vibes-plug · 52 tokens

ai-product

Every product will be AI-powered. The question is whether you'll build it right or ship a demo that falls apart in production. This skill covers LLM integration patterns, RAG architecture, prompt engineering that scales, AI UX that users trust, and cost optimization that doesn't bankrupt you. Use when "keywords…

omer-metin/skills-for-antigravity · 74 tokens

constraint-driven-development

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or…

addyosmani/agent-skills · 154 tokens

test-driven-development

Drives development with tests. Use when implementing any logic, fixing any bug, or changing any behavior. Use when you need to prove that code works, when a bug report arrives, or when you're about to modify existing functionality.

addyosmani/agent-skills · 50 tokens

deprecation-and-migration

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.

addyosmani/agent-skills · 45 tokens