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.
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.
.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:
Three things to notice in that example:
- The YAML frontmatter defines metadata Claude Code uses to route and restrict the command.
allowed-toolsis a security boundary — this command cannot rungit pushor any tool other than the three listed. - 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. $ARGUMENTSis where anything the user typed after the command name gets injected. If you run/commit auth refactor, the stringauth refactorreplaces$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 likeBash(git diff:*)to allow onlygit diff-family commands.model— force a specific model (sonnet,opus,haiku). Useful for cheap-model commands like/commitand 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-toolsstops a "quick refactor" from turning into agit push --force. - Composition. Commands can invoke other commands, sub-agents, or MCP tools. Build a
/shipcommand 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 reserveopusfor 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.
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.
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
Extract functions, rename safely, reduce nesting, convert JS→TS, modernize legacy patterns.
- /refactor
- /extract-function
- /convert-to-typescript
- /reduce-nesting
- /rename-safe
Generate JSDoc, docstrings, READMEs, API docs, architecture decision records.
- /docs
- /jsdoc
- /readme
- /api-docs
- /adr
Security, performance, accessibility, and general code review with structured output.
- /review
- /review-security
- /review-performance
- /pr-summary
- /review-a11y
Pre-deploy checks, rollback plans, feature flags, canary configs, deployment scripts.
- /deploy
- /pre-deploy-check
- /rollback-plan
- /feature-flag
- /canary-config
Conventional commits, PR descriptions, merge conflict resolution, safe rebases.
- /commit
- /commit-with-context
- /pr-description
- /merge-conflicts
- /rebase-safe
Root-cause analysis, repro scripts, log strategies, memory leak hunts.
- /debug
- /find-bug
- /repro
- /log-strategy
- /memory-leak
System design, diagrams, ADRs, data models, service boundary decisions.
- /architecture
- /system-design
- /diagram
- /adr
- /data-model
Component generation, accessibility audits, responsive checks, form validation, error boundaries.
- /component
- /accessibility
- /responsive
- /form-validation
- /error-boundary
API endpoints, middleware, auth flows, RBAC, webhook handlers, background jobs.
- /api-endpoint
- /middleware
- /auth
- /rbac
- /webhook
Schema design, migrations, query optimization, N+1 fixes, index strategy.
- /schema
- /migration
- /query-optimize
- /n1-query-fix
- /index-strategy
Dockerfiles, CI/CD pipelines, GitHub Actions, K8s manifests, Terraform modules.
- /dockerfile
- /ci-pipeline
- /github-actions
- /k8s-manifest
- /terraform-module
Security audits, dependency checks, secrets scanning, CSRF/XSS/injection defenses.
- /security-audit
- /dependency-check
- /secrets-scan
- /csrf-protect
- /xss-audit
Performance audits, cache strategies, bundle analysis, Core Web Vitals, lazy loading.
- /perf-audit
- /cache-strategy
- /bundle-analyze
- /core-web-vitals
- /lazy-load
Notebook scaffolds, RAG setup, embedding generation, vector search, model evaluation.
- /notebook-setup
- /rag-setup
- /embedding-generate
- /vector-search
- /model-eval
40 most-used commands right now
The commands developers install first, based on newsletter downloads, waitlist survey data, and community submissions. Click any to see the full Markdown, frontmatter, and usage notes.
How to create your own slash command in 5 steps
The fastest path from an idea to a working, team-shared slash command.
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.
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.
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.
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.
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.
Related long-form guides
In-depth reference material for when you need more than a snippet.
Claude Code Slash Commands — The Ultimate Playbook
Every pattern for writing, sharing, and versioning slash commands. The 20 commands every team should have on day one.
Setup GuideThe Complete Claude Code Setup Guide
From npm install to a production-ready environment: MCP servers, hooks, agents, cost caps, and team sync.
Deep DiveCustom Skills vs Slash Commands vs Subagents
The three big Claude Code primitives explained with a decision tree for when to reach for each.
SecuritySlash Command Security — allowed-tools Patterns
How to write allowed-tools patterns that keep team commands safe. Real examples of what to avoid.
Free tools for slash commands
Generators, builders, and analyzers — no signup, no account needed.
Slash Command Generator
Describe any task, get a working YAML slash command with tools, description, and prompt template.
Free ToolSlash Command Playground
Test any slash command against a sample codebase before you commit it to your project.
Free ToolRepo → Command Setup Analyzer
Paste a GitHub URL, get a tailored list of commands to install for that stack.
Free ToolToken Usage Estimator
Estimate the token cost of a slash command's context injection before you ship it.
🐛 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.
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>.mdat the project root — for team-shared commands. Commit this to git.~/.claude/commands/<name>.mdin 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:*)— onlygit 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:
- 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`. RequiresBash(command:*)inallowed-tools. - Mid-conversation invocation. If the
Bashtool 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
/architector/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.
Get the weekly Claude Code digest
Every Tuesday: new slash commands, Anthropic release recap, and the best community submission of the week. 13,000+ developers read it.