Slash Commands, Hooks & More: Steering Claude Code
Three ways to steer Claude Code: slash commands you type yourself, hooks that run automatically, and subagents that take over subtasks.
Slash commands: you type, Claude Code reacts
A slash command is a command you type directly in the session. It always starts with a slash. Claude Code ships with many built-in commands, for example:
/help- shows help and available commands/config- opens settings for theme, model, and output style/compact- summarizes the conversation so far to free up context window space/model- switches the model and saves it as your new default/permissions- manages allow/ask/deny rules for tools/clear- starts a new conversation with empty context
Custom slash commands: saved prompts
You can also build your own commands. Add a markdown file to the .claude/commands/ folder. The file name becomes the command name: deploy.md becomes /deploy. The text in that file is the prompt Claude receives once you run the command. This pays off for anything you repeat often, like 'summarize my uncommitted changes' or 'clean up this file'. Instead of retyping the prompt every time, you just type /your-command.
Hooks: rules that run automatically
Hooks are scripts Claude Code runs automatically at specific events - for example before a tool runs (PreToolUse), after a tool finishes (PostToolUse), or when a session starts (SessionStart). A hook receives info about the event and can allow it, block it, or just log it. You configure hooks in a JSON settings file, project-wide in .claude/settings.json or across all your projects in ~/.claude/settings.json. The difference from slash commands: you don't call a hook yourself. It runs automatically, without asking.
Subagents: handing off subtasks
Subagents delegate a subtask to a separate agent with its own context (see the Subagents guide). Claude Code recognizes on its own when a task fits a subagent and routes it there automatically. The subagent works through the task and returns only the result - your main context stays clean because the intermediate steps stay inside the subagent's own context.
The mental model
Three tools, three roles. Slash commands are something you steer yourself, you decide when they run. Hooks run automatically, they're fixed rules for events. Subagents are delegation, a subtask moves into its own separate context.
EXAMPLE
File `.claude/commands/changelog.md`: --- description: Summarizes uncommitted changes as one changelog line --- Summarize the current git diff as a single changelog line. Run it with: `/changelog`
QUICK QUIZ
What's the core difference between slash commands and hooks?
SOURCES
- Claude Code docs: Slash commands โ code.claude.com
- Claude Code docs: Commands reference โ code.claude.com
- Claude Code docs: Hooks โ code.claude.com
- Claude Code docs: Subagents โ code.claude.com