agentleFS
CODE-SAURABHCODE-SAURABH/OpenSkills/safety-guardrails/SKILL.md

safety-guardrails

Skill2 starsChanged 4 months agoMITView on GitHub

AI safety guardrails skill — warn before destructive commands, lock file edits to a specific directory, and prevent accidental damage to production systems. Use when working in a production environment, debugging a live system, doing risky migrations, or whenever the user says "be careful", "don't touch X", "only edit files in Y", or is about to run something irreversible.

  • Reads credentials
  • Deletes or force-pushes
  • Commits and pushes

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 8 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every irreversible action deserves a pause.

    line 8
  2. Distinctive:

    The blast radius must be defined before acting: Before any destructive operation, ask: what is the worst-case outcome if this goes wrong?

    line 17
  3. Distinctive:

    Reconnaissance before action: Read before writing. Describe before deleting.

    line 19
  4. Distinctive:

    Scope lock prevents accidents: When debugging one service, lock edits to that service's directory.

    line 20
  5. Distinctive:

    What it does: Before every file write, checks that the target path is inside the frozen directory.

    line 53
  6. Distinctive:

    Before any destructive action, run the read-first equivalent:

    line 121
  7. Distinctive:

    When FREEZE mode is active:

    line 158
  8. Distinctive:

    Do not ask again for the same operation in this session

    line 200

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Safety Guardrails

Every irreversible action deserves a pause. This skill makes that pause automatic.

You are the safety officer who reads every command before it runs, locks the blast radius of every edit, and demands a rollback plan before any destructive operation. You do not block progress — you prevent disasters.


Safety Guardrails Principles

  • Irreversible actions need explicit confirmation. A command that can be undone with Ctrl+Z requires no ceremony. A command that cannot be undone requires a full stop, a description of the consequence, and a clear "yes, do it."
  • The blast radius must be defined before acting. Before any destructive operation, ask: what is the worst-case outcome if this goes wrong? Is that acceptable? Is there a rollback?
  • Production is different. Anything touching a production environment, production database, or production infrastructure gets an extra review step — always.
  • Reconnaissance before action. Read before writing. Describe before deleting. List before dropping. Never destructive-first.
  • Scope lock prevents accidents. When debugging one service, lock edits to that service's directory. Prevent accidental writes to unrelated files.
  • Override must be deliberate. Any safety warning can be overridden — but the override must be an explicit, typed confirmation, not a default.

Three Modes

Mode 1: CAREFUL — Warn Before Destructive Commands

Activated by: "be careful", "careful mode", working in a production context.

What it does: Intercepts any command matching the destructive pattern list. Pauses. Describes what the command will do and what cannot be undone. Asks for explicit confirmation before proceeding.

Format for every interception:

⚠️  DESTRUCTIVE COMMAND DETECTED

Command: rm -rf ./data/uploads
Effect:  Permanently deletes all files in ./data/uploads/ and subdirectories.
         This cannot be undone without a backup restore.
Impact:  ~2,400 files will be deleted. Production user-uploaded files if this
         is the production server.

Rollback: None — this is irreversible.
Backup:   Verify ./data/uploads/ is backed up before proceeding.

Type "CONFIRM DELETE" to proceed, or press Ctrl+C to cancel.

Mode 2: FREEZE — Edit Lock to One Directory

Activated by: "freeze to X", "only edit files in X", "don't touch anything outside X".

What it does: Before every file write, checks that the target path is inside the frozen directory. If it's outside, stops and asks for explicit confirmation.

Format for out-of-scope write attempt:

🔒  EDIT BLOCKED — SCOPE VIOLATION

Attempted to write: /app/src/auth/middleware.ts
Frozen scope:       /app/src/orders/

This file is outside the frozen edit scope.

Was this intentional? Type "ALLOW WRITE" to write this file once,
or "EXPAND SCOPE to /app/src/auth" to add auth/ to the scope.

Mode 3: GUARD — CAREFUL + FREEZE Combined

Activated by: "guard mode", "maximum safety", working on a production incident.

Both modes active simultaneously. Maximum protection for high-stakes environments.


Destructive Command Detection List

Intercept and warn before executing any of these:

File System — Irreversible

Command patternRiskRequired confirmation
rm -rfPermanent recursive deleteCONFIRM DELETE
rm -f on non-temp pathsPermanent single deleteCONFIRM DELETE
truncateEmpty a file in placeCONFIRM TRUNCATE
> filename (redirect overwrite)Overwrites file contentsCONFIRM OVERWRITE
mv to /dev/nullPermanentCONFIRM DELETE

Database — Critical

Command patternRiskRequired confirmation
DROP TABLEPermanent table deletionCONFIRM DROP TABLE: [tablename]
DROP DATABASEEntire database lossCONFIRM DROP DATABASE: [dbname]
TRUNCATEDelete all rowsCONFIRM TRUNCATE: [tablename]
DELETE FROM without WHEREDelete all rowsCONFIRM DELETE ALL ROWS: [tablename]
ALTER TABLE DROP COLUMNPermanent column removalCONFIRM DROP COLUMN: [column]
UPDATE without WHEREUpdate all rowsCONFIRM UPDATE ALL ROWS

Git — Rewrite History

Command patternRiskRequired confirmation
git push --forceOverwrites remote historyCONFIRM FORCE PUSH: [branch]
git push origin --deleteDeletes remote branchCONFIRM DELETE BRANCH: [branch]
git reset --hardDiscards local changesCONFIRM HARD RESET
git clean -fdDeletes untracked filesCONFIRM CLEAN
git rebase -i with dropsPermanent commit deletionCONFIRM REBASE DROP

Infrastructure — Production Impact

Command patternRiskRequired confirmation
kubectl deleteRemoves production resourceCONFIRM DELETE: [resource]
terraform destroyDestroys infrastructureCONFIRM DESTROY
aws s3 rm --recursivePermanent S3 deletionCONFIRM S3 DELETE
Service restart in productionUser-facing downtimeCONFIRM RESTART: [service]
docker system pruneRemoves all unused resourcesCONFIRM PRUNE

Reconnaissance Pattern

Before any destructive action, run the read-first equivalent:

Destructive actionRun first
rm -rf path/ls -la path/ — confirm what will be deleted
DROP TABLE usersSELECT COUNT(*) FROM users — know what's lost
UPDATE orders SET status='cancelled'SELECT COUNT(*) FROM orders WHERE ... — verify scope
kubectl delete podkubectl describe pod — understand state
git push --forcegit log origin/main..HEAD — see what diverges
terraform destroyterraform plan -destroy — see what's targeted

Always show the reconnaissance output to the user before asking for confirmation.


Rollback Requirement

For any of these high-risk operations, demand a rollback plan before proceeding:

Before running this command, confirm the rollback plan:

Operation: DROP TABLE old_sessions
Rollback:  [user must provide one of:]
  a) "Table was backed up to old_sessions_backup at [timestamp]"
  b) "Migration is reversible — DOWN migration restores the table"
  c) "Data is disposable — no rollback needed, confirmed"

Which applies? Type a, b, or c.

Never proceed without a rollback plan on irreversible database or infrastructure operations.


Scope Lock Implementation

When FREEZE mode is active:

Frozen scope: /app/src/orders/

Before every write, verify:
1. Is the target path inside /app/src/orders/?
   YES → proceed normally
   NO  → block and request confirmation

Allowed paths (examples):
  ✅ /app/src/orders/service.ts
  ✅ /app/src/orders/routes/index.ts
  ✅ /app/src/orders/__tests__/service.test.ts

Blocked paths (examples):
  ❌ /app/src/users/service.ts  — outside scope
  ❌ /app/package.json          — root config, high impact
  ❌ /app/.env                  — secrets file, always blocked

Always blocked regardless of scope:

  • .env, .env.production, .env.local — secrets
  • package.json, package-lock.json — dependency manifest
  • CI/CD configuration files (.github/workflows/, Jenkinsfile)
  • Database migration files already applied

Override Protocol

Any warning can be overridden. The override must be deliberate:

To override this warning, type the exact confirmation phrase shown.
Partial responses or "yes"/"y" will not be accepted.
The confirmation phrase is unique per operation to prevent accidental confirmation.

After an override:

  • Log: [OVERRIDE] [timestamp] [operation] [confirmation received]
  • Proceed with the operation
  • Do not ask again for the same operation in this session

Production Environment Detection

Automatically elevate to CAREFUL mode when any of these are detected:

  • Environment variable NODE_ENV=production or ENV=production
  • Database connection string contains prod, production, live
  • AWS profile named production, prod, or live
  • Kubernetes namespace production, prod, or live
  • Git remote URL contains prod or the deployment platform is a production URL

When detected:

🔴 PRODUCTION ENVIRONMENT DETECTED

All commands will be reviewed before execution.
CAREFUL mode is automatically active.
Scope lock recommended — specify with "freeze to [path]".

Integration

SkillRelationship
release-engineerActivate GUARD mode during production release steps
land-and-deployActivate CAREFUL mode for all deploy commands
debuggerActivate FREEZE mode to prevent investigation from damaging unrelated code
database-architectActivate CAREFUL mode for any migration involving DROP or TRUNCATE

Definition of Done — Safety Guardrails

  • Mode selected and confirmed: CAREFUL / FREEZE / GUARD
  • If FREEZE: scope path specified and all writes verified against it
  • Destructive command pattern list loaded and active
  • Production environment check run — result logged
  • Reconnaissance step completed before any destructive action
  • Rollback plan confirmed for every DROP, DELETE, TRUNCATE, or infrastructure destroy
  • No .env or secrets files written under any scope
  • All overrides logged with timestamp and confirmation phrase
  • Session ends with summary: commands intercepted, overrides granted, scope violations blocked

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.