基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/T-rav/hydraflow --skill hfblock-destructive-git命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | hf.block-destructive-git |
| description | hf.block-destructive-git |
#!/bin/bash
# Hook: Block destructive git commands that are hard to reverse.
# Fires on PreToolUse for all Bash commands.
# Blocks: push --force, reset --hard, checkout ., restore ., clean -f, branch -D
set -euo pipefail
INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
if [ -z "$COMMAND" ]; then
exit 0
fi
# Block destructive git commands
if echo "$COMMAND" | grep -qE 'git\s+(push\s+.*--force|push\s+-f\b|reset\s+--hard|checkout\s+\.|restore\s+\.|clean\s+-f|branch\s+-D)'; then
echo "BLOCKED: Destructive git command detected." >&2
echo "" >&2
echo "The following are forbidden without explicit user approval:" >&2
echo " - git push --force / -f (overwrites remote history)" >&2
echo " - git reset --hard (discards uncommitted changes)" >&2
echo " - git checkout . (discards all working tree changes)" >&2
echo " - git restore . (discards all working tree changes)" >&2
echo " - git clean -f (deletes untracked files)" >&2
echo " - git branch -D (force-deletes branch)" >&2
echo "" >&2
echo "Ask the user for explicit approval before running destructive commands." >&2
exit 2
fi