跳到正文
Skillpedia
部署与云(DevOps)31k · #9254

data-loss-gate

它能做什么

这项技能会在智能体对文件或知识库执行破坏性操作之前设置一道确认步骤。适合希望在大规模删除前多一层安全检查的人。

适用场景

  • ✓当你的智能体准备执行批量删除或 rm -rf 之类的命令时。
  • ✓当清理操作会删除大量知识库页面或整个数据源时。
  • ✓当某个操作无法撤销,而你想先看清会丢失什么的时候。

技能链接

https://github.com/garrytan/gbrain/blob/master/plugin-variants/gbrain-coding/skills/data-loss-gate/SKILL.md

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“请帮我清理这个文件夹里所有旧的草稿文件,但在删除之前先把将被删除的内容给我看看。”

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

工作原理

智能体会检查目标文件,列出一份可恢复性摘要,显示将会丢失的内容,然后等你明确回复同意后再继续。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Data Loss Gate — Confirmation Before Destructive Operations

Convention: see conventions/brain-first.md — inspect the actual target before proposing deletion: get_backlinks, gbrain graph <slug>, git log on the underlying files. The confirmation card below is only as good as the inspection behind it.

Convention: see _brain-filing-rules.md — the post-confirmation deletion log files date-keyed under daily/.

What This Is

A gate that fires BEFORE any destructive operation and requires explicit user confirmation. The agent stops, presents a recoverability card, and waits.

Scope honesty: this gate is a routing convention — the harness resolves it into context when a destructive intent matches, and a well-behaved agent follows it. It is NOT an operation-boundary enforcement: nothing in the gbrain runtime mechanically blocks a delete if the skill never loads. (A native confirm gate at the operation boundary is a filed TODO; until it lands, this convention is the line of defense.) Some CLI surfaces carry their own flag gates — e.g. gbrain sources remove requires --confirm-destructive — but the flag confirms that the AGENT is sure. This skill exists to confirm that the USER is.

When This Fires

Before ANY of these operations:

Shell / filesystem level:

  • rm -rf on any directory with data
  • rm / unlink on more than 10 files
  • sed -i that modifies more than 10 files
  • git rm on tracked files
  • Truncating or stripping content from files in bulk
  • Overwriting files with smaller versions (content stripping)
  • Any operation described as "cleanup" or "freeing space" that touches data files

Brain / database level (gbrain-specific):

  • Bulk forget — scripting or looping gbrain forget <fact-id> over many facts. One forget is a considered, idempotent act; a forget sweep is data loss.
  • Page-delete sweeps — gbrain delete <slug> in a loop, or any script that sweeps delete_page across a set of slugs. Deletes are soft (recoverable via gbrain restore <slug>) until purged — say so on the card, then gate anyway: a sweep that's wrong in bulk is expensive to un-wrong in bulk.
  • gbrain delete --purge — skips the 72-hour soft delete and removes the page at once with its chunks, versions, takes, timeline, links, raw data and the facts filed on it. gbrain restore cannot undo it. Every purge needs the user's explicit go for that purge: a request to "scrub the repo", "clean up the files" or "remove it from Git" is not a go to purge database pages. After the go, purge one page at a time (never a parallel xargs or a background loop), confirm each one is gone (gbrain get <slug> --include-deleted reports page_not_found) before the next, and stop the batch at the first refusal. A purge batch that was stopped (SIGTERM, a write freeze, a timeout) stays stopped: report what finished and ask again before relaunching it.
  • gbrain pages purge-deleted — permanently removes soft-deleted pages from every source of the brain. This is the point of no return for the soft-delete safety net. Show the user gbrain pages purge-deleted --dry-run --json first; the command itself asks (exit 3 without a terminal) and runs with --yes only after the user agrees.
  • Source removal — gbrain sources remove <id> deletes the source AND every page in it. The --confirm-destructive flag does not substitute for the card.
  • Mount removal — gbrain mounts remove <id> only removes the local registration (the mounted brain's database survives; re-add to recover). Gate it anyway when the flow ALSO plans to delete the mount's underlying database or files — then the full card applies to those.
  • Raw-SQL truncation — any DROP TABLE, TRUNCATE, or DELETE without a narrow WHERE against the brain database, via any path (psql, a migration script, an engine executeRaw call).
  • Deleting database rows in bulk; dropping tables, collections, or indexes.

What To Do

Step 1: STOP before executing

Do NOT run the destructive command. Inspect the actual target first (backlinks, graph edges, git history, file contents — whatever grounds the card), then present the user with:

Step 2: The Confirmation Card

⚠️ DATA DELETION — Confirmation Required

What: [exactly what will be deleted/modified]
Count: [number of files/rows/pages/facts affected]
Size: [how much 
常见问题

这是硬性的技术限制吗?

技能文档说明,这只是一种路由约定,需要智能体自觉遵守,并不是强制锁定。

它在询问之前会检查什么?

它会检查实际的目标,例如反向链接和 git 历史,使摘要更准确。

删除日志保存在哪里?

技能文档说明,确认之后,删除日志会按日期归档到每日文件夹下。

详情

作者的原始描述

Confirmation gate before any bulk delete, cleanup, or destructive operation that could result in data loss — shell-level (rm -rf, git rm, bulk sed) or brain-level (bulk forget, delete sweeps, purge-deleted, source removal, raw-SQL truncation). Presents a recoverability card and requires an explicit "yes" from the user before proceeding. Routing convention, not an operation-boundary enforcement.

repo: garrytan/gbrain

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能