Claude Academy
Sign in

Claude Code in Action · lesson 4 of 6

Claude Code Slash Commands

Reusable, parameterized prompts you invoke with /command. Cheap, fast way to encode repeatable workflows.

Where they live

  • ~/.claude/commands/ — user-global commands.
  • <repo>/.claude/commands/ — project-shared (committed to repo).
  • Each file is a markdown prompt. Filename = command name (e.g., review.md/review).

Anatomy

<repo>/.claude/commands/review.md:

---
description: Review the current diff for correctness and security.
allowed-tools: Bash(git diff:*), Bash(git status), Read, Grep
---

Review the staged and unstaged diff in this repo.

Focus on:
- correctness bugs
- security issues (injection, auth, secrets)
- missing tests

Output a markdown checklist of findings, severity-tagged.

Frontmatter is optional. Useful fields:

  • description — shown in / autocomplete.
  • allowed-tools — narrow tool set for this command.
  • argument-hint — placeholder shown to user.

Arguments

In the markdown body, $ARGUMENTS is replaced with whatever the user typed after the command name.

Generate a unit test for the function $ARGUMENTS.

Usage: /test-for src/utils/format.ts:formatDate

Bash interpolation

Use backticks to embed shell output:

The current branch is `git branch --show-current`. Review since `git merge-base HEAD main`.

Slash command vs Skill vs Subagent

NeedUse
Reusable parameterized promptSlash command
Larger reusable capability with files/binariesSkill
Isolated context for a delegated taskSubagent

CCA-F angle

Recognize when to use a slash command vs a skill vs a subagent. Slash commands are stateless prompt templates; skills include resources and instructions; subagents are isolated execution.

See also