Przejdź do treści
Biblioteka skilli
Bezpieczeństwo · Przegląd i audyt

safety-validator

/safety-validator

Przegląda proponowane polecenia infrastrukturalne przed wykonaniem, gdy mogą zawierać ryzykowne lub niszczące operacje. Przydaje się, gdy ktoś chce uruchomić polecenia zmieniające infrastrukturę.

Repozytorium
srepowers ↗
Licencja
MIT
Ostatnia zmiana repozytorium
09.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
2
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 09.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Przegląda proponowane polecenia infrastrukturalne przed wykonaniem, gdy mogą zawierać ryzykowne lub niszczące operacje. Przydaje się, gdy ktoś chce uruchomić polecenia zmieniające infrastrukturę.

Oryginalny opis (EN)

Use when reviewing proposed infrastructure commands before execution that may contain high-risk or destructive operations

Jak działa

  1. Overview
  2. When to Use
  3. Risk Classification
  4. The Validation Process
  5. Validation Rules
  6. Safe Alternatives
  7. SRE Principles
  8. Integration
  9. Example Workflows
  10. Red Flags
Sekcje z nagłówków SKILL.md, w oryginale · 481 linii, 1 946 słów
Podgląd SKILL.md
---
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
Pliki w paczce (2)
  • README.md 2 KB
  • SKILL.md 14 KB

Wersje

W bazie nie ma innych skilli o nazwie safety-validator.

Migawka bazy z 13.11.2026 · wersja paczki 2349f7530dae (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90agent-guardrail
    Pilnuje, by agent kodujący potwierdzał niszczące polecenia, nie wypychał zmian siłowo i nie sięgał do sekretów poza repozytorium.
  • 100safety-guard
    Zapobiega destrukcyjnym operacjom w systemach produkcyjnych i przy autonomicznych agentach. Przydaje się, gdy agent pracuje samodzielnie albo trwa migracja lub wdrożenie.
  • 100jwt-token-validator
    Prawdopodobnie pomaga w walidacji tokenów JWT w ramach podstaw bezpieczeństwa aplikacji.
  • 100cors-policy-validator
    Prawdopodobnie sprawdza polityki CORS w ramach podstaw bezpieczeństwa aplikacji.
  • 100evidence-hygiene-for-cached-responses
    Zapisuje zachowanie brzegu sieci bez archiwizowania treści odpowiedzi, które mogą zawierać dane konta lub tokeny.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.