🦀 ClawHub
Quality Verification
by @lanyasheng
输出质量保障与验证。编辑后检查、提交前测试、session 指标测量。不适用于工具重试(用 tool-governance)或 agent 提前停止(用 execution-loop)。参见 tool-governance(错误追踪)。
⚡ When to Use
💡 Examples
在 .claude/settings.json 中配置 hook:
{
"hooks": {
// Post-edit 诊断:编辑后立即跑 linter
"PostToolUse": [
{
"matcher": { "tool_name": "Write|Edit|MultiEdit" },
"hooks": [
{
"type": "command",
"command": "bash post-edit-check.sh \"$TOOL_INPUT_FILE_PATH\""
}
]
}
],
// Commit 前测试:拦截 git commit,测试不通过则 deny
"PreToolUse": [
{
"matcher": { "tool_name": "Bash", "input_contains": "git commit" },
"hooks": [
{
"type": "command",
"command": "bash test-before-commit.sh"
}
]
}
]
}
}
post-edit-check.sh 按扩展名选 linter:.ts → tsc --noEmit,.py → ruff check + pyright,.rs → cargo check,其他 → exit 0。
test-before-commit.sh 按项目类型检测:package.json → npm test,Makefile → make test,pyproject.toml → pytest,Cargo.toml → cargo test。
Hook 输出格式(post-edit-check.sh stdout):
{"decision": "allow", "hookSpecificOutput": {"additionalContext": "[POST-EDIT] tsc error TS2345: Argument of type 'string' is not assignable to parameter of type 'number' at handlers.ts:42"}}
按 profile 控制强度:
HARNESS_PROFILE=strict claude -p "deploy to production" # 全部 hook
HARNESS_PROFILE=minimal claude -p "fix typo in README" # 仅原子写入
HARNESS_DISABLED_HOOKS=post-edit-check claude -p "quick experiment" # 禁用指定 hook
TERMINAL
clawhub install quality-verification