Module 4 of 5Lesson 2 of 2~22 min
Hooks: rules that always apply
An instruction written in a memory file is still a request the agent can forget during a long task. This lesson teaches you to turn your critical rules into Claude Code hooks that run every time, to test them before trusting them and to weigh the risks they introduce into your workflow.
Lesson objective
By the end of this lesson, you will be able to write and test simple hooks that block a forbidden action, format or verify automatically, choose the right event, and assess a hook's risks before installing it.
Topics covered
- Claude Code hooks
- automation
- AI agent guardrails
- repository security
- AI coding agent
Where it fits
Put guardrails in place that hold
What can the agent do without asking me, and how do I enforce what must never happen?
Lessons in this module
- Permissions: what the agent may do without asking you
- Hooks: rules that always apply (this lesson)
What you will learn in this module
This lesson is part of the course Work with Claude Code on a real project: context, planning, review
- Choose a permission mode and write allow, ask and deny rules suited to the project's risks, in the right settings file.
- Write simple hooks as deterministic guardrails (block, format, verify) and know their risks and limits.
Related courses
- AI & DevelopmentJuniorSome basics are useful: introductory knowledge of the topic.
Build and ship a web app with an AI coding agent
2 hr 45 min
- AI & DevelopmentAdvancedRegular practice: you already use the tools or work on this topic.
Add a database, authentication and payments to your app
4 hr
- Product ManagementAdvancedRegular practice: you already use the tools or work on this topic.
Git for PMs: ship as a team without putting production at risk
3 hr 30 min