Security · Review & audit
safety-validator
/safety-validator
Use when reviewing proposed infrastructure commands before execution that may contain high-risk or destructive operations
- Author
- yg-codes ↗
- Repository
- srepowers ↗
- Licence
- MIT
- Last repository change
- 09.11.2026
Assessment and security
100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
- Files in this package
- 2
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
Deprecation
No signals detected. Repository changed on 09.11.2026, without references to retired models or APIs.
Licence
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Use when reviewing proposed infrastructure commands before execution that may contain high-risk or destructive operations
Original author description
Use when reviewing proposed infrastructure commands before execution that may contain high-risk or destructive operations
How it works
- Overview
- When to Use
- Risk Classification
- The Validation Process
- Validation Rules
- Safe Alternatives
- SRE Principles
- Integration
- Example Workflows
- Red Flags
Original SKILL.md headings · 481 lines, 1,946 words
SKILL.md preview
---
name: safety-validator
description: Use when reviewing proposed infrastructure commands before execution that may contain high-risk or destructive operations
---
# Safety Validator
## Overview
Review proposed infrastructure commands before execution to catch dangerous operations. Acts as a safety net to prevent accidental data loss or service disruption.
**Core principle:** Explicit confirmation for destructive operations prevents accidents.
**Announce at start:** "I'm using the safety-validator skill to review these commands before execution."
## When to Use
**Always for:**
- Destructive operations (delete, remove, drop)
- Broad-scope operations (wildcards, "all", "*")
- Production environment changes
- Irreversible operations
- Commands generated by automation
**Use before:**
- Executing generated commands
- Running bulk operations
- Applying changes to production
- Executing unfamiliar commands
## Risk Classification
### 🔴 Critical Risk - Block Without Explicit Confirmation
| Pattern | Example | Why Dangerous |
|---------|---------|---------------|
| `rm -rf /` | `rm -rf /data` | Recursive deletion from root |
| `kubectl delete all` | `kubectl --context <context> delete all --all-namespaces` | Deletes everything |
| `DROP DATABASE` | `DROP DATABASE production` | Irreversible data loss |
| `terraform destroy` | `terraform destroy -auto-approve` | Destroys all infrastructure |
| `dd if=/dev/zero` | `dd if=/dev/zero of=/dev/sda` | Overwrites disk |
### 🟠 High Risk - Require Typed Confirmation
| Pattern | Example | Why Dangerous |
|---------|---------|---------------|
| `kubectl delete` | `kubectl --context <context> delete deployment api` | Deletes running workloads |
| `aws ec2 terminate` | `aws ec2 terminate-instances` | Destroys instances |
| `docker system prune` | `docker system prune -a` | Removes all containers/images |
| `git push --force` | `git push --force origin main` | Overwrites history |
| Database modifications | `ALTER TABLE DROP COLUMN` | Schema changes |
### 🟡 Medium Risk - Warn and Confirm
| Pattern | Example | Why Caution |
|---------|---------|-------------|
| `kubectl apply` | `kubectl --context <context> apply -f production/` | Changes production state |
| `terraform apply` | `terraform apply` | Modifies infrastructure |
| Package removal | `apt remove` | Removes dependencies |
| Service restart | `systemctl restart` | Causes brief outage |
### 🟢 Low Risk - Proceed with Log
| Pattern | Example | Notes |
|---------|---------|-------|
| `kubectl get` | `kubectl --context <context> get pods` | Read-only |
| `terraform plan` | `terraform plan` | Non-destructive |
| `ls`, `cat`, `grep` | `ls -la` | Safe read operations |
## The Validation Process
### Step 1: Parse Commands
Break down compound commands:
```bash
# Compound command
kubectl --context <context> delete deployment api && kubectl --context <context> delete service api
# Parsed as:
# 1. kubectl --context <context> delete deployment api
# 2. kubectl --context <context> delete service api
```
### Step 2: Pattern Matching
Check each command against risk patterns:
```python
# Example pattern matching logic
RISK_PATTERNS = {
'critical': [
r'rm\s+-rf\s+/',
r'kubectl\s+delete\s+all',
r'DROP\s+DATABASE',
r'terraform\s+destroy',
r'zpool\s+upgrade',
r'qm\s+destroy',
r'pvecm\s+delnode',
r'qm\s+migrate.*--force',
],
'high': [
r'kubectl\s+delete',
r'aws\s+.*\s+terminate',
r'docker\s+system\s+prune',
r'git\s+push\s+.*--force',
r'zfs\s+destroy\s+-r',
r'pvesr\s+delete.*-job',
r'apt\s+dist-upgrade',
r'\breboot\b',
],
'medium': [
r'kubectl\s+apply',
r'terraform\s+apply',
r'systemctl\s+restart',
r'pvesm\s+set.*--disable',
r'ha-manager\s+remove',
],
}
```
### Step 3: Risk Assessment
```bash
# Example assessment output
=== Safety Validation Report ===
Command: kubectl --context <context> delete deployment api-server -n production
Risk Level: 🔴 HIGH
Category: Workload Deletion
Impact: Service outage for api-server in production
Why this is dangerous:
- Deletes running deployment
- Causes immediate service outage
- Data in memory will be lost
Verification questions:
- [ ] Is this deployment no longer needed?
- [ ] Is traffic routed elsewhere?
- [ ] Is data backed up/persisted?
Safe alternatives to consider:
1. Scale to zero: kubectl --context <context> scale deployment api-server --replicas=0
2. Drain pods: kubectl --context <context> drain --ignore-daemonsets
3. Apply maintenance page first
Rollback plan:
kubectl --context <context> apply -f api-server-deployment.yaml # Reapply if needed
Type 'delete-api-server-production' to confirm execution:
```
### Step 4: Confirmation
Require typed confirmation for high/critical risk:
```bash
# Critical risk - require exact phrase
read -p "Type the confirmation phrase exactly: " confirmation
if [ "$confirmation" != "delete-api-server-production" ]; then
echo "Confirmation mismatch. Aborting."
exit 1
fi
```
## Validation Rules
### Kubernetes Commands
```yaml
rules:
- pattern: "kubectl delete.*--all"
risk: critical
message: "Deleting all resources of a type"
- pattern: "kubectl delete.*-n.*(prod|production)"
risk: high
message: "Deleting production resources"
- pattern: "kubectl delete.*deployment"
risk: high
message: "Deleting deployment will cause outage"
- pattern: "kubectl apply.*-f.*prod"
risk: medium
message: "Applying changes to production"
```
### Terraform Commands
```yaml
rules:
- pattern: "terraform destroy"
risk: critical
message: "Will destroy all managed infrastructure"
- pattern: "terraform apply.*-auto-approve"
risk: high
message: "Auto-approve bypasses plan review"
- pattern: "terraform apply"
risk: medium
message: "Will modify infrastructure"
```
### Database Commands
```yaml
rules:
- pattern: "DROP\s+(DATABASE|TABLE)"
risk: critical
message: "Irreversible data deletion"
- pattern: "DELETE\s+FROM"
risk: high
message: "Data deletion without WHERE clause?"
- pattern: "ALTER\s+TABLE.*DROP"
risk: high
message: "Schema modification - data may be lost"
```
### File System Commands
```yaml
rules:
- pattern: "rm\s+-rf\s+/"
risk: critical
message: "Recursive deletion from root"
- pattern: "rm\s+-rf"
risk: high
message: "Recursive force deletion"
- pattern: ">\s+/etc/"
risk: high
message: "Modifying system configuration"
```
### Remote / SSH Writes (read-only-host protection)
A write against a non-local host is a mutation regardless of intent. This
category catches commands that write to a remote host even when the *overall
task* was classified as read-only — the most common cause of READONLY-host
violations ("I just wanted to verify the command works"). If the target host
is under a READONLY approval (UAT twin, shared box, someone else's system),
**block the write regardless of risk level** and require explicit approval
for that specific write.
```yaml
rules:
- pattern: "ssh\\s+[^|]*\\b(cp|mv|tee|touch|mkdir|rm)\\b"
risk: high
message: "Write over SSH to a remote host — mutation, not read-only. If host is under READONLY approval, block."
- pattern: "ssh\\s+[^|]*>\\s*\\S"
risk: high
message: "Redirect over SSH writes to a remote host — mutation. Check READONLY approval scope."
- pattern: "\\bscp\\b"
risk: medium
message: "Copies a file to a remote host. Verify destination is in approval scope; stage to /tmp and verify, not blind overwrite."
- pattern: "\\brsync\\b.*::|\\brsync\\b.*@"
risk: medium
message: "Transfers files to a remote target. Confirm approval scope and use -n / --dry-run first."
- pattern: "(podman|docker)\\s+exec\\s+.*\\b(cp|mv|tee|touch|mkdir|rm)\\b"
risk: high
message: "Write inside a container (often a remote/shared service). Mutation — verify the exec user (-u) has scope to write, and that the host allows it."
- pattern: "(podman|docker)\\s+exec\\s+.*>"
risk: high
message: "Redirect inside container exec writes to the container fs. Mutation, not read-only."
- pattern: "parallel-(ssh|scp|rsync)"
risk: high
message: "Fan-out write to many hosts — high blast radius. Confirm every target host is in approval scope before running."
```
**READONLY-host rule (hard block):** if the target host of any of the above
was approved for **read-only** access only, the write is out of scope. Do not
execute it even as a "probe" or "test file." To verify a command's
correctness on a READONLY host, reason about it (perms, user context, paths)
or run it against a truly local/ephemeral target — never the shared host.
```yaml
rules:
- pattern: "zpool\s+upgrade"
risk: critical
message: "Pool cannot be imported by older ZFS versions. Irreversible."
- pattern: "qm\s+destroy"
risk: critical
message: "Permanently deletes VM and all disks"
- pattern: "pvecm\s+delnode"
risk: critical
message: "Permanent cluster removal. Cannot rejoin without full re-provision."
- pattern: "qm\s+migrate.*--force"
risk: critical
message: "Bypasses safety checks during migration"
- pattern: "zfs\s+destroy\s+-r"
risk: high
message: "Recursive irreversible data loss"
- pattern: "zfs\s+destroy\s+"
risk: medium
message: "Destroys dataset and dependent snapshots. Use zfs destroy -n to preview."
- pattern: "pvesr\s+delete.*-job"
risk: high
message: "Destroys replication configuration and failover capability"
- pattern: "apt\s+dist-upgrade.*-y"
risk: high
message: "Major upgrade without draining VMs or draining quorum"
- pattern: "\breboot\b"
risk: high
message: "Unclean VM shutdown if guests still running. Drain first."
note: "Flags the reboot command, not the word in comments or documentation."
- pattern: "pvesm\s+set.*--disable\s+1"
risk: medium
message: "Disables storage for all VMs using it"
- pattern: "ha-manager\s+remove"
risk: medium
message: "Removes HA protection from managed resource"
```
## Safe Alternatives
### Instead of Delete
| Dangerous | Safer Alternative |
|-----------|-------------------|
| `kubectl delete deployment` | `kubectl --context <context> scale deployment --replicas=0` |
| `rm -rf /data` | `mv /data /data.backup.$(date +%s)` |
| `DROP TABLE` | `RENAME TABLE old_table TO old_table_backup` |
| `terraform destroy` | `terraform plan -destroy` (review first) |
### Instead of Force
| Dangerous | Safer Alternative |
|-----------|-------------------|
| `git push --force` | `git push --force-with-lease` |
| `kubectl apply --force` | `kubectl --context <context> apply` (normal) |
| `rm -f` | `rm -i` (interactive) |
### Instead of PVE Destructive Operations
| Dangerous | Safer Alternative |
|-----------|-------------------|
| `zpool upgrade <pool>` | `zpool upgrade -n <pool>` (dry-run) — DO NOT upgrade until rollback window closes |
| `qm destroy <vmid>` | `qm snapshot <vmid> pre-delete` → confirm no references → then destroy |
| `zfs destroy -r <dataset>` | `zfs destroy -nrv <dataset>` (dry-run recursive) → verify scope → destroy without `-r` if possible |
| `reboot` on node with VMs | `qm migrate <vmid> <target>` per VM → verify quorum → then reboot |
| `pvesr delete-local-job <id>` | `pvesr verify-local-job <id>` — confirm replication target is healthy first |
| `apt dist-upgrade -y` | `apt dist-upgrade --simulate` → review → drain VMs → upgrade one node at a time |
## SRE Principles
### Safety First
- Block critical operations without explicit confirmation
- Suggest safer alternatives
- Require rollback plans for destructive operations
### Structured Output
- Present risk assessment in clear format
- Use consistent risk levels (🔴🟠🟡🟢)
- Show specific reasons for warnings
### Evidence-Driven
- Reference specific command patterns
- Show impact analysis
- Document why operation is risky
### Audit-Ready
- Log all validation decisions
- Record confirmation phrases used
- Track who approved risky operations
### Communication
- Explain risk in business terms
- Suggest alternatives clearly
- Provide rollback instructions
## Integration
**Called by:**
- `test-driven-operation` before GREEN phase
- `subagent-driven-operation` before task execution
- `executing-operation-plans` before batch execution
**Calls:**
- `systematic-troubleshooting` if validation fails
**Pairs with:**
- `verification-before-completion` - Double-check after validation
- `sre-runbook` - Document safe procedures
## Example Workflows
### Safe Deletion Workflow
```bash
# Proposed command
kubectl --context <context> delete deployment legacy-api -n production
# Safety validator intervenes:
# 🔴 HIGH RISK: Deleting production deployment
#
# Suggested alternative:
# kubectl --context <context> scale deployment legacy-api --replicas=0 -n production
#
# This keeps the deployment but scales to zero pods.
# You can scale back up if needed.
#
# Or type 'delete-legacy-api-production' to proceed with deletion.
# User chooses safer alternative:
kubectl --context <context> scale deployment legacy-api --replicas=0 -n production
# Verify:
kubectl --context <context> get deployment legacy-api -n production
# Shows 0/0 replicas - safe to delete now if confirmed not needed
```
### Bulk Operation Workflow
```bash
# Proposed command
kubectl --context <context> delete pods --all -n staging
# Safety validator:
# 🟠 HIGH RISK: Deleting all pods in namespace
#
# Impact: All services in staging will restart
# Duration: 30-60 seconds outage per service
#
# Are you sure? Consider:
# - Are you trying to restart pods? Use 'kubectl --context <context> rollout restart' instead
# - Are you cleaning up? Use label selectors for specific pods
#
# Type 'delete-all-staging-pods' to confirm:
```
## Red Flags
**Never bypass validation when:**
- Command was generated by untrusted source
- Operating on production
- Deleting data
- Modifying critical infrastructure
- You're tired or under pressure
**Always require validation for:**
- Automated scripts
- Bulk operations
- First-time operations
- Operations at 3 AM
## Limitations
**Safety validator cannot:**
- Prevent all accidents (human judgment required)
- Understand business context
- Predict all side effects
- Replace proper testing
**Not a substitute for:**
- Code review
- Testing in staging
- Backup procedures
- Change management process
Files in this package (2)
- README.md 2 KB
- SKILL.md 14 KB
Versions
The database has no other skills named safety-validator.
Database snapshot: 13.11.2026 · package version 2349f7530dae (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Similar skills
- 90agent-guardrail
Safety guardrails for AI coding agents. Enforces confirmation before destructive commands, blocks force pushes and secret access, and keeps agents inside the current repository. Use whenever an agent is about to modify system state, delete data, push to git, or touch credentials. - 100safety-guard
Use this skill to prevent destructive operations when working on production systems or running agents autonomously. - 100jwt-token-validator
Validate jwt token validator operations. Auto-activating skill for Security Fundamentals. Triggers on: jwt token validator, jwt token validator Part of the Security Fundamentals skill category. Use when working with jwt token validator functionality. Trigger with phrases like… - 100cors-policy-validator
Validate cors policy validator operations. Auto-activating skill for Security Fundamentals. Triggers on: cors policy validator, cors policy validator Part of the Security Fundamentals skill category. Use when working with cors policy validator functionality. Trigger with phrases… - 100evidence-hygiene-for-cached-responses
Record edge behaviour without archiving response bodies that may contain personal or session-bound data, keeping the evidence package safe to share with the vendor. Use when collecting responses during an edge assessment where any recorded body might contain account data, tokens or tenant content