← Back to Skills Marketplace
jinhuadeng

Command Guardian

by Koi · GitHub ↗ · v1.3.2 · MIT-0
cross-platform ✓ Security Clean
150
Downloads
0
Stars
0
Active Installs
3
Versions
Install in OpenClaw
/install command-guardian
Description
Preflight safety guard for shell and infrastructure commands. Use before running commands that delete, overwrite, move, deploy, rewrite git history, change p...
README (SKILL.md)

Command Guardian

Use this skill before executing commands with non-trivial side effects.

It classifies risk, checks targets against workspace boundaries, looks for obvious secret leakage, inspects compound and nested shell commands, adds lightweight git context when available, and produces rollback guidance before the command is run.

Workflow

  1. Normalize the command, working directory, and allowed roots.
  2. Run the preflight script with one of these input modes:
python {baseDir}/scripts/preflight.py --command "\x3Craw command>" --cwd "\x3Cworking dir>" --allowed-root "\x3Cworkspace root>" --format json
python {baseDir}/scripts/preflight.py --command-file command.txt --cwd "\x3Cworking dir>" --allowed-root "\x3Cworkspace root>" --format json
echo '\x3Craw command>' | python {baseDir}/scripts/preflight.py --cwd "\x3Cworking dir>" --allowed-root "\x3Cworkspace root>" --format json
  1. Read the report and respond by risk level:
  • low: proceed if the command still matches user intent
  • medium: explain the risk briefly and tighten the command if a safer rewrite is obvious
  • high: do not execute blindly; show why, provide a safer version, and require explicit confirmation
  • critical: stop automatic execution; narrow scope, strip secrets, or stage the operation before retrying
  1. Always surface:
  • Risk:
  • Why:
  • Safer rewrite:
  • Rollback:
  • Need approval: yes/no

If safer_commands are available, show them before execution. If the user only asks for analysis, stop at the review. If the user asks to proceed, use the report to tighten the command before execution.

Default Policy

  • Treat inline secrets as at least high risk. If the command embeds active credentials, treat it as critical.
  • Treat destructive operations on broad targets such as ., .., /, drive roots, wildcard-only paths, or repo roots as critical.
  • Treat git push --force, git reset --hard, docker system prune, kubectl delete, and terraform apply/destroy as requiring rollback guidance before execution.
  • Treat curl | sh and similar download-and-execute patterns as critical unless the script is pinned, inspected, and verified.
  • Treat compound commands by the highest-risk segment, not by the first visible token.
  • If the current git branch is main or master, raise the review bar for destructive git commands.

Scripts

Use these scripts directly:

  • scripts/preflight.py Main entrypoint. Supports --command, --command-file, or stdin. Runs command classification, path checks, secret detection, context checks, rollback hint generation, and safer-action suggestions.

  • scripts/classify_command.py Labels command risk and categories such as write, destructive, privileged, and production-impacting.

  • scripts/path_guard.py Resolves candidate paths relative to --cwd, checks whether they escape allowed roots, and flags broad deletion targets.

  • scripts/secret_guard.py Detects obvious inline secrets such as bearer tokens, JWTs, AWS keys, GitHub PATs, and suspicious key/value pairs.

  • scripts/rollback_hints.py Produces rollback and pre-change backup guidance for git, kubectl, terraform, docker, npm, and destructive file operations.

References

Read these only when needed:

  • references/risk-rules.md Risk rubric, approval thresholds, and examples of broad targets and secret exposure.

  • references/tool-patterns.md Tool-specific review notes for git, docker, kubectl, terraform, curl/wget, npm/pip/cargo, and file operations.

Response Template

Use this shape in your answer:

Risk: high
Why:
- rewrites shared git history
- no rollback checkpoint was created

Safer commands:
- git branch backup/pre-force-push-main HEAD
- git push --force-with-lease origin main

Safer rewrite:
- create a backup branch first
- use force-with-lease instead of plain force

Rollback:
- git reflog
- restore backup branch if remote history breaks collaborators

Need approval: yes
Usage Guidance
This skill appears coherent and implements what it promises, but review the bundled scripts before enabling them in an automated agent. Notes to consider before installing: (1) It executes locally via Python and may call subprocesses (e.g., git) and read filesystem paths — ensure the agent supplies a restrictive --allowed-root and appropriate --cwd so the checker only examines intended workspaces. (2) No external downloads or credentials are required, but you should still inspect scripts (guardlib.py, secret_guard.py, preflight.py) if you need higher assurance. (3) If you do not want automated agents to run preflight checks autonomously, restrict model/skill invocation in your policy; otherwise the skill can be invoked by the agent when it decides to run a risky command. (4) Run the included tests locally to validate behavior in your environment before granting broad trust.
Capability Analysis
Type: OpenClaw Skill Name: command-guardian Version: 1.3.2 The 'command-guardian' skill is a defensive utility designed to analyze shell and infrastructure commands for risks such as destructive operations, secret leakage, and path escapes before execution. The core logic in `scripts/guardlib.py` and `scripts/preflight.py` performs static analysis to identify high-risk patterns (e.g., `curl | bash`, `git reset --hard`, or broad `rm` targets) and provides safer alternatives and rollback guidance. The skill includes robust secret detection for AWS keys, JWTs, and tokens, and it uses standard libraries to safely gather local git context without executing the untrusted input commands.
Capability Assessment
Purpose & Capability
Name/description match the packaged scripts and runtime instructions. The skill requires a Python interpreter and the SKILL.md tells the agent to run the included preflight.py and helper scripts; those scripts implement command classification, path checks, secret detection, and rollback hints as described.
Instruction Scope
The SKILL.md directs the agent to run local Python scripts that examine commands and filesystem paths and (per guardlib imports) may invoke subprocesses such as git. That behavior is expected for a preflight tool, but it does mean the skill will read workspace files, resolve paths (including environment-variable expansion), and query VCS state when given a cwd or allowed-root. Make sure callers provide an appropriate --cwd and --allowed-root to constrain its analysis; otherwise the analysis could examine broad parts of the filesystem.
Install Mechanism
There is no install spec or network download; the skill is instruction-only with bundled Python scripts. Nothing is fetched from external URLs or installed into system paths, which reduces supply-chain risk.
Credentials
The skill does not request environment variables or credentials. Its code uses os.path and expands environment variables when resolving paths (expected for path resolution) but does not require or exfiltrate secrets by design. The secret detection module flags inline secrets in commands rather than asking for external tokens.
Persistence & Privilege
always is false and the skill does not request persistent system-level privileges or modify other skills' configs. It runs as an on-demand local checker (agent-invoked), which is appropriate for its purpose.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install command-guardian
  3. After installation, invoke the skill by name or use /command-guardian
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.3.2
Improve Windows PowerShell file-operation risk detection for Remove-Item, Copy-Item, Move-Item, Set-Content, Out-File, and Clear-Content; add coverage for -Recurse, -Force, -Path, and -LiteralPath handling.
v1.3.1
Polish nested command reporting, improve compound rollback guidance, and add safer git clean suggestions
v1.3.0
Add compound command parsing, git context checks, safer command suggestions, and stdin/command-file support
Metadata
Slug command-guardian
Version 1.3.2
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 3
Frequently Asked Questions

What is Command Guardian?

Preflight safety guard for shell and infrastructure commands. Use before running commands that delete, overwrite, move, deploy, rewrite git history, change p... It is an AI Agent Skill for Claude Code / OpenClaw, with 150 downloads so far.

How do I install Command Guardian?

Run "/install command-guardian" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Command Guardian free?

Yes, Command Guardian is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Command Guardian support?

Command Guardian is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Command Guardian?

It is built and maintained by Koi (@jinhuadeng); the current version is v1.3.2.

💬 Comments