Last reviewed
Correct answer: A. Define it in that repository's .cursor/hooks.json and commit it, because project hooks apply to that project alone while home directory hooks apply to every project you open.
Explanation
The principle — Hooks load from four sources: enterprise configuration managed by MDM, team configuration distributed from the dashboard, a project's .cursor/hooks.json, and your own ~/.cursor/hooks.json. Every matching hook from every source runs, and where responses conflict the higher-priority source wins the merge, in the order enterprise, team, project, user. Scope is decided by the file the hook lives in: project-level hooks apply only to that specific project, while home directory hooks apply globally.
Why the key is correct — A scanner meant for one repository belongs in that repository. Committing .cursor/hooks.json gives it exactly the reach it should have, and it arrives with the code for everyone who clones it, including cloud agents working on that repo. Two details come with the move. Project hooks run from the project root, so a command written as ./hooks/scan.sh for the home directory becomes .cursor/hooks/scan.sh once committed, and forgetting this leaves a hook that fails to launch. Project hooks also require a trusted workspace, which is the same mechanism seen from the other side: cloning someone's repository and trusting the workspace runs their hook scripts on your machine, so a hooks file is worth reading before you trust an unfamiliar repo.
Why the others are wrong — There is no single hooks file; the location is the scoping mechanism, and a matcher narrows by command or tool rather than by project, so it cannot express repository boundaries. Workspace trust governs whether a repository's own hooks may run, and it places no limit on the ones you installed for yourself. Moving the file to the enterprise directory pushes the hook to every user on the machine and, being MDM-managed, out of the developer's hands, which is the opposite of narrowing.
Remember this — Where a hook lives is what it applies to. Repository concerns go in the repository; only machine-wide habits belong in the home directory.
Sources — Cursor's Hooks documentation.
Sources
“Project-level hooks apply only to that specific project, while home directory hooks apply globally.”
Practise 10 questions on this topic
Take Cursor Basics — Timed Test 1 (10 questions) — scored instantly, explanation for every question, no login.