We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Analysis Summary
Ask yourself: “Did I notice what this video wanted from me, and did I decide freely to say yes?”
Worth Noting
Positive elements
- This video provides a practical, hands-on demonstration of how to intercept and act upon CLI tool events, which is a valuable skill for developer productivity.
Be Aware
Cautionary elements
- The video includes a brief, non-disclosed mention of Epidemic Sound as a tool for the project, which functions as a soft product placement.
Influence Dimensions
How are these scored?About this analysis
Knowing about these techniques makes them visible, not powerless. The ones that work best on you are the ones that match beliefs you already hold.
This analysis is a tool for your own thinking — what you do with it is up to you.
Related content covering similar topics.
How to configure Claude Code in Tidewave
Dashbit
Claude Just Rolled Out 2 Big New Features
Matt Wolfe
Introducing Cowork: Claude Code for the rest of your work
Anthropic
This New Claude Code Feature is a Game Changer
Nate Herk | AI Automation
This New Claude Code Feature is a Game Changer
Nate Herk | AI Automation
Transcript
When Enthropic announced hooks for Claude code, there was this comment on the Claude AI subreddit. I'm going to use this to make Claude meow. I've always wanted a cat, but I'm allergic. That felt like as good of a use case as any to get started with. So, this is what your Claude code can sound like when you're running it in parallel. Or maybe you prefer the old school beeps. Or maybe you want Cloud Code to talk to >> editing ready for you. Bashing. Let me quickly walk you through how I built this. And I think this is a really great project for getting started with cloud code and hooks because when you assign sounds to all of the different events, you will start to understand when they're getting triggered, which will then help you come up with new ideas for a bit more pragmatic ways that you can use hooks, which is an incredibly powerful addition to Claude Code. The general idea here is that Claude has a whole bunch of different types of events, and you can set up hooks to run custom commands before or after or on those different events. So some of those events would be a pre-tool use. So before it uses a tool, the tool includes bash which you'll find out if you do this is a lot of cloud code use. Uh it is also editing files. It is reading files. It is uh fetching stuff from the web. Uh you can also do post tool use. So this is letting you know after it's finished that task. There's notification. There's always been the notification with cloud code that you could set up with iTerm for instance to beep when it's waiting for your approval on something. But I found that it was easy to miss this and didn't always work great and I've really enjoyed being able to customize that. There's stop. So this is when cloud code's completed as its task. I actually use this a lot in lie of the notification. Uh and then there's uh pre-ompact. So something that it's going to do before it autocompacts all of your history. Uh so you can set up uh claude to run custom commands before it does any of these actions. And the way you're going to set that up is in your settings.json. Now anytime you're editing your settings.json, JSON, you got to figure out which one do you edit. And I think this is a little confusing for folks and probably worth a deep dive later on. Uh, but generally for this use case, I've been doing it in my settings.json in my project. This way, it is committed to my repo and uh, it will be included on all of the uh, work trees that I'm running this on. I also have created inside mycloud directory a hooks directory where I'm storing all of the files associated with these hooks here. Uh, and I suspect that I might end up moving some of this stuff out to my user settings, my uh, user/.cloud directory so that this is included in all of my uh, cloud usage across all my projects. But for right now, I'm just doing this on a single project. I did not want to do it in my settings.local.json because then it's not committed to the repo. And then I don't get all of this across all the different work trees. You've edited your settings.json before. You've probably just looked at the permissions. Uh, and this is a lot of permissions that I've given Claude. Now, we'll minimize those for now. Uh, and now we have hooks. So, we're going to define the type of event that we're going to trigger a hook on. Hooks are a list and then uh a list of uh dictionaries. And there's really I think actually command is the only type of hook that you can run. And for now the only thing I'm doing is running a custom Python script. And so I'm running Python 3 and then I'm passing the full path of that script. So you can see that here in my project I have claude hooks and then the script called hook handler. And so I'm doing Python 3 users Greg code YouTube tracker claude hooks etc. All right. So this means that anytime that claude code needs to run the notification, it's running hook handler. It means that anytime it's running stop, it triggers a stop event, it's running hook handler. Anytime it's running pre-tool use, it's running the hook handler. I tried this a few different ways. I tried writing different scripts for different um events. Uh I have also tried uh using the same script but passing different arguments in uh like command line arguments in. I found that difficult to debug. Uh, I found that what I want to do is keep my settings.json as simple as possible and then handle all of the logic in the Python script because there I have much better debugging, etc. All right, so let's take a look at the Python script. This Python script, by the way, uh, I generated with cloud code. I basically passed it the URL for the hooks, uh, documentation and told it what I want to do. I went through several different iterations and then I had it um uh refactor it several times to make it as legible as possible. And you can find this script at uh hih high.ai/hooks. Um but basically what's going to happen here first and foremost let's just run and log the data that cloud code is passing into this script when it gets triggered because that data is what will help you decide what you want to do. You can see under hook input hooks receive JSON data via standard in containing session information and event specific data and it goes through some of the specifics of what that looks like. Another little tip that I found for working with cloud code is you can just say to cloud code uh do some stuff to test out my hooks integration and then it will just do stuff. Uh, and I think right now I have the beeps turned on. So, you can hear the various beeps that it's doing. And then as that runs, you can see that it was updating its to-dos and it's reading a file now. So, I'm going to come over here and I'm going to look into my hook handler.json l uh because I have a function in my hook handler called log hook data. It's right here. Claw's going to keep making sounds in the background as we go. um which I might need to turn off. Uh and so this is basically just uh writing out the uh data that's coming in via standard in. So this is what that looks like. So you can see there's a session ID. You can see that uh we have an event name. We have the tool name. So in this case it's it's pre-tool use. So we have the tool name and then the tool input. So this gives us all the information we need to know about what Claude is doing in order to branch the logic to to do the various stuff. Um so let's uh come back in here and we'll look at then what my hook handler is doing. Uh basically I have a uh a few different directories here. I have a sounds directory and I have um uh beeps and I have voice and I think on a different branch I had my meow sounds although I may have actually accidentally reverted that out after I recorded the demo but okay we'll go dig through uh git for that later. Uh the way that I got these is I use uh Epidemic Sound. Uh I use it in my various YouTube videos. Um they have music uh and then I also they also have a sound effects section here. And so I just came in here and I got there was a section for uh beeps. And so I just all sorts of fun beeps that you can play with. Uh oh my god, that one's Oh, let's make that one stop right now. Sorry about that. Uh they've got one for uh you know, they've got cats. That's kind of nice. All right. I feel like I only use sad meows in mine. I should change that. Uh I did some construction equipment once for the tool use. Uh they also have this new feature called voices which I played around with. So you can they have these voice actors who have donated their voice to the AI and then you can make them say things. So uh I used Shawn here because he's British. Seemed like Claude might be British. uh uh say committing and you can create the voice over >> commiting. >> Commiting. Okay. Uh I guess I did spell that wrong. Let's try that again. >> Committing. >> There we go. That's better. Uh so you can see how I did those. One, if you do end up using these, one um just tip is say they often will cram a whole bunch of different uh sound effects on the same one. And so you can see it here. All right. So then if you go to download, you can come to segment and you can select just the segment of the sound effect that you want to download. So I'll take that down. You can get just that. So I did that. I played with a different a few different ways of doing this. The first iteration I did, um, I just threw a bunch of random sound effects into a folder and then I just let it pick randomly. I do like assigning specific sounds to specific actions because I do find that it helps me understand when Claude is doing stuff. For instance, I didn't realize how often Claude is updating its to-do list. Uh, which I I thought was actually kind of cool. I didn't realize initially before I started doing this how many of the commands that Claude runs is a bash command. And so initially I just had it uh playing a sound for bash and then it was the same sound over and over again and then I realized that I needed to do a pattern match on uh you know the specific commands such as editing files or reading files um or even you know it runs bash for uh using the GitHub CLI um and so doing all those different things I think it just helped me understand cloud code and how it worked better. So I have here um I've renamed these various uh sounds to the command. So here you can see with uh speaking >> committing >> or I have one for bash >> bashing >> or testing >> running tests. >> You go the PR >> creating pull request. >> See? So uh pretty cool. I I thought it was great. And I mean you can imagine what this Python script's doing here. Um so basically we just play the sound. I have a little toggle up here, sounds type, that I can set this to meows or voices or beeps. Uh, and then I just have a map uh telling it to map the different event to the various uh sound files. Uh, and then it will uh match go in depth on uh the different bash commands to figure out which sound it should play for those. Um, and uh this was really fun and pretty easy to create with Claude. And I think that this was uh a really cool foray into using hooks because it helped me understand the different event types by assigning the different sounds which has then given me a lot more thoughts about different ways that I can use hooks. I've seen a lot of folks use them for instance to um prevent some of the commands that they're most concerned about. So for instance, you could set up a hook to look for a bash command that's running rm-rf for instance and to uh you know have it not do that. Uh you could um a lot of folks are using it to run llinters. A lot of folks are using it to ensure that the test suite is being run before uh you open up a pull request. Um, and so there's just a lot of really interesting things you can do here that gives you a lot a little bit more deterministic control over Cloud Code's behavior. Uh, but I did find that getting started by doing the fun thing with sounds was a great way to get started here. If you want to see all this code, you can check out hih high.ai/hooks and I put the code up there and would love to hear what you're using hooks for.
Video description
Hooks is a Claude Code feature that lets you run custom commands on Claude Code events such: bash commands, file edits, git commits, todos updated, etc. To get started with hooks, I built a claude code soundboard. I had claude code play different sounds depending on the event that was happening. This helped me learn the different events, and made claude a lot more fun (especially when running parallel). This video is a getting started guide for Claude Code and hooks. We walk through editing your settings.json, the different types of claude code events, getting custom sounds, running custom python scripts with hooks, etc. You can find the code for custom hooks handler at: https://haihai.ai/hooks