# Pre-Action Guard

> A QA gate that validates potentially destructive or irreversible actions before execution.

- **Type:** Skill
- **Install:** `agentstack add skill-sounder25-foundational-agent-skills-18-pre-action-guard`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [Sounder25](https://agentstack.voostack.com/s/sounder25)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [Sounder25](https://github.com/Sounder25)
- **Source:** https://github.com/Sounder25/Foundational-Agent-Skills/tree/main/18_pre_action_guard

## Install

```sh
agentstack add skill-sounder25-foundational-agent-skills-18-pre-action-guard
```

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

## About

# SKILL-018: Pre-Action Guard

## Overview

Enforces a **"Measure Twice, Cut Once"** philosophy. This skill intercepts high-stakes actions (file writes, command execution) and validates them against safety rules and the current active plan to prevent accidental data loss or system corruption.

## Trigger Phrases

- `check safety`
- `verify action`
- `is this safe`
- `guard check`

## Inputs

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `--Action` | string | Yes | - | The tool/verb being performed (e.g. `write_to_file`, `rm`) |
| `--Target` | string | Yes | - | The file path or command argument |
| `--Plan` | string | No | $null | The current plan context for alignment check |

## Outputs

### 1. Assessment Result (JSON)

```json
{
  "allowed": false,
  "risk_level": "CRITICAL",
  "reason": "Root directory deletion detected.",
  "warnings": ["Target matches blocked pattern '/*'."]
}
```

### 2. Risk Levels

- `NONE`: Read-only operations.
- `LOW`: Safe writes (files in temp, new files).
- `MEDIUM`: Modifying existing non-critical files.
- `HIGH`: Modifying config/env files.
- `CRITICAL`: Destructive delete/format commands.

## Preconditions

1. Valid tool/action inputs.
2. PowerShell 5.1+ or Core 7+.

## Safety/QA Checks

1. **Auto-Block**: Root deletions (`/`, `C:\`) are automatically blocked.
2. **Context Awareness**: Checks `.env` and `config` keywords for higher sensitivity.
3. **Command-Only Discipline**:
   - Rejects output containing shell prompts (`PS C:\`, `>`).
   - Rejects lines that look like terminal output (e.g., `Everything up-to-date`, `At line:`, `CategoryInfo:`).
   - Rejects mixed snippets containing both commands and output.
   - **Enforcement**: All runnable commands must be isolated in a clean, validated block.

## Stop Conditions

| Condition | Action |
|-----------|--------|
| Missing Action/Target | Return error |
| CRITICAL risk | Return `allowed: false` |
| Mixed Output Detected | Return `allowed: false` |

## Implementation

See `scripts/guard_check.ps1`.

## Integration with Other Skills

**All agents must:**

1. Call this skill BEFORE running `write_to_file` on existing files.
2. Call this skill BEFORE running any `run_command` containing `rm`, `del`, `drop`.
3. If `allowed` is false, **STOP** and ask user for confirmation.

## Source & license

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

- **Author:** [Sounder25](https://github.com/Sounder25)
- **Source:** [Sounder25/Foundational-Agent-Skills](https://github.com/Sounder25/Foundational-Agent-Skills)
- **License:** Apache-2.0

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:** yes
- **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-sounder25-foundational-agent-skills-18-pre-action-guard
- Seller: https://agentstack.voostack.com/s/sounder25
- 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%.
