gateguard
Skill1 starsChanged 58 days agoMITView on GitHub
Design spec for a three-stage fact-forcing PreToolUse gate (deny the first edit, force named facts, allow on evidence). Not a runnable hook in this collection; use it to build one, or to review a gate someone built.
- Deletes or force-pushes
- Installs packages
- Commits and pushes
9 other projects use a version of this, 7 of them edited.
Adopted by
Most recently taken up by
- lhbsaa/apex-unifiededited, first seen Nov 8, 2026
- pankaj-mahaur/Agent-Daemonedited, first seen Nov 6, 2026
- renepf/claude-skillsedited, first seen Oct 25, 2026
- agenticluke/edit-gateguard-plustheir own version, first seen Oct 20, 2026
- davidanthonyn/claude-skillsedited, first seen Oct 20, 2026
- NISTALTALSON/essential-claude-skillsedited, first seen Oct 11, 2026
Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 7
- Fmarzochi/EGC★ 6184% same
- NISTALTALSON/essential-claude-skills★ 171% same
- SamuelNDCE/claude-super-skill-library★ 186% same
- davidanthonyn/claude-skills★ 086% same
- lhbsaa/apex-unified★ 086% same
- pankaj-mahaur/Agent-Daemon★ 085% same
- renepf/claude-skills★ 087% same
Wrote their own version · 2
- 5throck/ai-workspace-standards★ 25same name
- agenticluke/edit-gateguard-plus★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository64 other files it gives its agents.
- accioSkill
- anthropic-doc-validatorSkill
- archifySkill
- cavecrewSkill
- caveman-compressSkill
- caveman-exploreSkill
- caveman-helpSkill
- cavemanSkill
- codebase-designSkill
- conference-talk-deckSkill
- config-gcSkill
- context-budgetSkill
- domain-modelingSkill
- excalidrawSkill
- explain-yogi-like-he-is-5Skill
- field-guide-builderSkill
- geo-contentSkill
- goal-creatorSkill
- grillingSkill
- grill-meSkill
- grill-with-docsSkill
- hindsightSkill
- implementSkill
- improve-codebase-architectureSkill
- loop-design-checkSkill
- mental-modelsSkill
- migrationSkill
- modern-pythonSkill
- no-ai-slopSkill
- onboard-lightSkill
- onboard-repoSkill
- ponytail-auditSkill
- ponytail-reviewSkill
- ponytailSkill
- primitive-classifierSkill
- prompt-fixerSkill
- prompt-optimizerSkill
- prototypeSkill
- qa-deckSkill
- read-wikiSkill
- researchSkill
- resolving-merge-conflictsSkill
- safe-refactorSkill
- scope-creep-checkSkill
- sdd-workshop-walkthroughSkill
- setup-matt-pocock-skillsSkill
- skill-complySkill
- skill-scoutSkill
- smellsSkill
- spec-interviewSkill
- surgical-patchSkill
- teachSkill
- the-llm-councilSkill
- to-questionnaireSkill
- to-specSkill
- to-ticketsSkill
- triageSkill
- wait-whatSkill
- watchSkill
- wayfinderSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 1 is common, 0 are distinctive, and 2 are very specific to this project.
1
Common
Most of the 9 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 33
No competitor does all three.
- Very specific: line 112
If GateGuard blocks setup or repair work, start the session with ECC_GATEGUARD=off.
- Very specific: line 191
Use .gateguard.yml to ignore paths like .venv/, node_modules/, .git/.
“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 presentedNo 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.
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 verbatimWrite Gate (first new file creation)
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 verbatimDestructive Bash Gate (every destructive command)
Triggers on: rm -rf, git reset --hard, git push --force, drop table, 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 verbatimRoutine Bash Gate (once per session)
1. The current user request in one sentence
2. What this specific command verifies or producesQuick Start
Option A: Use the ECC hook (NOT available in this collection)
Adapted 2026-09-03. Upstream ships an implementation at
scripts/hooks/gateguard-fact-force.jsinside the ECC plugin. That file was not imported, so this skill arrives as the design (gate stages, fact lists, tuning surface) and not as a runnable hook. Two ways to actually run it:
- Install the upstream package (Option B below), which is self-contained.
- Port the three gates into
onboard-repo/library/hooks/as a PythonPreToolUsehook alongsideprotect-paths.pyandblock-destructive.py, following the same fail-open discipline (exit 0 on unparseable input, and on valid JSON of the wrong shape). The three-stage DENY / FORCE / ALLOW contract and the per-gate fact lists above are the spec for that port.Everything below documents upstream's
ECC_*environment surface. Those variables do nothing here until one of the two options above is done; they are kept because they are the best statement of which knobs a gate like this needs.
If GateGuard blocks setup or repair work, start the session with
ECC_GATEGUARD=off. For hook-level control, keep using
ECC_DISABLED_HOOKS with the GateGuard hook ID.
In long sessions, only the first GATEGUARD_FACT_FORCE_FULL_DENIALS
fact-force denials (default 3) emit the full four-fact block; later
denials are condensed to a single line carrying the denial ordinal, so
near-identical blocks cannot accumulate in the context window and
amplify model repetition loops (#2142). Retrying the same file or
command after presenting facts never re-triggers the gate.
Graduated controls
ECC_GATEGUARD=off (or GATEGUARD_DISABLED=1) turns the gate off entirely.
The variables in this table do not: each narrows one behaviour while the
load-bearing destructive-Bash checks keep running:
| Variable | Default | Effect |
GATEGUARD_BASH_ROUTINE_DISABLED | unset (gate on) | Disables the routine-Bash gate only. The destructive-Bash gate (rm -rf, git reset --hard, drop table, dd if=, …) is unaffected. |
GATEGUARD_EXEMPT_GLOBS | unset (no exemptions) | Comma-separated globs; a matching Edit/Write/MultiEdit target skips first-touch fact-forcing. Intended for low-import-value trees (tests, generated artifacts, scratch dirs) where "who imports this / what schema" carries no signal. |
GATEGUARD_FACT_FORCE_FULL_DENIALS | 3 | How many denials emit the full four-fact block before later ones condense to a single line. 0 condenses from the very first denial. |
GATEGUARD_BASH_EXTRA_DESTRUCTIVE | unset | Extra destructive-command patterns, as regex source, added to the built-in set. A malformed regex is treated as unset (built-ins still apply) and logged once to stderr. |
GATEGUARD_STATE_DIR | ~/.gateguard | Where per-session gate state is kept. If state cannot be persisted the gate allows the operation rather than looping, and names this variable in the warning. |
GATEGUARD_BASH_ROUTINE_DISABLED accepts 1, true, on, enabled,
enable, or yes (case- and whitespace-insensitive); any other value
leaves the gate on.
Turning the gate off completely
| Variable | Effect |
ECC_GATEGUARD=off | Disables GateGuard for the session. Accepts 0, false, off, disabled, or disable. |
GATEGUARD_DISABLED=1 | Same effect. Recognises 1 only, the spellings above do not apply here. |
For hook-level control, keep using ECC_DISABLED_HOOKS with the GateGuard hook ID.
Glob semantics for GATEGUARD_EXEMPT_GLOBS
Patterns are matched, unanchored, against the target path with backslashes
normalized to / and the whole string lowercased, the path exactly as the
hook receives it, which for Claude Code tool payloads is absolute. * matches
within a path segment, ** across segments, ? a single character. Matching
is fail-open: a malformed pattern is dropped rather than raising.
Note that a leading **/ compiles to .*/, so it requires at least one
preceding separator: **/tests/** exempts /repo/tests/foo.js but would not
match a bare relative tests/foo.js. Add the separator-free form too if you
pass relative paths:
{
"env": {
"GATEGUARD_BASH_ROUTINE_DISABLED": "1",
"GATEGUARD_EXEMPT_GLOBS": "**/tests/**,tests/**,**/*.test.*,**/docs/**,**/dist/**"
}
}Option B: Full package with config
pip install gateguard-ai
gateguard initThis adds .gateguard.yml for per-project configuration (custom messages, ignore paths, gate toggles).
Anti-Patterns
- Don't use self-evaluation instead. "Are you sure?" always gets "yes." This is experimentally verified.
- Don't skip the data schema check. Both A/B test agents assumed ISO-8601 dates when real data used
%Y/%m/%d %H:%M. Checking data structure (with redacted values) prevents this entire class of bugs. - Don't gate every single Bash command. Routine bash gates once per session. Destructive bash gates every time. This balance avoids slowdown while catching real risks.
Best Practices
- Let the gate fire naturally. Don't try to pre-answer the gate questions, the investigation itself is what improves quality.
- Customize gate messages for your domain. If your project has specific conventions, add them to the gate prompts.
- Use
.gateguard.ymlto ignore paths like.venv/,node_modules/,.git/.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

