- Published on
Claude Code Hooks升级 — 执行时间测量·感知努力级别·CI自动代码审查
2026年5月,Claude Code的Hook系统新增了三项重要功能。
PostToolUse输出替换 — 覆盖任意工具
此前仅限MCP工具,现在所有工具均可使用。
{
"hooks": {
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "python3 sanitize_output.py",
"hookSpecificOutput": { "updatedToolOutput": true }
}
]
}
]
}
}
effort.level — 感知努力级别
- Hook输入JSON:
effort.level字段 - 环境变量:
$CLAUDE_EFFORT
if [ "$CLAUDE_EFFORT" = "high" ] || [ "$CLAUDE_EFFORT" = "xhigh" ]; then
npm run test:full
else
npm run test:smoke
fi
duration_ms — 精确测量执行时间
if [ "$DURATION" -gt 5000 ]; then
echo "[SLOW] $(date): ${DURATION}ms" >> slow-tools.log
fi
claude ultrareview — CI自动代码审查
claude ultrareview src/ --json
claude ultrareview --diff origin/main...HEAD
来源
- Anthropic, "Claude Code Changelog — May 2026": https://code.claude.com/docs/en/changelog
- Releasebot, "Claude Code Updates by Anthropic – May 2026": https://releasebot.io/updates/anthropic/claude-code