🔗Custom Commands & Hooks
Create reusable workflows and automate actions
Custom Commands (Skills)
Custom commands let you package repeatable workflows that your whole team can share.
Creating a Custom Command
Create a file in .claude/commands/ in your project:
mkdir -p .claude/commandsExample: /review-pr command
Create .claude/commands/review-pr.md:
Review the current PR changes. For each file:
1. Check for bugs and logic errors
2. Verify error handling
3. Look for security issues
4. Check for performance problems
5. Verify tests cover the changes
Format your review as:
- **File**: path
- **Issues**: list any problems
- **Suggestions**: improvementsNow you can run:
claude /review-prMore Custom Command Ideas
.claude/commands/deploy-check.md:
Before deploying, check:
1. All tests pass
2. No TypeScript errors
3. No lint warnings
4. Build succeeds
5. No TODO or FIXME comments in changed files
Report a go/no-go decision with reasons..claude/commands/write-tests.md:
Write comprehensive tests for the file I specify:
1. Unit tests for each exported function
2. Edge cases (null, undefined, empty, boundary values)
3. Error scenarios
4. Use the project's existing test patterns
5. Run the tests and fix any failuresHooks
Hooks let you run shell commands automatically before or after Claude Code performs certain actions.
What Are Hooks?
| When | What Happens |
|---|---|
| Before file edit | Run a command before Claude edits a file |
| After file edit | Auto-format, lint, or run tests after edits |
| Before command | Validate or log before Claude runs a terminal command |
| After command | Check results after Claude runs something |
Example Hook: Auto-Format After Edit
In your Claude Code settings, you can configure hooks to automatically run Prettier after every file edit:
{
"hooks": {
"afterEdit": "npx prettier --write {file}"
}
}Example: Run Tests After Edit
{
"hooks": {
"afterEdit": "npm test -- --related {file}"
}
}MCP (Model Context Protocol)
MCP lets Claude Code connect to external data sources:
- Google Drive — Read design docs
- Jira — Update tickets
- Slack — Post messages
- Databases — Query data
- Custom tools — Your own integrations
Setting Up MCP
MCP servers are configured in your Claude Code settings. Each server provides tools that Claude can use during a session.
Next up: Advanced Claude Code workflows — agent teams, CI/CD, and automation.