PostToolUse: Enrich After It Happens

Day 34 · Week 7 · Hooks — Guardrails

Slack Message — copy & paste

🤖 Tip #34 — PostToolUse hooks enrich after the fact — cache expensive results, validate outputs, log actions. Prevention is PreToolUse; enrichment is PostToolUse.

#34 Claude Code

What PostToolUse Can Do

  • **Auto-cache expensive results**every time the AI calls the Figma screenshot tool, a PostToolUse hook saves the image to disk. Next time you need it, it's already cached — no API call needed.
  • **Validate file edits**after any Edit tool call to a plugin file (YAML, JSON, markdown), a hook checks the file is still valid. Catches YAML syntax errors, missing required fields, and accidental deletions.
  • **Log subagent completions**after the Agent tool completes, a hook logs the agent name, model used, and duration. Useful for tracking cost and identifying slow agents.
PostToolUse Cache Validate
#34 Hooks — Guardrails

Hooks to Build First

  1. 1 **Cannot block, only observe**the action already happened. If you need to prevent something, use PreToolUse instead.
  2. 2 **Gets tool result as context**your script can inspect the output and take different actions based on success or failure.
  3. 3 Create a PostToolUse hook that logs every Bash command to a fileafter a session, review what commands the AI ran
  4. 4 Add a validation hook for Edit calls on config files (YAML, JSON)catch corruption immediately instead of discovering it later
  5. 5 Use the matcher to target specific tools`Edit` for file validation, `mcp__*figma*` for Figma caching
PostToolUse Cache Validate
Your screenshot here Optional — add a screenshot from your own workflow
KAI by Dragan Filipovic