Stay Updated!

Get the latest posts and insights delivered directly to your inbox

Skip to content

How to Speed Up Your Claude Code Experience with Slash Commands

Published: at 

I was wasting time. Every commit message, every branch name, every PR description. I typed the same things over and over. Then I discovered Slash Commands in Claude Code. Now I type /commit and it writes the message for me. /branch "add dark mode" and it creates feat/add-dark-mode. /pr and it generates a full PR description from my commits. This post shows you how to build the same workflow. I’ll cover how Slash Commands work, then we’ll build a complete system that automates your entire git lifecycle.

Claude Code executing /branch command showing git operations
The /branch command creates a feature branch automatically

📢 Prerequisites

You need Git and the GitHub CLI (gh). Install gh with brew install gh on macOS or check cli.github.com. Run gh auth login to authenticate.

Without gh, commands like /pr and /fix-pipeline will not work.

Two things you need to know#

Before we build the workflow, you need to understand two features.

Bash command execution#

Write !git status inside a command file. Claude runs the command first, captures the output, and injects it into the prompt. The AI sees the result before it starts thinking.

This is how /commit knows what you changed. It runs !git diff automatically. See the official documentation for more details.

Model selection#

You don’t need a powerful model to fix a missing semicolon. Claude Code lets you pick the model in the frontmatter:

Add model: haiku and commands run almost instantly.

Command structure#

Slash commands are Markdown files stored in .claude/commands/ (project-level) or ~/.claude/commands/ (personal). The filename becomes the command name: commit.md becomes /commit.

Here is a complete example:

---
description: Create a git commit with a conventional message
allowed-tools: Bash(git add:*), Bash(git commit:*)
argument-hint: [message]
model: haiku
---

# Commit Changes

<git_diff>
!`git diff --cached`
</git_diff>

Create a commit message following Conventional Commits.
If $ARGUMENTS is provided, use it as the commit message.
Claude Code slash command autocomplete showing available commands
Slash commands appear in autocomplete when you type /

Frontmatter options#

OptionPurposeDefault
descriptionBrief description shown in /helpFirst line of prompt
allowed-toolsTools the command can useInherits from conversation
modelModel to use (sonnet, haiku, or full model ID)Inherits from conversation
argument-hintShows expected arguments in autocompleteNone

Arguments#

Use $ARGUMENTS to capture everything passed to the command:

Create a branch named: $ARGUMENTS

For multiple arguments, use positional parameters $1, $2, etc:

---
argument-hint: [pr-number] [priority]
---

Review PR #$1 with priority $2.

File references#

Include file contents with the @ prefix:

Review the implementation in @src/utils/helpers.js

The workflow#

I replaced my manual git rituals with custom commands. They live in .claude/commands/. Here is how I drive a feature from start to merge.

Auto-fix

Fix Failure

No

Fix & Push

Yes

Start

/branch

Write Code

/lint
(Haiku)

/vitest
(Haiku)

/push

/pr

CI Pass?

/fix-pipeline
(Sonnet)

/review-coderabbit

/merge-to-main

Done

Development Workflow

/branch — start a task#

/lint — fix before commit#

/vitest — run unit tests#

/commit — save your work#

/push — commit and push in one step#

/fix-pipeline — fix failing CI tests#

/pr — create a pull request#

/review-coderabbit — address review comments#

/merge-to-main — finish the task#

Summary#

By moving your process into .claude/commands/, you are building a system.

Define the process once. Claude executes it every time.

Want to extend Claude Code even further? Connect external tools via MCP (Model Context Protocol) What Is the Model Context Protocol (MCP)? How It Works Learn how MCP (Model Context Protocol) standardizes AI tool integration, enabling LLMs to interact with external services, databases, and APIs through a universal protocol similar to USB-C for AI applications. mcptypescriptai or package your commands into a shareable plugin Building My First Claude Code Plugin How I built a Claude Code plugin to generate skills, agents, commands, and more—and stopped copy-pasting boilerplate. claude-codeaitooling +1 .

I don’t think about naming conventions, commit messages, or PR descriptions anymore. The commands handle it.

💪 Bonus: Shell aliases for even faster execution

You can skip the interactive prompt entirely with claude -p. Add aliases to your .zshrc or .bashrc:

alias clint="claude -p '/lint'"
alias cpush="claude -p '/push'"
alias ccommit="claude -p '/commit'"
alias cbranch="claude -p '/branch'"

Now clint runs the lint command without opening the interactive session. The -p flag passes the prompt directly—Claude executes and exits. Two steps become one keystroke.

Stay Updated!

Subscribe to my newsletter for more TypeScript, Vue, and web dev insights directly in your inbox.

  • Background information about the articles
  • Weekly Summary of all the interesting blog posts that I read
  • Small tips and trick
Subscribe Now