skills/warn-destructive-commands/SKILL.md
Warn before destructive commands. Checks Bash commands for rm -rf, DROP TABLE, force-push, git reset --hard, kubectl delete, and similar patterns. User can override each warning. Use when touching prod, debugging live systems, or in shared environments.
npx skillsauth add nesnilnehc/ai-cortex warn-destructive-commandsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
在会话中执行 Bash 命令前,检查是否包含破坏性模式;若命中则先警告用户并征得确认再执行,降低误操作风险。适用于接触生产、调试线上系统或共享环境。
首要目标:在每次执行 Bash 命令前,若检测到破坏性模式,则先 AskUserQuestion 警告并等待用户确认或取消;确认后方可执行。
成功标准(必须满足所有要求):
验收测试:若用户输入含 rm -rf /important 的命令,Agent 是否先警告并等待确认?
本技能负责:
本技能不负责:
转交点:技能激活后持续生效直至会话结束;用户可随时选择「继续」覆盖单次警告。
当用户请求本技能时,输出:
Safety mode active. I will warn before running any command matching destructive patterns. You can override each warning.
| Pattern | Example | Risk |
|---------|---------|------|
| rm -rf / rm -r / rm --recursive | rm -rf /var/data | Recursive delete |
| DROP TABLE / DROP DATABASE | DROP TABLE users; | Data loss |
| TRUNCATE | TRUNCATE orders; | Data loss |
| git push --force / -f | git push -f origin main | History rewrite |
| git reset --hard | git reset --hard HEAD~3 | Uncommitted work loss |
| git checkout . / git restore . | git checkout . | Uncommitted work loss |
| kubectl delete | kubectl delete pod | Production impact |
| docker rm -f / docker system prune | docker system prune -a | Container/image loss |
rm -rf node_modules / .next / dist / __pycache__ / .cache / build / .turbo / coverageThe following command matches a destructive pattern:
[命令]
Risk: [对应风险描述]
A) Proceed anyway
B) Cancel
不要做这些(其他技能可以处理它们):
输入 rm -rf /tmp/test(或任意破坏性命令)时,是否先出现警告并等待确认?
命令:rm -rf /var/cache
行为:命中 rm -rf,AskUserQuestion 警告「Recursive delete」;用户选 A 则执行,选 B 则取消。
命令:rm -rf node_modules
行为:属于安全例外,不警告,直接执行。
命令:git push -f origin main
行为:命中 force-push,警告「History rewrite」;用户确认后执行。
本技能产出会话级警告提示与用户确认结果:
| 元素 | 格式 | 必填字段 | 路径模式 | | :--- | :--- | :--- | :--- | | 警告提示 | AskUserQuestion 文本 | 字段:触发命令原文 / 命中模式名 / 风险描述 / 选项 A=Proceed / B=Cancel | 标准会话输出,不落盘 | | 确认结果 | 标量 | decision ∈ {proceed, cancel};cancel 时输出 "Command cancelled." | 标准会话输出 | | 命中决策表 | 内部对照表(仅在调试时输出) | pattern_id / matched_substring / safe_exception_applied(bool) | 仅故障排查时显式请求 |
development
Generate an LLM agent test suite (golden cases, mock-LLM unit tests, evaluator harness) from an agent implementation and its agent-test contract. Use when an agent has no tests, or a contract exists but the test code is missing.
development
After code changes, auto-detect the project's build system and local deployment method for a given directory, then build the project and restart its locally-deployed environment (Docker Compose / systemd / process manager). Never assumes — asks only when detection is ambiguous. Caches detected commands per project in .cortex/redeploy-local.yaml; re-invocations on the same project skip re-scanning until signal files change, the cache expires (30 days), or the skill version bumps.
tools
Publish a NATS message conforming to a cross-team contract, using NATS MCP tools. Authors the contract on first use if missing. Reads project-level cache (.cortex/nats.yaml) to avoid re-prompting basics across sessions.
tools
Drain pending NATS messages from a producer contract via NATS MCP tools (default batch / drain-style). Applies Tolerant Reader semantics and per-message ack/nak/term, returning aggregated stats. Reads project-level cache (.cortex/nats.yaml) to avoid re-prompting.