# Guard

> Analyze and prepare prompts with JSON for safe context submission

- **Type:** Skill
- **Install:** `agentstack add skill-pjuniszewski-cook-guard`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [PJuniszewski](https://agentstack.voostack.com/s/pjuniszewski)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [PJuniszewski](https://github.com/PJuniszewski)
- **Source:** https://github.com/PJuniszewski/cook/tree/main/.claude/skills/guard

## Install

```sh
agentstack add skill-pjuniszewski-cook-guard
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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:
```bash
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/guard_cmd.py" "" [options]
```

### For inline JSON data:
```bash
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/guard_cmd.py" - [options] 
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)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [PJuniszewski](https://github.com/PJuniszewski)
- **Source:** [PJuniszewski/cook](https://github.com/PJuniszewski/cook)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-pjuniszewski-cook-guard
- Seller: https://agentstack.voostack.com/s/pjuniszewski
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
