Module 5: Skills and Hooks: automating your workflow
Module 5: Skills and Hooks — automating your workflow
Module 5: Skills and Hooks — automating your workflow
Overview
You already have the Explore → Plan → Code workflow down. You know when to explore, when to plan, and when to execute. You manage the context window and decide when to start fresh sessions. That puts you ahead of most Claude Code users. Now comes the logical question: how do you make Claude Code adapt to you, instead of the other way around?
This module teaches Claude Code's two extension mechanisms: Skills and Hooks. Skills are markdown files in .claude/skills/ that Claude reads and follows as instructions — you invoke them with slash commands (/name). Hooks are scripts that run automatically at specific points in Claude Code's lifecycle — before writing a file, after running a command, when a task completes.
Together, Skills and Hooks turn Claude Code into a tool built for your project. You aren't limited to what Claude Code does out of the box — you can teach it your conventions, automate your validations, and build a quality system that runs without you having to remember to trigger it.
Where you are in the guide
Module 01: What Claude Code is ✅
Module 02: Installation and setup ✅
Module 03: CLAUDE.md and memory ✅
Module 04: Agentic workflow ✅
Module 05: Skills and Hooks ← YOU ARE HERE
Module 06: Subagents
Module 07: Integrations (Git, SDK, Remote Control)
Module 08: Capstone project
In the previous modules you configured Claude Code (Modules 02-03) and learned to work with it (Module 04). Now you move from using to extending. This module teaches you to shape Claude Code so it works exactly the way you need.
The mental model: plugins for an AI agent
Think about your IDE. VS Code has extensions. JetBrains has plugins. These let you add functionality without modifying the IDE itself. Claude Code has an analogous system — but for an AI agent.
┌─────────────────────────────────────────────────────────────┐
│ CLAUDE CODE │
│ │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ Skills │ │ Hooks │ │ Permissions │ │
│ │ (on-demand │ │ (automatic │ │ (access │ │
│ │ commands) │ │ events) │ │ control) │ │
│ └───────────────┘ └───────────────┘ └───────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ YOUR CUSTOM WORKFLOW │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
But there's a key difference: IDE plugins extend the UI. Claude Code's Skills and Hooks extend the agent's behavior. You aren't adding a button — you're defining how Claude thinks, acts, and checks its own work.
The precise analogy
| IDE concept | Claude Code concept | What it does |
|---|---|---|
| Extension/plugin | Skill | Adds a new capability on demand |
| Git hooks / watchers | Hook | Reacts automatically to events |
| Workspace permissions | Permission system | Controls what it can and can't do |
| Settings.json | CLAUDE.md + settings | Defines the baseline behavior |
How this differs from CLAUDE.md
In Module 03 you set up CLAUDE.md — the file Claude reads always, at the start of every session. Skills and Hooks are different:
| Mechanism | When it kicks in | Purpose |
|---|---|---|
| CLAUDE.md | Always, at session start | The project's baseline context |
.claude/rules/ | Always, or per path (with paths frontmatter) | Modular rules by topic or scope |
| Skills | You with /name, or Claude automatically based on description | Specific, repetitive tasks |
| Hooks | Automatically, on 22+ lifecycle events | Validations and automations |
CLAUDE.md says "what this project is". .claude/rules/ organizes rules by topic. Skills say "how I do this task". Hooks say "what I check automatically".
Module objectives
By the end of this module, you'll be able to:
- ✅ Create Skills in the current format (
SKILL.md+ YAML frontmatter) and invoke them with slash commands, or let Claude invoke them automatically viadescription - ✅ Configure Hooks using any of the 22+ lifecycle events (PreToolUse, PostToolUse, UserPromptSubmit, SessionStart/End, PreCompact/PostCompact, etc.)
- ✅ Use the 4 hook handler types:
command,http,prompt,agent - ✅ Automate validations with hooks (linting, testing, formatting, security checks)
- ✅ Understand the permission system and its 4 modes: default, accept edits, Auto mode (classifier, March 2026), bypass permissions
- ✅ Design an automated quality pipeline for your project
Prerequisites
Required knowledge:
- ✅ Module 04 completed (Explore → Plan → Code workflow mastered)
- ✅ Module 03 completed (CLAUDE.md configured in your project)
- ✅ Claude Code installed and running (Module 02)
For the practice:
- ✅ A real project with CLAUDE.md configured
- ✅ Comfort with the terminal and basic scripts (bash)
- ✅ Node.js installed (for hooks with JS scripts, if that applies)
Quick check:
Before you continue, make sure you can answer these questions:
- What are Claude Code's three modes, and when do you use each one?
- What is CLAUDE.md, and how does it differ from a README?
- What does the
/effortparameter do?
Answers
- Explore (read-only analysis, to understand the codebase), Plan (design without execution, to plan before implementing), Agent/Code (full execution, to implement). The typical cycle is Explore → Plan → Code.
- CLAUDE.md is Claude Code's persistent memory file. It defines conventions, stack, and project rules. Claude reads it at the start of every session. Unlike a README (written for humans), CLAUDE.md is written for the agent.
- The effort level controls how deeply the model reasons. The current models — Opus 5, Sonnet 5, and Fable 5 — have 5 levels (
low,medium,high,xhigh,max) withhighas the default;xhighis the one recommended for coding. You set it with/effort, inside/modelwith the ← → arrows, or in settings.
If you're not ready:
Review these first:
- Module 03: CLAUDE.md and the memory system
- Module 04: The agentic workflow
Module roadmap
This module has 5 progressive capsules:
Capsule 01 — Module introduction (this capsule)
Context, mental model, and roadmap. You understand what Skills and Hooks are and why they matter.
Capsule 02 — Creating skills (slash commands)
How to create skill files in .claude/skills/, name them, structure them, and invoke them with /name. From simple skills (create a component) to advanced ones (that reference other files and templates). Best practices for team skills vs personal ones.
Capsule 03 — Hooks: lifecycle events
The 5 lifecycle events: PreToolUse, PostToolUse, Notification, Stop, SubagentStop. How to configure them in settings.json, write hook scripts, use matchers to filter tools, and control the flow with return codes.
Capsule 04 — Automating validations
Hooks in practice: building an automated quality pipeline. Lint on every write, tests after implementing, security validation before commits. How to chain validations and avoid pitfalls (infinite loops, slow hooks).
Capsule 05 — Permission system
Claude Code's permission model: what it can do by default, how permissions get requested, how to configure approval levels, and the --dangerously-skip-permissions flag. Security and control on real projects.
Progression map
Capsule 01 (this one) → Mental model and context
Capsule 02 → Skills: your custom slash commands
Capsule 03 → Hooks: event-based automation
Capsule 04 → Automated validation pipeline
Capsule 05 → Permissions: security and control
Difficulty: ⭐ ──────────────────────────▶ ⭐⭐⭐
The first two capsules are foundational — you understand and create Skills. Capsules 03-05 are intermediate/advanced — you automate validations and control permissions.
What you'll build in this module
Across the 5 capsules, you'll build a complete extension system for your project:
- Custom skills — at least 2 invocable slash commands (e.g.
/create-component,/write-test) - Configured hooks — at least 2 working hooks (e.g. automatic lint, tests after implementing)
- Validation pipeline — an automated flow that checks quality on every action Claude takes
- Permission configuration — settings tuned to your level of trust and the kind of project
By the end of the module, your Claude Code won't be generic — it'll be a tool built for your workflow.
Why this matters
Without Skills or Hooks
Every time you want Claude to follow a specific convention, you have to spell it out in the prompt:
> Create a React component. Use TypeScript. Name the file
in PascalCase. Include a test in __tests__/. Use CSS Modules.
Export it as default. Add the barrel export in index.ts.
That's 6 instructions you have to remember and type every single time. With a skill:
> /create-component UserProfile
One line. All 6 instructions live in the skill file, ready to be used every time.
Without Hooks
After Claude writes a file, you have to remember to ask for validation:
> Run eslint on the file you just created.
> Now run prettier.
> Now run the related tests.
With hooks configured, all of that happens automatically after every write. You don't have to remember anything.
The compounding effect
Skills and Hooks strip out repetitive friction. In a 30-minute session, you might run 10-15 tasks. If each task has 3-4 manual validation steps, that's 30-60 actions you can automate. The gain isn't just time — it's consistency. Humans forget to run the linter. Hooks don't.
Connection to the capstone project
In Module 08, you'll build a complete CLI tool with Claude Code. For that project, you'll use exactly what you learn here:
- Skills: You'll create at least 2 custom skills for your CLI tool (e.g.
/add-commandto add a new CLI command,/write-testto create tests following your convention) - Hooks: You'll configure at least 2 hooks (e.g. automatic lint after every write, tests after implementing a new command)
Skills and Hooks aren't just an exercise — they're part of the capstone project's grading criteria.
Versions and compatibility
This module covers:
- Claude Code 2.0+
- Opus 5 (1M token context window)
- Sonnet 5 (1M token context window)
- Haiku 4.5 (200K context window)
Features covered:
- ✅ Skills in
.claude/skills/with slash commands - ✅ Hooks: PreToolUse, PostToolUse, Notification, Stop, SubagentStop
- ✅ Hook matchers (Write, Execute, Read, etc.)
- ✅ Hook scripts (bash, Python, Node.js)
- ✅ Permission system (allowedTools, session permissions)
- ✅ Settings:
.claude/settings.jsonand.claude/settings.local.json
A note on change:
Claude Code ships updates roughly every 2 days. Skills, Hooks, and Permissions are fundamental to Claude Code's architecture — the way you invoke them may shift in small ways, but the philosophy is stable. Always check the official docs to confirm exact syntax.
A look at the full module
To help you picture how Skills, Hooks, and Permissions fit together, here's a real scenario:
The session without customization
> Create a React component to show a list of products.
Claude creates the component... but uses CSS-in-JS instead of
CSS Modules (your convention). No test. Doesn't pass the linter.
> Hey, in this project we use CSS Modules, not styled-components.
> I also need a test.
> Run eslint please.
3 manual corrections. And this happens on EVERY component.
The session with Skills and Hooks
> /create-component ProductList
Claude reads the skill, follows the conventions, creates the
component with CSS Modules, generates the test, adds the barrel export.
[PostToolUse hook] → ESLint ran automatically → 0 errors
[PostToolUse hook] → Prettier ran → formatting correct
[PostToolUse hook] → Tests ran → 1/1 passing
0 manual corrections. All automatic.
That's the difference. And that's what you'll build in this module.
Key concepts you'll see
Skills: your slash commands
A skill is a directory in .claude/skills/ with a SKILL.md file containing YAML frontmatter + instructions. The directory name becomes the slash command:
.claude/skills/create-component/SKILL.md → /create-component
.claude/skills/write-test/SKILL.md → /write-test
.claude/skills/review-code/SKILL.md → /review-code
A SKILL.md looks like this:
---
name: create-component
description: Create a new React component following the project's conventions
---
Instructions Claude follows when /create-component is invoked...
The description field is critical: Claude uses it to invoke the skill automatically when it detects the skill is relevant to your request. No API, no complex configuration. The format follows the open Agent Skills standard.
Hooks: event-based automation
Hooks are configured in .claude/settings.json and run automatically when certain events occur:
| Event | When it fires | Example use |
|---|---|---|
| PreToolUse | Before a tool is used | Block writing secrets |
| PostToolUse | After a tool is used | Run the linter automatically |
| Notification | When Claude sends a notification | Send an alert to Slack or the terminal |
| Stop | When the main agent finishes | Run the test suite |
| SubagentStop | When a subagent finishes | Validate the subagent's output |
Hooks are scripts (bash, Python, Node) that receive information about the action (which file was modified, which command ran) and can react to it.
Permission system: granular control
Claude Code has a permission system that controls what it can do without asking and what requires your approval:
Read files → ✅ Always allowed
Search in files → ✅ Always allowed
Write files → ⚠️ Asks permission (configurable)
Run commands → ⚠️ Asks permission (configurable)
You can configure allowedTools in settings to pre-approve certain actions and cut friction without giving up safety.
The control triad
┌──────────────────────────────────────────────────────┐
│ │
│ PERMISSIONS SKILLS HOOKS │
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
│ │ What it CAN│ │ What it │ │ What gets │ │
│ │ do │ │ KNOWS to do│ │ VALIDATED │ │
│ │ │ │ │ │ auto- │ │
│ │ (control) │ │(capability)│ │ matically │ │
│ └────────────┘ └────────────┘ └────────────┘ │
│ │ │ │ │
│ └────────────────┼────────────────┘ │
│ ▼ │
│ A CONTROLLED AND │
│ CUSTOMIZED WORKFLOW │
│ │
└──────────────────────────────────────────────────────┘
Permissions define the limits. Skills define the capabilities. Hooks define the checks. Together, they create an agent that works exactly the way you need.
How it all fits together
To give you the full picture, here's how Skills, Hooks, and Permissions interact in a real session:
Session start
[Permission check] → Claude has permissions configured in settings.json
[CLAUDE.md] → Claude reads the project context
During the session
You: /create-component ProductCard
[Skill] → Claude reads .claude/skills/create-component/SKILL.md
[Permission] → Write(src/**) is in allowedTools → proceeds without asking
[PreToolUse hook] → Security check: no secrets → proceeds
[Claude writes the file]
[PostToolUse hook] → Prettier formats → ESLint validates → related tests pass
When the task finishes
[Stop hook] → tsc --noEmit: ✅ | npm test: 14/14 passing
Claude: "ProductCard component created with tests. All clean."
This flow is fully automatic. All you typed was /create-component ProductCard. Everything else — permissions, skill, hooks, validation — happened without you.
Summary
This module is where Claude Code stops being a generic tool and becomes your tool.
What you learned in this capsule:
- Skills and Hooks are Claude Code's extension system
- Skills = on-demand slash commands, Hooks = event-based automations
- CLAUDE.md defines the baseline context; Skills define tasks; Hooks define automations
- Skills remove the friction of repeating instructions; Hooks remove the friction of validating by hand
- In the capstone project (Module 08) you'll build 2+ real skills and 2+ real hooks
Next capsule: 02 - Creating skills (slash commands) — how to create, name, structure, and invoke your own custom commands.
Additional resources
Official documentation
- Hooks — Lifecycle events and hook configuration
- Plugins Reference — Skills, agents, hooks, MCP bundled
- Settings — Configuring scopes (global, project, local)
Best practices
- Claude Code Best Practices — Workflows and context management
- Memory — How CLAUDE.md and Skills interact
Complementary
- CLI Reference — Every command and slash command
- Interactive Mode — Permissions and task management