silent-fallback-gate
PreToolUse hook — refuses an Edit or Write that adds an inert broad except. Use when a Python edit was blocked for a silent fallback.
- License 许可
- MIT
- 所属仓库
- muratovv/ai-hats
- 最近更新
- 2026-11-05
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- silent-fallback-gate
- ai_hats
- { "runtime_hooks": { "PreToolUse": [ { "script": "hooks/silent_fallback_gate.py", "matcher": "Edit|Write|MultiEdit" } ] } }
- license
- MIT
- description
- PreToolUse hook — refuses an Edit or Write that adds an inert broad except. Use when a Python edit was blocked for a silent fallback.
02 资源文件 2
- 脚本hooks/bypass_journal.py35 B
- 脚本hooks/silent_fallback_gate.py11.5 KB
03 SKILL.md 正文
silent-fallback-gate
Thin registration for a PreToolUse hook. On an Edit, Write or MultiEdit of a
.py file outside tests/, the hook refuses when the edit adds a broad
except whose body neither raises, calls, nor uses the bound exception.
# silent-ok: <reason> marks a deliberate one. The refusal names that choice.
The check is violations() in hooks/silent_fallback_gate.py. CI walks the
tree through scripts/check_silent_fallback.py, which calls the same function.
An edit that does not grow the set is silent, including a file that already
has one. A payload the hook cannot reconstruct is fail-open; the CI walk still
sees the file. Kill switch AI_HATS_SILENT_FALLBACK_OFF=1, exported.
When to Use
Read this when an edit was blocked and the next step in the refusal is unclear.
Not a nudge: py-security-lint reports and lets the edit through.
Completion
The refusal names the line and one of: report it, re-raise it, or mark
# silent-ok: <reason>.
Validation scenario (RED). An agent adds except Exception: return [] to a
module. Without this hook the standing rule asked it not to, and the edit
landed; CI caught it at review. With the hook the edit is refused and the
reason names the mark.
Anti-Patterns
- Refusing every edit of a file that already contains an inert handler.
- A second copy of the check in the CI script.
04 同仓库更多 Skills
tool-evaluation-protocol
Time-bounded protocol for evaluating new tools, libraries, or methodologies before adoption. Use when evaluating a candidate dependency for the project, researching a methodology (e.g. ML/LLM frameworks, testing approaches), or following up on a hype-driven recommendation.
systematic-debugging
4-phase bug-fix protocol (evidence, pattern, hypothesis, verify). Use when investigating any error, failure, or unexpected behavior, handling bug reports from users or monitoring, or diagnosing test failures with non-obvious causes.
skill-template
Canonical template and validation guide for ai-hats skills. Use when creating a new skill, reviewing an existing one for structural compliance, or deciding which pattern fits a new behavior.
skill-optimization
Audit and refactor library components to eliminate redundancy and staleness. Use during periodic library maintenance, after adding multiple new skills or rules, when a role's token budget is too high, or after retrospectives identify component issues.
silent-fallback-gate
PreToolUse hook — refuses an Edit or Write that adds an inert broad except. Use when a Python edit was blocked for a silent fallback.
retro-to-framework
Convert an observation about agent behavior — from a retrospective or from a single incident — into a framework-level change (hook, rule, skill, skill update). Use after a retrospective identifies problems that are not project-specific, after an incident where an agent misapplied a component it had read, when CLAUDE.md band-aids accumulate (more than 3 per-project rules that could be generic), or when the same problem recurs across multiple projects.