Files
knowledge-base/6 - Zettelkasten/20260319120100 Hook驱动优于提示词驱动.md
Yaojia Wang cdba2497a7 Re-structure
2026-03-21 11:31:31 +01:00

25 lines
991 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
created: "2026-03-19 12:01"
type: zettel
tags: [zettel, claude-code, agent-reliability, automation]
source: "https://github.com/affaan-m/everything-claude-code"
---
# Hook 驱动优于提示词驱动
AI Agent 的行为控制有两种机制提示词Skill/Rule和 Hook。核心区别在于**确定性**
- **Hook**: 触发率 100%,确定性执行,不依赖模型判断
- **提示词**: 触发率 50-80%,概率性,受上下文长度、模型注意力影响
因此,**关键质量控制(格式化、安全检查、状态保存)应通过 Hook 实现,而非依赖提示词**。提示词适合灵活的、需要判断力的任务Hook 适合必须每次都执行的不变量。
这解释了 ECC v2 为什么把学习观察从 Skill 迁移到了 Hook — v1 中观察经常遗漏v2 通过 PreToolUse/PostToolUse Hook 实现了 100% 捕获率。
---
## Related
- [[Everything Claude Code 方法论与最佳实践]]
- [[Everything Claude Code 完整指南]]