Custom Slash Commands

Table of content

Slash commands turn multi-step prompts into single keystrokes. Type /commit and get a smart commit message. Type /today and get your daily briefing.

How it works

Commands live in .claude/commands/ as markdown files:

.claude/
└── commands/
    ├── commit.md
    ├── review.md
    ├── today.md
    └── deploy.md

Run them with /name:

claude
> /commit
> /review src/
> /today

Your first command

Create .claude/commands/hello.md:

---
description: Test command
---

Say hello and tell me the current time.

Test it:

claude
> /hello

Command file structure

---
description: Short description shown in /help
---

Your prompt goes here. This is what Claude executes.

You can use multiple paragraphs.

Include specific instructions, context, or steps.
FieldPurpose
descriptionShows in command list (/help)
BodyThe actual prompt sent to Claude

Passing arguments

Use $ARGUMENTS to accept input:

---
description: Explain a concept simply
---

Explain $ARGUMENTS like I'm 5 years old. Use analogies.

Usage:

> /eli5 recursion
> /eli5 kubernetes networking

Practical examples

/commit — Smart commits

.claude/commands/commit.md:

---
description: Generate a commit message and commit
---

Look at the staged changes (git diff --cached).

Write a commit message following conventional commits:
- type(scope): description
- Types: feat, fix, docs, refactor, test, chore
- Keep first line under 72 chars
- Add body if changes are complex

Show me the message first. If I approve, run the commit.

/review — Code review

.claude/commands/review.md:

---
description: Review code for issues
---

Review $ARGUMENTS for:
1. Bugs and edge cases
2. Security issues
3. Performance problems
4. Code style violations

Be specific. Show line numbers. Suggest fixes.
Skip praise — only mention problems.

Usage:

> /review src/auth/login.ts
> /review --staged  # Review staged changes

/today — Daily briefing

.claude/commands/today.md:

---
description: Morning briefing
---

Give me my daily briefing:

1. **Calendar** — What's on today? Any prep needed?
2. **Tasks** — What's due? What's overdue?
3. **Yesterday** — Any captured notes or loose ends?
4. **Focus** — What should I prioritize?

Keep it tight. Bullet points. No fluff.

/deploy — Deployment workflow

.claude/commands/deploy.md:

---
description: Deploy to production
---

Run the deployment checklist:

1. Check git status — anything uncommitted?
2. Run tests — all passing?
3. Check current branch — on main?
4. Show recent commits since last tag

If all checks pass, ask me to confirm before running deploy.

Stop immediately if any check fails.

/test — Run and fix tests

.claude/commands/test.md:

---
description: Run tests and fix failures
---

Run the test suite: $ARGUMENTS

If tests fail:
1. Show which tests failed
2. Analyze the failure reason
3. Propose a fix
4. Ask before applying

If all pass, just say "All tests pass" and show coverage if available.

Usage:

> /test
> /test src/utils/
> /test --coverage

/pr — Create pull request

.claude/commands/pr.md:

---
description: Create a pull request
---

Create a PR for the current branch:

1. Show diff against main
2. Generate title from commits (conventional format)
3. Write description:
   - What changed
   - Why
   - Testing done
4. Create PR as draft

Ask me to confirm before creating.

Command patterns

PatternExampleUse case
No args/todayFixed workflows
File path/review $ARGUMENTSTarget specific files
Flags/test $ARGUMENTSPass options through
Confirmation“Ask before running”Destructive actions

Organization

For many commands, use subdirectories:

.claude/commands/
├── git/
│   ├── commit.md
│   ├── pr.md
│   └── rebase.md
├── dev/
│   ├── test.md
│   ├── lint.md
│   └── deploy.md
└── daily/
    ├── today.md
    └── weekly.md

Access with /git/commit, /dev/test, etc.

Tips


Next: Morning Briefing Workflow

Topics: claude-code automation workflow