Memuat
Memuat
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Claude from Zero to Expert Class #90: Custom Commands and Hooks”.
Other ways we can help with Claude.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Midjourney Course: Create Stunning AI Images from Text
★ 4.9

DALL-E Course: Creating Professional AI Images from Text
★ 4.9

Stable Diffusion Course: AI Art from Beginner to Professional
★ 4.9
Have it built for you
No time to learn Claude? Our team can do the project for you.

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9

AI Image Creation with Midjourney — Cinematic AI Art for Business
★ 4.9
Get notified about new Claude classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
Hi, and welcome to the final episode of the Advanced Claude Code session. We've used Git, plan mode, subagents, and MCP. Now we make Claude Code feel like our own: custom commands for work we repeat often, and hooks that run checks automatically.
At the start of every month, Dewi types the same long request: run the report script, read the log, explain if it fails, summarize the five key numbers, and don't send anything. Compare that with the right side: one short line. A long request easily misses one rule, especially when you're in a hurry. A custom command always carries the complete rules. And if a coworker covers for Dewi during leave, the request stays exactly the same. The results are consistent for the whole team. A practical rule: a request you've typed three times with almost the same content deserves to become a custom command. In Claude Code, commands that start with a slash are called slash commands. There are built-in ones, such as slash help for help and slash clear to start a new conversation. We can also create our own custom commands. A custom command is just a text file holding a standard request, saved in Claude's settings folder inside the project. A custom command can take extra input after it, such as the report month. That input is inserted into the standard request. How commands are stored and named can change between versions, so check the official Claude Code documentation.
Dewi asks Claude to create a custom command called monthly report, holding the request Dewi usually types, with the month as extra input. Claude writes one text file in the project's settings folder. The file name becomes the command name. Its content is a standard request in plain language: run the script for a given month, read the log, explain if it fails, summarize five numbers, and send nothing. The text dollar arguments is a placeholder for the extra input, here the report month. At the start of November, Dewi just types slash monthly report, space, twenty twenty-six dash ten. Claude runs the main script from the automation session. All three steps succeed. The summary comes out with the same rules every month, including a reminder that the report hasn't been sent to anyone. One command line replaces a whole paragraph of requests. Raka creates a release check command that combines habits from earlier episodes: the price-checking subagent, a browser test, and then the Git status. Dewi adds a tidy invoices command that always starts with a dry run and shows twenty rows of the plan. The safety rules are now built into the command. And Mr. Hendra could create a make quiz command, with the chapter name as extra input, so the question format always matches the question bank. Start with just one command: the work you repeat most often. Use it for a few weeks, improve it if a rule is missing, and only then add the next command.
Now for hooks. A hook is a command that Claude Code runs automatically every time a certain event happens, for example right before Claude changes a file. The hook itself is a command or small script that you've set up. It runs without being asked, every time, without ever forgetting. Its action can vary: allow, block, or simply notify. The difference from instructions in CLAUDE.md: an instruction is advice that can be forgotten, while a hook is a rule that always runs. A simple example: Raka has already written in CLAUDE.md that secret files must not be changed. Usually that's followed, but there's no guarantee. With a hook, that rule becomes a fence that's truly locked. There are several events you can use. The most useful for safety is before Claude uses a tool, such as before changing a file. Here a hook can block a dangerous action. The second event: after Claude uses a tool. It's good for tidying file formatting or running a check every time something changes. Third, when Claude finishes working or needs your attention. It's good for notifications, so you can do something else while you wait. The full list of events is in the official Claude Code documentation. For beginners, start with just two hooks: one that protects important files before a tool is used, and one notification when Claude finishes. We'll set up both now.
Raka wants one rule that can never be broken: the secret file holding service keys must not be changed, whatever the reason. Raka asks Claude to create a hook and explain every line of its settings. Claude writes a small checking script. It has only one job: block the change if the file about to be changed is the secret file. Then Claude adds the hook to the project's settings file. Let's read the settings. PreToolUse means before a tool is used. The matcher Edit or Write means only for the tools that change and write files. Command is the script that runs, which is the checker from before. Claude sums up the meaning in one sentence. This is the habit to keep: never install a hook you can't explain in your own words. A hook must be tested. Raka deliberately asks Claude to change the WhatsApp number in the secret file, to prove the protection works. When Claude tries to change that file, the hook blocks it with a clear reason. The file isn't touched at all. Claude suggests that Raka change that file by hand. Exactly what we want: secrets stay in human hands. Raka adds one more hook: a notification on the laptop when Claude finishes working. Now Raka can work on college assignments while waiting, without watching the terminal. All settings are saved with a commit, so the hooks are recorded in the history and apply to anyone working on this project.
One important thing about hooks: a hook runs automatically with your access rights, without a permission box. So the first rule is, install only hooks you can explain in your own words. Second, when working in someone else's project, read its hooks and custom commands first. A hook from an unclear source could run anything on your computer. Third, keep all settings in Git and review them every few months. Delete the ones you no longer use. Fourth, never write passwords or tokens inside a hook or a custom command. Settings files are saved in the history and could be read by others. Let's close this session by looking at everything together. Git gives you a history and safe points to return to. Plan mode makes sure big changes are agreed on before they're made. Subagents split big tasks so they run in parallel. MCP connects Claude Code to browsers, services, and databases. And custom commands and hooks standardize routine work and enforce rules automatically. The screens in this video are simulations; menu names and file locations can change, so always check the official Claude Code documentation.
We created a custom command for routine work, set up a hook that protects secret files and a notification hook, and wrapped up the Advanced Claude Code session with a tidy, safe workflow. In the next episode we start a new session: API and Your Own Agent. We begin by getting to know the Claude API the easy way, as a path to building your own bot. See you there!
Try these on your own after watching to lock in what you learned.
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →