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.
python {baseDir}/scripts/preflight.py --command "<raw command>" --cwd "<working dir>" --allowed-root "<workspace root>" --format json
python {baseDir}/scripts/preflight.py --command-file command.txt --cwd "<working dir>" --allowed-root "<workspace root>" --format json
echo '<raw command>' | python {baseDir}/scripts/preflight.py --cwd "<working dir>" --allowed-root "<workspace root>" --format json
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 retryingRisk:Why:Safer rewrite:Rollback:Need approval: yes/noIf 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.
high risk. If the command embeds active credentials, treat it as critical.., .., /, drive roots, wildcard-only paths, or repo roots as critical.git push --force, git reset --hard, docker system prune, kubectl delete, and terraform apply/destroy as requiring rollback guidance before execution.curl | sh and similar download-and-execute patterns as critical unless the script is pinned, inspected, and verified.main or master, raise the review bar for destructive git commands.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.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.
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.
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
共 1 个版本