Loading learning content…
Loading learning content…
Build reusable skills and configure lifecycle hooks to automate repetitive patterns in your Claude Code workflow.
Read through the lesson, mark it complete when the concept is clear, then move to the next lesson in the sequence or jump back to the module map.
Skills are reusable prompt templates stored in ~/.claude/skills/ or project-level skills/ directories. Instead of retyping complex instructions, you invoke a skill with /skill-name.
Create ~/.claude/skills/code-review.md:
# Code Review
Review the specified code for:
1. Logic errors and edge cases
2. Security vulnerabilities
3. Performance issues
4. Type safety
5. Code style consistency
Output a ranked list of findings with severity (Critical/High/Medium/Low)
and suggested fixes for each.
Invoke it with: /code-review src/lib/auth.ts
Hooks run automatically at defined points in the Claude Code lifecycle. Configure them in ~/.claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "npx prettier --write $CLAUDE_FILE_PATH"
}
]
}
]
}
}
This automatically formats every file after Claude edits it.
| Hook | Trigger | Use Cases |
|---|---|---|
PreToolUse |
Before any tool runs | Validation, parameter injection |
PostToolUse |
After any tool runs | Auto-format, type-check, tests |
Stop |
Session ends | Final verification, cost logging |
PreCompact |
Before context compaction | Save session state |
Auto-typecheck after edits:
{
"matcher": "Edit(*.ts,*.tsx)",
"hooks": [{"type": "command", "command": "npx tsc --noEmit 2>&1 | tail -5"}]
}
Block dangerous operations:
{
"matcher": "Bash",
"hooks": [{"type": "block", "condition": "command contains 'rm -rf'"}]
}
Start a skills/ directory in your project with skills for your most repeated tasks:
/deploy-check — pre-deployment verification checklist/migration — database migration workflow/component — React component creation with tests/api-endpoint — REST endpoint scaffoldOver time, skills compound into a powerful personal automation layer.