Custom Slash Commands, Settings, and Keybindings
Claude Code comes with built-in slash commands that handle common tasks, but you can also create your own custom commands tailored to your workflow. Combined with settings and keybindings, these customizations turn Claude Code from a general-purpose tool into one that is perfectly tuned for how you work.
In this lesson, you will learn how to use built-in commands, create powerful custom slash commands, and configure Claude Code's settings and keybindings.
What You Will Learn
- Key built-in slash commands and when to use them
- How to create custom slash commands
- Parameterized commands and command chains
- Configuring Claude Code settings
- Customizing keybindings
- Sharing commands across your team
Built-In Slash Commands
Claude Code includes several built-in commands you can access by typing / during a conversation:
Essential Commands
| Command | Purpose |
|---|---|
/help | Show all available commands and usage tips |
/clear | Clear conversation and start fresh |
/compact | Compress conversation to save context space |
/usage | Show session cost, plan usage limits, and activity stats (/cost is an alias) |
/memory | Edit CLAUDE.md files and manage auto memory |
/permissions | View and modify permission settings |
/status | Show current session status and configuration |
Conversation Management
| Command | Purpose |
|---|---|
/compact | Summarize conversation to reclaim context |
/clear | Wipe conversation and start over |
/resume | Browse and resume past conversations |
Configuration
| Command | Purpose |
|---|---|
/config | Open configuration settings |
/model | Change the current model |
/permissions | Manage tool permissions |
Creating Custom Slash Commands
Custom slash commands let you package frequently used prompts into reusable shortcuts. They are Markdown files in .claude/commands/. The same idea is now covered by skills (.claude/skills/<name>/SKILL.md), which are recommended for new work and can include supporting files. Existing command files keep working, and this lesson uses them because they are the simplest place to start.
Where Custom Commands Live
Custom commands can be stored in two locations:
Project-level commands (shared with your team):
my-project/.claude/commands/
User-level commands (personal to you):
~/.claude/commands/
Creating Your First Custom Command
Create a file in your project's .claude/commands/ directory. The filename becomes the command name:
.claude/commands/review-diff.md
Inside the file, write the prompt that should execute when you type /review-diff:
Review the current git diff for:
1. Bugs or logic errors
2. Security vulnerabilities
3. Performance issues
4. Code style violations
5. Missing error handling
For each issue found, explain the problem, its severity,
and suggest a fix. If no issues are found, confirm the
code looks good.
Now when you type /review-diff in Claude Code, it executes this entire prompt. Pick names that do not clash with built-in commands. Claude Code already has /review, for example.
Naming Convention
- Both project and user commands are run as
/command-name - The filename (without .md extension) becomes the command name
- Use kebab-case for filenames:
code-review.md,deploy-check.md
Parameterized Commands
Custom commands can accept arguments using the $ARGUMENTS placeholder:
Create .claude/commands/explain.md:
Explain the following file or code concept in detail,
including its purpose, how it works, and how it connects
to the rest of the codebase:
$ARGUMENTS
Usage:
/explain src/services/auth.ts
The $ARGUMENTS placeholder is replaced with whatever you type after the command name.
Practical Custom Command Examples
Code Review Command
.claude/commands/review-pr.md:
Review the changes in the current branch compared to main.
1. Run `git diff main...HEAD` to see all changes
2. For each changed file, analyze:
- Correctness: Are there bugs or logic errors?
- Security: Are there any vulnerabilities?
- Performance: Are there any inefficiencies?
- Tests: Are there adequate tests for the changes?
3. Summarize your findings with severity levels
4. Suggest specific improvements where applicable
Test Generation Command
.claude/commands/test.md:
Generate comprehensive tests for:
$ARGUMENTS
Follow these rules:
- Match the testing patterns in existing test files
- Cover happy paths, edge cases, and error conditions
- Use descriptive test names that explain the expected behavior
- Include setup and teardown where needed
- Mock external dependencies
Usage: /test src/services/payment.ts
Documentation Command
.claude/commands/document.md:
Generate documentation for:
$ARGUMENTS
Include:
- A brief description of what the module/function does
- Parameters with types and descriptions
- Return value description
- Usage examples
- Any important notes or caveats
Pre-Commit Check Command
.claude/commands/pre-commit.md:
Run a pre-commit checklist:
1. Run the linter: `npm run lint`
2. Run the type checker: `npm run typecheck`
3. Run the test suite: `npm test`
4. Check for any console.log statements that should be removed
5. Check for any TODO comments that should be addressed
6. Show a summary of all issues found
Refactor Command
.claude/commands/refactor.md:
Refactor the following code:
$ARGUMENTS
Goals:
- Improve readability and maintainability
- Follow the project's coding conventions (see CLAUDE.md)
- Preserve all existing behavior (no functional changes)
- Add or update comments where logic is complex
- Run tests after refactoring to verify nothing broke
Configuring Settings
Claude Code's settings control its behavior across sessions. Open them inside a session with /config, or edit the settings files directly:
/config
Key Settings
Theme: Choose between light and dark mode for the CLI interface.
Default model: Set which Claude model to use by default.
Permission rules: Use /permissions or the permissions key in your settings file to control which tools run without asking.
Editor mode: Switch between normal and Vim-style editing in the prompt.
Settings File Location
Settings are stored in:
~/.claude/settings.json
You can edit this file directly if you prefer. Here is an example configuration:
{
"theme": "dark",
"verbose": false,
"permissions": {
"allow": ["Bash(npm run test *)"],
"deny": ["Read(./.env)"]
}
}
Project-Level Settings
You can also create project-specific settings in:
my-project/.claude/settings.json
Project settings override user settings for that project only. For personal overrides in one project, use .claude/settings.local.json, which stays out of git.
Customizing Keybindings
Claude Code supports custom keybindings to make your workflow faster.
Default Keybindings
| Key | Action |
|---|---|
| Enter | Submit prompt / Confirm action |
| Escape | Cancel current operation |
| Ctrl+C | Cancel the current operation (press Ctrl+D twice to exit Claude Code) |
| Up Arrow | Previous prompt |
| Tab | Accept suggestion / Autocomplete |
Custom Keybindings
Keybindings are configured in the file below. Run /keybindings to create or open it:
~/.claude/keybindings.json
The file holds a bindings array of blocks. Each block has a context, such as Chat, and a map of keystrokes to actions. For example:
{
"bindings": [
{
"context": "Chat",
"bindings": {
"ctrl+e": "chat:externalEditor",
"ctrl+s": null
}
}
]
}
Actions use a namespace:action format. Setting a key to null removes its default binding. Changes apply without a restart. Ctrl+C and Ctrl+D are reserved and cannot be rebound.
Chord Bindings
You can create multi-key combinations (chords), and you can bind a key to any slash command with command:<name>:
{
"bindings": [
{
"context": "Chat",
"bindings": {
"ctrl+k ctrl+c": "command:compact"
}
}
]
}
This means pressing Ctrl+K followed by Ctrl+C runs /compact.
Sharing Commands with Your Team
Since project-level commands live in .claude/commands/, they are part of your repository. This means:
- Commit them to git so your entire team has access
- Standardize workflows with team-wide commands for code review, testing, and deployment
- Document them in your CLAUDE.md so team members know what commands are available
Example CLAUDE.md section:
## Custom Claude Code Commands
- `/review-diff` - Run a comprehensive code review on the current diff
- `/test <file>` - Generate tests for a specific file
- `/document <file>` - Generate documentation for a module
- `/pre-commit` - Run the full pre-commit checklist
Key Takeaways
- Built-in slash commands like
/compact,/clear,/usage, and/memoryhandle essential session management - Custom slash commands are Markdown files stored in
.claude/commands/(project) or~/.claude/commands/(personal). Skills in.claude/skills/are recommended for new work - Commands use the
$ARGUMENTSplaceholder to accept input, making them flexible and reusable - Project and user commands are both run as
/command-name, using the filename without.md - Settings in
~/.claude/settings.jsoncontrol default behavior like theme and permission rules. Open them with/config - Keybindings in
~/.claude/keybindings.json(open with/keybindings) let you customize keyboard shortcuts per context and create chord combinations - Commit project commands to git so your entire team benefits from shared workflows
Quiz
Up next ยท Lesson 10 of 14
MCP Servers: Connecting External Tools
7 min read
9 of 14 lessons done

