Automate repetitive actions with a single command
Slash commands are Markdown files that Claude executes when you invoke them with /. They live in your project under .claude/commands/ and contain instructions Claude follows every time you call them. Think of them as intelligent macros.
.claude/
└── commands/
├── optimize.md → /optimize
├── pr.md → /pr
├── commit.md → /commit
└── review.md → /reviewEach file has two parts: YAML frontmatter with metadata, and the body with instructions for Claude.
--- name: commit description: Generate a commit message following Conventional Commits --- Analyze the staged changes (git diff --staged) and generate a commit message that: 1. Follows Conventional Commits format: type(scope): description 2. Uses types: feat, fix, chore, docs, refactor, test, style 3. Description in present tense, maximum 72 characters 4. Adds body if changes are complex Most common types: - feat: new feature - fix: bug fix - chore: build changes, dependencies - refactor: refactor with no behavior change
You can use $ARGUMENTS in the command body to accept parameters. Example: /review security specifically evaluates vulnerabilities.
# Invoke directly in chat /commit # With arguments /review security # See all available commands /help
Project slash commands (.claude/commands/) are local to the repository. Personal commands (~/.claude/commands/) are available across all your projects.
exercise
Create your first slash command
Create the file .claude/commands/standup.md in your project with the content below. Then invoke it with /standup in Claude Code.
--- name: standup description: Generate the daily standup report based on recent commits --- Check commits from the last 24 hours with: git log --since="24 hours ago" --oneline Generate a standup report in this format: **Yesterday:** - [list of what I did based on commits] **Today:** - [suggested next logical steps based on recent work] **Blockers:** - None (unless you see something in the code suggesting a problem) Maximum 5 points per section. Professional, concise tone.