CCDV-F Claude Code Practice Question
A team wants Claude Code to run a custom script that inspects the repository for license headers before any commit. The script must run automatically each time Claude Code is about to create a commit, and the team wants the same hook to apply to every developer without manual setup. Which mechanism should they use?
⚠ Common exam trap
The trap here is relying on CLAUDE.md instructions or shell aliases for enforcement, when only a configured hook guarantees the script runs on the commit event for every developer.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Define a hook in the project's Claude Code settings that triggers on the commit event and runs the script.
Hooks defined in project-level Claude Code settings run deterministically on lifecycle events such as pre-commit and are shared through the repository, so every developer gets identical behavior automatically. Advisory notes in CLAUDE.md and per-machine aliases or cron jobs are either non-enforcing or require individual setup, and none reliably fires at the exact moment Claude Code is about to commit.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Ask each developer to add the script to their personal shell profile as an alias.
Why it's wrong here
A shell alias only runs when a human types the alias; it does not intercept commits that Claude Code creates through its own tool calls. It also requires per-developer setup and can drift between machines. This approach fails the requirement that the check run automatically and uniformly for everyone whenever Claude Code commits.
- ✗
Configure a cron job on each developer machine to run the script every five minutes.
Why it's wrong here
A periodic cron job is time-based, not event-based, so it can run between commits or miss the moment before a commit entirely. It also requires setup on every machine, contradicting the shared-configuration goal. License checks tied to a timer rather than the commit event would allow non-compliant commits to slip through the window.
- ✗
Add a note in CLAUDE.md instructing Claude Code to run the script before committing.
Why it's wrong here
Instructions in CLAUDE.md are guidance the model may follow, not an enforced trigger. Claude Code could skip the step, especially under a long or complex session, and there is no guarantee it runs before every commit. The scenario calls for automatic, reliable execution, which advisory text cannot provide.
- ✓
Define a hook in the project's Claude Code settings that triggers on the commit event and runs the script.
Why this is correct
Claude Code supports hooks configured in project settings that fire on specific lifecycle events such as pre-commit, letting the team run the license-header script automatically. Because the configuration lives in the repository, every developer inherits the same behavior without individual setup, which satisfies both the automatic execution and shared-application requirements.
About these practice questions
One of 257 original CCDV-F practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Anthropic exam blueprint
This CCDV-F practice question is part of Courseiva's free Anthropic certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CCDV-F exam.