Flashcardsfor IT Certifications

D7: Hooks for Guardrails & Deterministic Actions

Claude Certified Developer – Foundations exam practice questions · 10 flashcards

Question
What are hooks in Claude Code / Agent SDK?
1 / 10

Tip: Space flips the card, ← / → navigate.

Last updated: · Report an error on this page

Show all 10 Hooks for Guardrails & Deterministic Actions practice questions and answers
  1. What are hooks in Claude Code / Agent SDK?
    User-defined commands or functions that run automatically at specific lifecycle events.
  2. Which hook runs before a tool executes?
    PreToolUse.
  3. Which hook runs after a tool executes?
    PostToolUse.
  4. Name other hook events.
    UserPromptSubmit, Stop, SubagentStop, SessionStart, SessionEnd, PreCompact and Notification.
  5. How can a PreToolUse hook block a destructive command?
    Inspect the tool input (e.g. rm -rf) and return a blocking decision (e.g. exit code 2) with a reason fed back to Claude.
  6. Why use hooks instead of prompt rules for safety?
    Hooks are deterministic and run every time; prompts can be ignored or overridden.
  7. What's a good PostToolUse hook example?
    Auto-running a formatter or linter after file edits.
  8. Where are Claude Code hooks configured?
    In settings.json (user, project or local scope).
  9. Why review hook scripts carefully?
    They run with your user's permissions automatically.
  10. How can hooks support auditing?
    Log every tool call and its inputs for monitoring and review.