/install command-guardian
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
- Normalize the command, working directory, and allowed roots.
- 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
- Read the report and respond by risk level:
low: proceed if the command still matches user intentmedium: explain the risk briefly and tighten the command if a safer rewrite is obvioushigh: do not execute blindly; show why, provide a safer version, and require explicit confirmationcritical: stop automatic execution; narrow scope, strip secrets, or stage the operation before retrying
- 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
highrisk. If the command embeds active credentials, treat it ascritical. - Treat destructive operations on broad targets such as
.,..,/, drive roots, wildcard-only paths, or repo roots ascritical. - Treat
git push --force,git reset --hard,docker system prune,kubectl delete, andterraform apply/destroyas requiring rollback guidance before execution. - Treat
curl | shand similar download-and-execute patterns ascriticalunless 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
mainormaster, raise the review bar for destructive git commands.
Scripts
Use these scripts directly:
-
scripts/preflight.pyMain 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.pyLabels command risk and categories such aswrite,destructive,privileged, andproduction-impacting. -
scripts/path_guard.pyResolves candidate paths relative to--cwd, checks whether they escape allowed roots, and flags broad deletion targets. -
scripts/secret_guard.pyDetects obvious inline secrets such as bearer tokens, JWTs, AWS keys, GitHub PATs, and suspicious key/value pairs. -
scripts/rollback_hints.pyProduces 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.mdRisk rubric, approval thresholds, and examples of broad targets and secret exposure. -
references/tool-patterns.mdTool-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
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install command-guardian - 安装完成后,直接呼叫该 Skill 的名称或使用
/command-guardian触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Command Guardian 是什么?
Preflight safety guard for shell and infrastructure commands. Use before running commands that delete, overwrite, move, deploy, rewrite git history, change p... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 150 次。
如何安装 Command Guardian?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install command-guardian」即可一键安装,无需额外配置。
Command Guardian 是免费的吗?
是的,Command Guardian 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Command Guardian 支持哪些平台?
Command Guardian 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Command Guardian?
由 Koi(@jinhuadeng)开发并维护,当前版本 v1.3.2。