← 返回列表
全部 Skill›数据与AI Data & AI›gateguard

gateguard

作者 @affaan-m · 语言 mul
API、エージェント、およびLLMエンドポイントのアクセス制御と認可パターン。
数据与AI Data & AILLM 与 AI需海外环境执行命令敏感路径待翻译
存储库
最近源活动
—
检测 SKILL.md 语言
mul
星标 ★
309,846
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

GateGuard — Fact-Forcing Pre-Action Gate

A PreToolUse hook that forces Claude to investigate before editing. Instead of self-evaluation ("are you sure?"), it demands concrete facts. The act of investigation creates awareness that self-evaluation never did.

When to Activate

  • Working on any codebase where file edits affect multiple modules
  • Projects with data files that have specific schemas or date formats
  • Teams where AI-generated code must match existing patterns
  • Any workflow where Claude tends to guess instead of investigating

Core Concept

LLM self-evaluation doesn't work. Ask "did you violate any policies?" and the answer is always "no." This is verified experimentally.

But asking "list every file that imports this module" forces the LLM to run Grep and Read. The investigation itself creates context that changes the output.

Three-stage gate:

1. DENY  — block the first Edit/Write/Bash attempt
2. FORCE — tell the model exactly which facts to gather
3. ALLOW — permit retry after facts are presented

No competitor does all three. Most stop at deny.

Evidence

Two independent A/B tests, identical agents, same task:

| Task | Gated | Ungated | Gap |

| --- | --- | --- | --- |

| Analytics module | 8.0/10 | 6.5/10 | +1.5 |

| Webhook validator | 10.0/10 | 7.0/10 | +3.0 |

| Average | 9.0 | 6.75 | +2.25 |

Both agents produce code that runs and passes tests. The difference is design depth.

Gate Types

Edit / MultiEdit Gate (first edit per file)

MultiEdit is handled identically — each file in the batch is gated individually.

NotebookEdit は notebook_path への Edit として扱われます(同じクラス・チェック済みキー・クレジット・上限の規則。セル内容は読まないため常に完全な質問になり、コメントのみの通過はありません)。

質問内容は対象ファイルのクラスによって変わります(対象クラス別の質問を参照)。以下は code クラスの Edit ゲートの質問です。

Before editing {file_path}, present these facts:

1. List ALL files that import/require this file (search the tree — Glob/Grep, or find/grep via Bash)
2. List the public functions/classes affected by this change
3. If this file reads/writes data files, show field names, structure,
   and date format (use redacted or synthetic values, not raw production data)
4. Quote the user's current instruction verbatim

Write Gate (first new file creation)

以下は code クラスの Write ゲートの質問です。

Before creating {file_path}, present these facts:

1. Name the file(s) and line(s) that will call this new file
2. Confirm no existing file serves the same purpose (search the tree — Glob/Grep, or find/grep via Bash)
3. If this file reads/writes data files, show field names, structure,
   and date format (use redacted or synthetic values, not raw production data)
4. Quote the user's current instruction verbatim

対象クラス別の質問

初回の Edit/Write ゲートは対象ファイルを分類し、最初に一致したクラスの質問を使います。分類にはプロジェクトルート(CLAUDE_PROJECT_DIR、次にペイロードの cwd、次にプロセスのディレクトリ)からの相対パスを使うため、~/work/tests/ のような場所にあるプロジェクトでも全ファイルが test になることはありません。先頭の .claude/worktrees/<name>/ は <root>/.claude/worktrees/<name>/.git が存在する場合にだけ取り除きます。Windows 形式のパスでは末尾のドット・空白と :stream 接尾辞を除いてから分類します(CLAUDE.md. や CLAUDE.md::$DATA は CLAUDE.md として扱います)。ルート外の対象は絶対パスで分類します。パスは小文字化・/ 区切りで、次の順に判定します。

  1. instruction — CLAUDE.md、AGENTS.md、AGENT.md、GEMINI.md、SKILL.md、copilot-instructions.md、.cursorrules、.windsurfrules、任意の .mdc、.claude、agents、commands、skills、rules、hooks、.cursor、.codex、.opencode ディレクトリ配下の .md/.mdx/.txt、または .github/ 配下の *instructions*.md
  2. test — *.test.*、*.spec.*、test_*.py、*_test.py、*_test.go、または tests、test、__tests__ 配下
  3. prose — .md、.mdx、.txt、.rst、.adoc
  4. config — .json、.jsonc、.yaml、.yml、.toml、.ini、またはコード拡張子で終わらない .env / .env.*(.env.local は config、.env.example.ts と .envrc は code)
  5. code — 上記以外(上に示した質問)

どのクラスも最後に「ユーザーの現在の指示を原文のまま引用する」項目が付きます。質問文(英語、hook の出力そのまま)は次のとおりです。*(search)* は "(search the tree — Glob/Grep, or find/grep via Bash)" の略です。

| クラス | 質問 |

|---|---|

| instruction | Name the harness/loader that reads this file (Claude Code, Codex, Cursor, OpenCode, …) and when it loads it · Describe what agent behaviour changes as a result · Confirm no existing instruction, skill, or agent file already covers this *(search)* |

| test | Name what behaviour is under test and which module/function it exercises · Name the existing test file(s) covering this module, or confirm none exist *(search)* |

| prose (Write) | Name any existing doc this supersedes or duplicates *(search)* · State where it will be linked or referenced from · Explain why a new file rather than editing an existing one |

| prose (Edit) | List other docs or code that reference the section being changed *(search)* · State what the change corrects or adds |

| config | Name which process/tool reads this file and when · Describe the effect of the change · Confirm no secrets or credentials are being written in plain text |

code クラスでは変更内容も読み、公開宣言に触れない Edit には importer/公開 API の代わりに「このファイルまたはモジュール内で変更された振る舞いに依存する呼び出し箇所」を尋ね、データを扱わない変更ではデータ形式の質問を省きます(未対応の拡張子、64 KiB 超などの判定不能な変更と機密対象では従来の 4 問のままです)。

メッセージの文面以外でクラスが影響するのは兄弟ファイル集約だけです(集約できるクラスと、同じクラス同士でのみ集約されること)。

Destructive Bash Gate (every destructive command)

Triggers on: rm -rf, git reset --hard, git push --force, drop table, drop database, drop schema, alter table ... drop column, etc.

1. List all files/data this command will modify or delete
2. Write a one-line rollback procedure
3. Quote the user's current instruction verbatim

Routine Bash Gate (once per session)

1. The current user request in one sentence
2. What this specific command verifies or produces

このゲートが発火するまでは、読み取り専用のコマンド(ls、cat、rg、git status/log/diff、Get-ChildItem など。リダイレクト、置換、tee、xargs、未知のコマンドを含まないもの)はゲートを消費せずに通過し routine_readonly_passes に数えます。セッション ID またはトランスクリプトパスで識別される状態は 8 時間、プロジェクトディレクトリによるフォールバックは 30 分の無操作で失効し、サブ

评论
Aaffaan-m
affaan-m
affaan-m/ECC
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@affaan-m
所属大类数据与AI Data & AI / LLM 与 AI
国内可用性需海外环境
最近源活动—
风险提示执行命令、敏感路径
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。