跳到正文
Skillpedia
部署与云(DevOps)139k · #705

guard

它能做什么

这个技能同时开启两项安全检查:对风险命令发出警告,并限制文件只能在哪个文件夹中修改。适合希望在智能体工作时有强力安全保障的人。

适用场景

  • ✓当你希望智能体在你的项目上工作时获得最高等级保护的时候。
  • ✓当你希望同时开启破坏性命令警告和文件夹限制的时候。
  • ✓当你把任务交给一个涉及重要项目、不能容忍错误的智能体的时候。

技能链接

https://github.com/garrytan/gstack/blob/main/guard/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/garrytan/gstack/blob/main/guard/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我开启完全安全模式,把所有编辑限制在 src 文件夹内。执行任何破坏性操作前先提醒我。”

每周 5 个新技能,1 分钟读完。

工作原理

你选择一个文件夹,技能会同时启用命令警告和文件夹限制。文件夹之外的编辑会被阻止,有风险的命令会触发警告。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

<!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly --> <!-- Regenerate: bun run gen:skill-docs -->

/guard — Full Safety Mode

Activates both destructive command warnings and directory-scoped edit restrictions. This is the combination of /careful + /freeze in a single command.

Dependency note: This skill references hook scripts from the sibling /careful and /freeze skill directories. Both must be installed (they are installed together by the gstack setup script).

GSTACK_STATE_ROOT=$(~/.claude/skills/gstack/bin/gstack-paths --get GSTACK_STATE_ROOT); : "${GSTACK_STATE_ROOT:?gstack-paths failed; reinstall with ./setup or /gstack-upgrade}"
mkdir -p "$GSTACK_STATE_ROOT"/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_STATE_ROOT"/analytics/skill-usage.jsonl 2>/dev/null || true

Setup

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:

Set the user-selected boundary with the shared writer, which resolves a physical absolute path and serializes replacement with investigation cleanup:

bash "$HOME/.claude/skills/gstack/freeze/bin/freeze-state.sh" set "<user-provided-path>"

On helper failure, do not claim the boundary is active. Preserve the state and report recovery; never bypass the shared writer with a direct write or deletion.

Tell the user:

  • "Guard mode active. Two protections are now running:"
  • "1. Destructive command guard — rm -rf, DROP TABLE, force-push, etc. warn before executing (overridable); catastrophic shapes (recursive delete of / or ~, force-push to the default branch) are hard-denied"
  • "2. Edit boundary — file edits restricted to <path>/. Edits outside this directory are blocked."
  • "To remove the persistent edit boundary, run /unfreeze. Ending the session stops its hooks but does not delete that boundary."

What's protected

See /careful for the full list of destructive command patterns and safe exceptions. See /freeze for how edit boundary enforcement works.

常见问题

完全安全模式包括什么?

对破坏性命令的警告,加上阻止在你选定的文件夹之外编辑文件。

警告一直开着吗?

是的。说明中提到,在此模式下破坏性命令警告始终开启。

它需要安装其他技能吗?

需要。它使用同时安装的两个相关技能中的钩子脚本。

详情

作者的原始描述

Full safety mode: destructive command warnings + directory-scoped edits. (gstack)

repo: garrytan/gstack

热度

GitHub 星标
139k
排名
#705
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能