Custom Slash Commands in Claude Code

You can define custom shortcuts in Claude Code by adding Markdown files to the .claude/commands/ directory. This guide shows how to set up a deployment command as an example.

Nov 11, 2025 · 2 min read · 282 Words · -Views -Comments · Programming

In my current project, I frequently need to deploy builds to a development server. While CI/CD pipelines are great, they can be slow for quick iterations; sometimes a simple scp command is much faster. Since I spend most of my time in the Claude Code (cc) CLI, I wanted a more integrated way to trigger these scripts without manually typing out bash commands. Here is how I set up custom slash commands in Claude Code.

Configuration

Custom commands are scoped to the project. Create a directory named .claude/commands/ in your project root. For example, to create a development deployment command, create a file named deploy-dev.md.

The content should follow this structure: use Markdown for the description and a code block for the actual script.

# Deploy to Development Server
Run this command to build the project and sync files to the dev environment.

```bash
npm run build
scp -r ./dist user@dev-machine:/path/to/deploy

After saving the file, restart your `claude` session. You can now execute it by typing `/deploy-dev` in the CLI.

## Permissions

Commands like `scp` are considered sensitive. By default, Claude Code will ask for permission before executing shell scripts. You have two options:
1. Start Claude Code with the `--dangerously-skip-permissions` flag (not recommended for general use).
2. Allow the command when prompted and select the "Always allow for this project" option to add it to your project's whitelist.

## Summary

1. This is a basic example, but you can use natural language within the Markdown file to provide more context or complex instructions for the command.
2. The Claude Code CLI is arguably the best AI-driven terminal tool available right now. Mastering its custom commands can significantly boost your development workflow.
Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover