Загрузка...

Why Your Claude Code Rules Get Ignored (And How Hooks Fix It)

Text rules in CLAUDE.md get ignored. Hooks don't. In this episode I build three production Claude Code hooks from scratch — a destructive command guard, a compaction state save, and a test gate — and explain the one technical detail that causes most community hooks to silently do nothing.

─────────────────────────────────────
🔧 WHAT YOU'LL BUILD
─────────────────────────────────────
✅ Destructive command guard — PreToolUse hook that intercepts rm -rf, git reset --hard, DROP TABLE before they run
✅ Compaction state save — Notification:PreCompact hook that writes task state before context is summarised
✅ Test gate — PostToolUse hook that runs the test suite after every git commit and stops the session if tests fail
✅ settings.json wiring — how to register all three hooks with correct event types, matchers, and timeouts

─────────────────────────────────────
📌 KEY CONCEPTS COVERED
─────────────────────────────────────
• The four hook events: PreToolUse, PostToolUse, Notification, Stop — when to use each
• The stdin vs. env var distinction — why Notification hooks must NOT read stdin (and why most don't work)
• Exit codes: exit 0 = allow, exit 2 = block with message
• The compaction survival pattern: state in files, not conversations
• Diagnostic checklist: four reasons hooks silently fail and how to fix each

─────────────────────────────────────
⏱️ TIMESTAMPS
─────────────────────────────────────
00:00 — Why hooks exist: the gap between guidance and enforcement
02:00 — The four hook event types explained
04:30 — Hook anatomy: exit codes, stdin vs. env vars
07:30 — Hook 1: Destructive command guard (PreToolUse)
11:00 — Hook 2: Compaction state save (Notification:PreCompact)
14:30 — Hook 3: Test gate (PostToolUse)
17:00 — Wiring hooks in settings.json
19:00 — Why most community hooks silently fail (diagnostic checklist)
21:00 — Key takeaways

─────────────────────────────────────
💻 CODE & RESOURCES
─────────────────────────────────────
GitHub repo → https://github.com/ogu83/production-claude-code
Branch → ep2-hooks

Claude Code hooks docs → https://docs.anthropic.com/claude-code

─────────────────────────────────────
🤝 WORK WITH ME
─────────────────────────────────────
I help engineering teams configure Claude Code for production use — CLAUDE.md architecture, hooks, MCP servers, and context management.
Upwork profile → https://www.upwork.com/freelancers/oguzkoroglu

─────────────────────────────────────

#ClaudeCode #AIEngineering #ClaudeCodeHooks #Anthropic #AITools #ProductionAI #SoftwareEngineering #DeveloperTools #LLM #AIWorkflow #DevProductivity #ClaudeAI #AIAssistant #BeyondTheDeveloper #ClaudeCodeTips

Видео Why Your Claude Code Rules Get Ignored (And How Hooks Fix It) канала Edward Blake
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять