Claude Code Slash Commands — 195 Tested Templates | AI Code Toolkit
195 tested commands · 15 categories · Updated within 48h of every Anthropic release

Claude Code Slash Commands

The complete library of production-tested slash command templates. Testing, refactoring, code review, deployment, debugging, security, performance — every workflow, one keystroke.

195
Commands
15
Categories
100%
Tested
48h
Update SLA

What are Claude Code slash commands?

Slash commands are user-defined prompt templates that live as Markdown files inside your project (or your home directory). Type / followed by the command name in Claude Code, and the file's contents get sent to Claude as your prompt — often with dynamic arguments, tool restrictions, and even shell command output pre-injected.

Think of them as bash aliases for Claude Code: repeatable, versionable, and shareable across your team. Instead of retyping the same "review this code for security issues, focus on OWASP top 10, output as a table" prompt every time, you save it once as /security-review and forget the details.

The one-line version: A slash command is a Markdown file at .claude/commands/<name>.md (project) or ~/.claude/commands/<name>.md (user) that expands into a prompt when you type /<name>.

Anatomy of a slash command

Every slash command is a single Markdown file with two parts — an optional YAML frontmatter block and the prompt body:

markdown .claude/commands/commit.md
--- allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git log:*) description: Generate a Conventional Commit message from staged changes model: sonnet argument-hint: [optional context or scope] --- # Context - Current status: !`git status --short` - Staged diff: !`git diff --cached --stat` - Last 5 commits (for tone): !`git log --oneline -5` # Your task Write a Conventional Commit message based on the staged changes above. Rules: 1. Format: `type(scope): description` 2. Keep the subject line under 72 characters 3. If breaking change, add `!` after type and `BREAKING CHANGE:` footer 4. If tests are included, mention them in the body 5. Additional context from user: $ARGUMENTS Output only the commit message, no preamble.

Three things to notice in that example:

  1. The YAML frontmatter defines metadata Claude Code uses to route and restrict the command. allowed-tools is a security boundary — this command cannot run git push or any tool other than the three listed.
  2. The ! prefix in the body runs a shell command before the prompt is sent to Claude. The output is inlined into the prompt as context. This is how you make commands feel "aware" of the current repo state.
  3. $ARGUMENTS is where anything the user typed after the command name gets injected. If you run /commit auth refactor, the string auth refactor replaces $ARGUMENTS. For positional args, use $1, $2, etc.

Frontmatter fields you'll actually use

  • description — short summary shown in the / autocomplete menu.
  • allowed-tools — whitelist of tools the command can call. Use narrow patterns like Bash(git diff:*) to allow only git diff-family commands.
  • model — force a specific model (sonnet, opus, haiku). Useful for cheap-model commands like /commit and expensive-model commands like /architect.
  • argument-hint — placeholder shown in the input UI so users know what to type.
  • disable-model-invocation — prevent Claude from auto-invoking the command via natural language (useful for destructive commands).

Why every serious Claude Code user has 20+ slash commands

  • Repeatability. The prompt is exactly the same every time. No forgetting the "output as JSON" or "check for N+1 queries" instruction.
  • Team standardization. Check .claude/commands/ into git and every developer on the team gets the same commands the same day.
  • Tool boundaries. allowed-tools stops a "quick refactor" from turning into a git push --force.
  • Composition. Commands can invoke other commands, sub-agents, or MCP tools. Build a /ship command that runs /security-review, then /test, then /deploy.
  • Context injection. The ! shell prefix and @ file reference let you pre-load state without wasting a turn asking Claude to look.
  • Cost control. Force cheap models on high-frequency commands (/commit, /rename) and reserve opus for the ones that need it.

Slash commands vs subagents vs hooks — when to use each

All three are ways to shape Claude Code's behavior, but they solve different problems:

  • Slash command = a prompt template you invoke by typing. It runs in your main conversation. Best for: repeated prompts, on-demand workflows, quick standardization.
  • Subagent = a specialized Claude with its own context window and system prompt. Best for: complex tasks that need a dedicated "role" (security reviewer, DB migration expert), or work you want to isolate from your main chat.
  • Hook = a shell command that runs automatically at a lifecycle event (before a tool call, after a session ends, on prompt submit). Best for: security gates, auto-formatters, cost logging — anything you want to happen without being asked.

You'll often use all three together. A /deploy slash command that invokes a deploy-checker subagent, gated by a PreToolUse hook that blocks pushes to main.

Browse by Category

15 categories covering the full development lifecycle

Each sub-category page has the complete listing, real Markdown files, and copy-paste-ready configs. Every command tested against the latest Claude Code release.

🧪 Testing 15

Generate unit, integration, and E2E tests. Coverage checks, flaky-test fixes, mock generation.

  • /test-unit
  • /test-e2e
  • /coverage-check
  • /mock-external-apis
  • /fix-flaky-test
Browse all 15 →
♻️ Refactoring 15

Extract functions, rename safely, reduce nesting, convert JS→TS, modernize legacy patterns.

  • /refactor
  • /extract-function
  • /convert-to-typescript
  • /reduce-nesting
  • /rename-safe
Browse all 15 →
📚 Documentation 14

Generate JSDoc, docstrings, READMEs, API docs, architecture decision records.

  • /docs
  • /jsdoc
  • /readme
  • /api-docs
  • /adr
Browse all 14 →
🔍 Code Review 13

Security, performance, accessibility, and general code review with structured output.

  • /review
  • /review-security
  • /review-performance
  • /pr-summary
  • /review-a11y
Browse all 13 →
🚀 Deployment 11

Pre-deploy checks, rollback plans, feature flags, canary configs, deployment scripts.

  • /deploy
  • /pre-deploy-check
  • /rollback-plan
  • /feature-flag
  • /canary-config
Browse all 11 →
🌿 Git Workflows 11

Conventional commits, PR descriptions, merge conflict resolution, safe rebases.

  • /commit
  • /commit-with-context
  • /pr-description
  • /merge-conflicts
  • /rebase-safe
Browse all 11 →
🐛 Debugging 11

Root-cause analysis, repro scripts, log strategies, memory leak hunts.

  • /debug
  • /find-bug
  • /repro
  • /log-strategy
  • /memory-leak
Browse all 11 →
🏗️ Architecture 10

System design, diagrams, ADRs, data models, service boundary decisions.

  • /architecture
  • /system-design
  • /diagram
  • /adr
  • /data-model
Browse all 10 →
🎨 Frontend 15

Component generation, accessibility audits, responsive checks, form validation, error boundaries.

  • /component
  • /accessibility
  • /responsive
  • /form-validation
  • /error-boundary
Browse all 15 →
⚙️ Backend 15

API endpoints, middleware, auth flows, RBAC, webhook handlers, background jobs.

  • /api-endpoint
  • /middleware
  • /auth
  • /rbac
  • /webhook
Browse all 15 →
🗄️ Database 13

Schema design, migrations, query optimization, N+1 fixes, index strategy.

  • /schema
  • /migration
  • /query-optimize
  • /n1-query-fix
  • /index-strategy
Browse all 13 →
🔧 DevOps 14

Dockerfiles, CI/CD pipelines, GitHub Actions, K8s manifests, Terraform modules.

  • /dockerfile
  • /ci-pipeline
  • /github-actions
  • /k8s-manifest
  • /terraform-module
Browse all 14 →
🔒 Security 13

Security audits, dependency checks, secrets scanning, CSRF/XSS/injection defenses.

  • /security-audit
  • /dependency-check
  • /secrets-scan
  • /csrf-protect
  • /xss-audit
Browse all 13 →
⚡ Performance 12

Performance audits, cache strategies, bundle analysis, Core Web Vitals, lazy loading.

  • /perf-audit
  • /cache-strategy
  • /bundle-analyze
  • /core-web-vitals
  • /lazy-load
Browse all 12 →
🤖 Data / AI / ML 12

Notebook scaffolds, RAG setup, embedding generation, vector search, model evaluation.

  • /notebook-setup
  • /rag-setup
  • /embedding-generate
  • /vector-search
  • /model-eval
Browse all 12 →
How to Use

How to create your own slash command in 5 steps

The fastest path from an idea to a working, team-shared slash command.

1

Choose the file location

Slash commands live in one of two places:

  • .claude/commands/<name>.md — project-scoped. Commit to git so your team gets it too.
  • ~/.claude/commands/<name>.md — user-scoped. Personal to you across all projects.

Prefer project scope for team standards. Reserve user scope for personal preferences.

2

Write the frontmatter

Add a YAML block at the top. At minimum, include description so it appears nicely in the / autocomplete menu. Add allowed-tools to restrict what the command can execute — the narrower, the safer.

3

Write the prompt body

The body is a normal Markdown prompt. Use $ARGUMENTS (or $1, $2) to accept user input. Use !` cmd ` to pre-inject shell command output. Use @file.ts to pre-inject file contents. Keep the prompt focused — one command, one job.

4

Test it in Claude Code

Type / in Claude Code and the command appears in the autocomplete. Select it, add any arguments, and press enter. If it doesn't behave as expected, iterate on the prompt — commands are cheap to edit.

5

Share it with your team

Commit .claude/commands/<name>.md to git. On next pull, teammates get the command instantly — no install step, no config to update. This is the whole point of project-scoped commands.

🐛 Hit an error while using slash commands?

Our sister site AI Error Hub covers Claude Code errors, MCP connection failures, and stack traces — cross-referenced with everything on this site.

Visit AI Error Hub →
FAQ

Frequently asked questions

The questions developers ask most about slash commands.

A Claude Code slash command is a Markdown file (with optional YAML frontmatter) stored in .claude/commands/ or ~/.claude/commands/ that acts as a reusable prompt template. Type /command-name in Claude Code and the file's contents are sent to Claude as your prompt, optionally with dynamic arguments, tool restrictions, and pre-injected shell output.

Two locations:

  • .claude/commands/<name>.md at the project root — for team-shared commands. Commit this to git.
  • ~/.claude/commands/<name>.md in your home directory — for personal commands across all projects.

Project-scoped files take precedence when a name collides.

Type them after the command name. In the command's Markdown body:

  • $ARGUMENTS — everything the user typed after the command name.
  • $1, $2, $3… — positional arguments.

Example: /commit refactor auth flow makes $ARGUMENTS equal to refactor auth flow.

Add an allowed-tools field to the YAML frontmatter with a comma-separated list of tool patterns:

  • Bash(git diff:*) — only git diff-family commands.
  • Read, Grep, Glob — read-only file access.
  • Edit, Write — file modification.

Anything not in the list is blocked at runtime. This is the primary security boundary for team-shared commands.

Yes, in two ways:

  1. Pre-injection with !. Prefix a line with ! and Claude Code runs it as a shell command before sending the prompt, inlining the output as context. Example: !`git status --short`. Requires Bash(command:*) in allowed-tools.
  2. Mid-conversation invocation. If the Bash tool is allowed, Claude can decide to run shell commands during its response.

A slash command is a prompt template that runs in your main Claude Code conversation. A subagent is a specialized Claude with its own context window and system prompt that runs as a delegated sub-task.

Rule of thumb: slash commands for repeated prompts and quick workflows; subagents for complex tasks that need isolation, dedicated system prompts, or restricted tool sets. They often work together — a /security-review command can delegate to a security-reviewer subagent.

Yes. Add model: sonnet, model: opus, or model: haiku to the frontmatter. This is useful for cost control:

  • Force Haiku on high-frequency commands like /commit, /rename.
  • Force Sonnet for most everyday commands.
  • Reserve Opus for expensive reasoning like /architect or /root-cause.

If no model is set, Claude Code uses whatever model is currently active in the session.

Commit .claude/commands/ to git. That's the whole workflow.

When a teammate pulls, they get every command immediately — no install step, no config file to update, no plugin to enable. This is why project-scoped commands are the standard for team standardization.

Yes, and it's a powerful combination. Hooks fire on tool-use events, so a slash command that invokes tools also triggers hooks.

Common pattern: a /deploy slash command that runs deployment tools, gated by a PreToolUse hook that blocks deploys to production outside business hours or without a passing test suite. See our hooks hub for the full lifecycle.

Browse the 195 tested commands on this site, organized into 15 categories. Each command page shows the full Markdown file, the frontmatter, and real-world usage notes.

When our Toolkit CLI ships, one command installs the whole set into any project.