# Safe Command Guardrails for Coding Agents

> Block, confirm, or allow every shell, git, SQL, and cloud command before your agent runs it, and catch credential leaks on the way.

Safe Command Guardrails for Coding Agents is a free AI agent skill on Agensi by Korey Dillon, in Security. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Korey Dillon](https://www.agensi.io/creators/korey-dillon)
- Category: [Security](https://www.agensi.io/skills/security)
- Uses: 1
- Version: 1.0
- Last updated: 2026-10-13
- Security: scan passed (2026-10-13); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/safe-command-guardrails-for-coding-agents
- Tags: security, devops, ai-agents, shell-scripting, python, guardrails, git, secrets

## About this skill

Coding agents run commands constantly, and most of the time that is fine. The problem is the one command in a thousand that force-pushes over a teammate's work, truncates a table, or echoes an API key into a shared transcript. This skill gives your agent a clear, four-tier rule for deciding what to run.

**BLOCK** covers damage no project can justify: deleting root or home, formatting disks, fork bombs. **SECRET** covers anything that would print, stage, or upload a credential. **CONFIRM** covers recursive deletes, pushes, history rewrites, destructive SQL, infrastructure teardown, and package publishing. Everything else is **ALLOW**. The agent refuses the first two, asks before the third, and runs the fourth.

The SKILL.md is advisory. It teaches the agent how to decide and when autonomous mode does and does not count as consent. For a hard stop that does not depend on the model's judgment, the package includes a standard-library Python script that applies the same tiers mechanically and returns a distinct exit code per tier. A reference page shows how to wire it as a Claude Code PreToolUse hook in a few lines of settings.json, and how other agents can call it from their own pre-exec hooks. If the script ever breaks, it fails open with a warning, so it never silently locks you out.

Every pattern lives in a readable reference file so you can tune the lists for your project. The script ships with a self-test you can run after any change. Patterns are conservative on purpose: a grep for a dangerous string is allowed, while the same string inside bash -c is blocked.

Built by Korey Dillon (LatentAxis). Source: https://github.com/koreydillon/cipher-harness

## Known limitations

The SKILL.md is advisory: the agent follows it by judgment. For a hard stop, wire the included script as a pre-execution hook (Claude Code PreToolUse is documented). Patterns are regex based and conservative, so an obfuscated command (base64 piped to sh, a script file that deletes things) can get through. Treat it as a strong floor, not a sandbox.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Safe Command Guardrails for Coding Agents skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How does this skill keep my agent safe?

It gives the agent a four-tier rule for every shell, git, SQL, and cloud command. BLOCK commands (like deleting root or formatting a disk) are refused. SECRET commands (printing, staging, or uploading a credential) are refused. CONFIRM commands (recursive deletes, pushes, history rewrites, destructive SQL, infrastructure teardown) wait for your yes. Everything else runs normally.

### Which agents does it work with?

Any agent that reads SKILL.md files, including Claude Code, Cursor, GitHub Copilot, Codex CLI, and Gemini CLI. The optional enforcement script works with any agent that can run a command before executing one. Wiring it as a Claude Code PreToolUse hook is documented step by step.

### What is in the package?

SKILL.md with the decision procedure, scripts/check_command.py (Python 3.8+, standard library only, with --json, --hook, and --self-test modes), references/patterns.md with every regex by tier, and references/claude-code-hook.md with the settings.json snippet, failure behavior, and interpreter notes.

### Does it treat production differently?

The SKILL.md tells the agent to look for production signals before its first mutating command, such as production environment variables, hosted database hosts, or a kube context containing prod. If one appears, it confirms the target with you first. That check is part of the agent instructions; the script itself classifies commands only.

### What happens if the hook script breaks?

It fails open with a one-line warning. Malformed input, empty input, or an internal error lets the command fall through to your normal permission flow instead of blocking every Bash call. If python3 is missing from PATH, Claude Code shows a non-blocking notice. The reference file covers all five cases.

### What can it not catch?

Patterns are regex based, so deliberately obfuscated commands (encoded payloads piped to a shell, or a script file that does the damage) can get past the script. The SKILL.md asks the agent to read scripts before running them, but treat this as a strong floor, not a sandbox.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
