# Guard

> Analyze and prepare prompts with JSON for safe context submission

- Skill: `pjuniszewski/guard` (Agent Skill)
- Install (CLI): `npx skillmds@latest add pjuniszewski/guard`
- Raw SKILL.md: https://api.skillmd.com/api/skills/pjuniszewski/guard/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: PJuniszewski (https://skillmd.com/u/pjuniszewski)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/pjuniszewski/guard

---


# 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" "<file_path>" [options]
```

### For inline JSON data:
```bash
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)

