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
- All 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 |
/cost | Show token usage and estimated cost for this session |
/memory | View and manage memory entries |
/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 |
/history | View conversation history |
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 defined as Markdown files in specific directories.
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.md
Inside the file, write the prompt that should execute when you type /project:review:
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 /project:review in Claude Code, it executes this entire prompt.
Naming Convention
- Project commands are accessed as
/project:command-name - User commands are accessed as
/user: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:
/project: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: /project: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. Access them with:
claude config
Key Settings
Theme: Choose between light and dark mode for the CLI interface.
Default model: Set which Claude model to use by default.
Auto-approve tools: Configure which tools (Edit, Write, Bash, etc.) are auto-approved without asking permission each time.
Notification preferences: Control when and how Claude Code notifies you about completed operations.
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",
"notifications": true,
"verbose": false
\}
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.
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 | Exit prompt (press twice to exit Claude Code) |
| Up Arrow | Previous prompt |
| Tab | Accept suggestion / Autocomplete |
Custom Keybindings
Keybindings are configured in:
~/.claude/keybindings.json
You can remap keys to suit your workflow. For example:
[
\{
"key": "ctrl+s",
"command": "submit"
\},
\{
"key": "ctrl+k",
"command": "clear"
\}
]
Chord Bindings
You can create multi-key combinations (chords):
[
\{
"key": "ctrl+k ctrl+c",
"command": "compact"
\}
]
This means pressing Ctrl+K followed by Ctrl+C triggers the compact command.
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
- `/project:review` - Run a comprehensive code review on the current diff
- `/project:test <file>` - Generate tests for a specific file
- `/project:document <file>` - Generate documentation for a module
- `/project:pre-commit` - Run the full pre-commit checklist
Key Takeaways
- Built-in slash commands like
/compact,/clear,/cost, and/memoryhandle essential session management - Custom slash commands are Markdown files stored in
.claude/commands/(project) or~/.claude/commands/(personal) - Commands use the
$ARGUMENTSplaceholder to accept input, making them flexible and reusable - Project-level commands are accessed as
/project:command-name, user-level as/user:command-name - Settings in
~/.claude/settings.jsoncontrol default behavior like theme, auto-approve tools, and notifications - Keybindings in
~/.claude/keybindings.jsonlet you customize keyboard shortcuts and create chord combinations - Commit project commands to git so your entire team benefits from shared workflows

