guard
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly -->
<!-- Regenerate: bun run gen:skill-docs -->
<!-- 由SKILL.md.tmpl自动生成——请勿直接编辑 -->
<!-- 重新生成:bun run gen:skill-docs -->
/guard — Full Safety Mode
/guard — 完全安全模式
Activates both destructive command warnings and directory-scoped edit restrictions.
This is the combination of + in a single command.
/careful/freezeDependency note: This skill references hook scripts from the sibling
and skill directories. Both must be installed (they are installed together
by the gstack setup script).
/careful/freezebash
mkdir -p ~/.gstack/analytics
echo '{"skill":"guard","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true同时启用破坏性命令警告和目录范围编辑限制。
这是将/careful + /freeze整合为单一命令的功能。
依赖说明: 此技能引用了同级/careful和/freeze技能目录中的钩子脚本。两者必须已安装(gstack安装脚本会一并安装它们)。
bash
mkdir -p ~/.gstack/analytics
echo '{"skill":"guard","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || trueSetup
设置步骤
Ask the user which directory to restrict edits to. Use AskUserQuestion:
- Question: "Guard mode: which directory should edits be restricted to? Destructive command warnings are always on. Files outside the chosen path will be blocked from editing."
- Text input (not multiple choice) — the user types a path.
Once the user provides a directory path:
- Resolve it to an absolute path:
bash
FREEZE_DIR=$(cd "<user-provided-path>" 2>/dev/null && pwd)
echo "$FREEZE_DIR"- Ensure trailing slash and save to the freeze state file:
bash
FREEZE_DIR="${FREEZE_DIR%/}/"
STATE_DIR="${CLAUDE_PLUGIN_DATA:-$HOME/.gstack}"
mkdir -p "$STATE_DIR"
echo "$FREEZE_DIR" > "$STATE_DIR/freeze-dir.txt"
echo "Freeze boundary set: $FREEZE_DIR"Tell the user:
- "Guard mode active. Two protections are now running:"
- "1. Destructive command warnings — rm -rf, DROP TABLE, force-push, etc. will warn before executing (you can override)"
- "2. Edit boundary — file edits restricted to . Edits outside this directory are blocked."
<path>/ - "To remove the edit boundary, run . To deactivate everything, end the session."
/unfreeze
询问用户要将编辑操作限制到哪个目录。使用AskUserQuestion:
- 问题:“守护模式:请指定编辑操作的限制目录?破坏性命令警告始终处于开启状态。所选路径外的文件将被禁止编辑。”
- 文本输入(非多选)——用户输入路径。
用户提供目录路径后:
- 将其解析为绝对路径:
bash
FREEZE_DIR=$(cd "<user-provided-path>" 2>/dev/null && pwd)
echo "$FREEZE_DIR"- 确保路径末尾带有斜杠并保存到冻结状态文件:
bash
FREEZE_DIR="${FREEZE_DIR%/}/"
STATE_DIR="${CLAUDE_PLUGIN_DATA:-$HOME/.gstack}"
mkdir -p "$STATE_DIR"
echo "$FREEZE_DIR" > "$STATE_DIR/freeze-dir.txt"
echo "Freeze boundary set: $FREEZE_DIR"告知用户:
- “守护模式已激活。 现已启用两项防护措施:”
- “1. 破坏性命令警告 ——执行rm -rf、DROP TABLE、强制推送等操作前会发出警告(您可以选择覆盖)”
- “2. 编辑边界限制 ——文件编辑仅允许在<path>/目录内进行。此目录外的编辑操作将被阻止。”
- “如需解除编辑边界限制,请运行/unfreeze。如需完全停用所有防护,请结束当前会话。”
What's protected
防护范围
See for the full list of destructive command patterns and safe exceptions.
See for how edit boundary enforcement works.
/careful/freeze有关破坏性命令模式和安全例外的完整列表,请查看/careful技能说明。
有关编辑边界限制的实现方式,请查看/freeze技能说明。