H2运行态配置级别: 核心权重: 1修复方式: 手动修改
H2: PreToolUse 钩子配置了精确 matcher
为什么设立这条规则(一手实证依据)
全量语料显示 91%(248/273)的 PreToolUse 钩子未写 matcher 过滤工具名,导致每次 Read、Glob、Grep 都启动子进程,严重拖慢交互体验。
修复建议为每条
PreToolUse 钩子指定精确 matcher(如 "Bash" 或 "Edit|Write")。AgentLint 4,533 个开源仓库 CLAUDE.md 全量实证分析 (2026)
反例(会触发 H2 告警)
# Anti-pattern triggering H2 (PreToolUse hooks have matcher) # Rule or repository configuration violates this check without verification.
推荐写法(通过 H2 检查)
# Compliant harness passing H2 (PreToolUse hooks have matcher) # Concrete, verifiable repository configuration backed by corpus-4533.
本地 CLI 或浏览器一键验证
npm install -g agentlint-ai && agentlint check --check H2