From the course: Claude Code in Action by Anthropic
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Introducing hooks - Claude Tutorial
From the course: Claude Code in Action by Anthropic
Introducing hooks
In this video we're going to take a look at hooks. These allow you to run commands before or after Claude attempts to run a tool. Hooks can be used to implement really interesting and very useful functionality. For example, after Claude decides to write a file, you can automatically run a code formatter on the created file. Or you can run tests after a file is edited. Or you can block Claude from reading particular files. The possibilities are really endless and and I've got a couple of good examples lined up to show you to give you some ideas of how you might use hoax on your particular project. First, however, let me help you understand exactly how hoax work. As a reminder, when you ask Claude code something, your query is sent off to the Claude model along with some tool definitions. The Claude model might then decide to run a tool by providing a carefully formatted response. And at that point, it is up to Claude code to run the requested tool, maybe in this case to read a file…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.