DEV Community

brian austin
brian austin

Posted on

Claude Code custom slash commands: build your own /deploy, /review, /test

Claude Code custom slash commands: build your own /deploy, /review, /test

Claude Code ships with built-in slash commands like /help, /clear, and /compact. But the real power is in custom commands — project-specific shortcuts that run multi-step workflows with a single word.

Here's exactly how to build them.

What custom slash commands actually are

Custom slash commands are Markdown files in a .claude/commands/ directory. When you type /deploy in Claude Code, it reads .claude/commands/deploy.md and executes whatever's in it as a prompt.

That's it. No plugins, no config syntax — just Markdown files.

your-project/
├── .claude/
│   └── commands/
│       ├── deploy.md
│       ├── review.md
│       ├── test.md
│       └── standup.md
└── src/
Enter fullscreen mode Exit fullscreen mode

The $ARGUMENTS variable

Every custom command gets access to $ARGUMENTS — whatever text you type after the command name.

/review src/auth.js
Enter fullscreen mode Exit fullscreen mode

Inside your review.md, $ARGUMENTS becomes src/auth.js.

This makes commands composable:

/review src/auth.js
/review src/api/routes.js
/review src/utils/
Enter fullscreen mode Exit fullscreen mode

Same command, different target.

The commands I actually use

/deploy

File: .claude/commands/deploy.md

Pre-deployment checklist for $ARGUMENTS (or main branch if not specified):

1. Run the test suite and confirm all tests pass
2. Check for any console.log statements that shouldn't go to production
3. Verify environment variables are documented in .env.example
4. Check that package.json version was bumped if needed
5. Look for any TODO comments that should be resolved before shipping
6. Summarize what changed and whether it's safe to deploy

If anything fails, stop and explain what needs to be fixed first.
Enter fullscreen mode Exit fullscreen mode

Usage: /deploy or /deploy feature/auth-refactor

/review

File: .claude/commands/review.md

Code review $ARGUMENTS:

- Security: look for injection vulnerabilities, exposed secrets, unsafe eval
- Performance: N+1 queries, missing indexes, synchronous blocking operations
- Error handling: unhandled promises, missing try/catch, silent failures
- Style: naming consistency, function length, code duplication
- Tests: is this code testable? Are edge cases covered?

Be specific. Quote the exact lines that need attention.
Enter fullscreen mode Exit fullscreen mode

Usage: /review src/auth.js

/test

File: .claude/commands/test.md

Write comprehensive tests for $ARGUMENTS.

Requirements:
- Use the existing test framework (check package.json for jest/vitest/mocha)
- Cover happy path, edge cases, and error conditions
- Mock external dependencies (APIs, databases, file system)
- Test names should describe behavior, not implementation
- Aim for 80%+ coverage of the target file

Create the test file in the appropriate __tests__ directory.
Enter fullscreen mode Exit fullscreen mode

Usage: /test src/utils/validators.js

/standup

File: .claude/commands/standup.md

Generate a standup update based on recent git history:

1. Run: git log --oneline --since='24 hours ago' --author=$(git config user.email)
2. Summarize what was completed yesterday in 2-3 bullets
3. Identify what's in progress based on open branches or uncommitted changes
4. Flag any blockers visible in the code (TODO, FIXME, failing tests)

Format it for a Slack standup: brief, specific, no filler words.
Enter fullscreen mode Exit fullscreen mode

Usage: /standup

/explain

File: .claude/commands/explain.md

Explain $ARGUMENTS to a developer who's new to this codebase.

- What does this code do at a high level?
- What are the key inputs and outputs?
- What are the non-obvious design decisions and why were they made?
- What could go wrong and how does the code handle it?
- What would a developer need to know before modifying this?

Assume they're competent but unfamiliar with this specific code.
Enter fullscreen mode Exit fullscreen mode

Usage: /explain src/middleware/rateLimit.js

Global vs project commands

Commands in .claude/commands/ are project-scoped — they only appear when you're in that project.

For commands you want everywhere, put them in ~/.claude/commands/ (your home directory).

I keep these in my global commands:

~/.claude/commands/
├── gitblame.md      # explain why a line exists
├── refactor.md      # step-by-step refactor plan
├── security.md      # full security audit
└── docs.md          # generate JSDoc / README section
Enter fullscreen mode Exit fullscreen mode

Multi-step commands with subagents

Custom commands can trigger Claude Code's subagent system. If your command asks Claude to run multiple independent tasks, it'll spin them up in parallel.

Example — .claude/commands/audit.md:

Full codebase audit for $ARGUMENTS. Run these in parallel:

1. Security scan: check all files for hardcoded secrets, injection vulnerabilities
2. Dependency audit: run npm audit and explain any high/critical CVEs  
3. Performance check: find the 5 slowest database queries or API calls
4. Test coverage: identify files with 0% test coverage

Report findings by severity: Critical → High → Medium → Low.
Enter fullscreen mode Exit fullscreen mode

Claude Code spins up separate context windows for each task, then combines the results. For a large codebase, this can take minutes — but it's running in parallel, not sequential.

Sharing commands with your team

Since .claude/commands/ is just files in your project directory, check them into git:

git add .claude/commands/
git commit -m 'add claude code custom commands'
Enter fullscreen mode Exit fullscreen mode

Every developer on the team gets the same commands. No setup required — they appear automatically when someone opens the project in Claude Code.

This is the killer feature for teams: standardize your review process, deployment checks, and testing standards as Claude Code commands. New developers get the institutional knowledge baked in.

The rate limit problem with long commands

Complex commands that touch many files — like /audit on a large codebase — can hit Claude's rate limits mid-execution. The session stalls and you're stuck waiting.

One fix: set ANTHROPIC_BASE_URL to a proxy that removes rate limits.

export ANTHROPIC_BASE_URL=https://api.simplylouie.com
Enter fullscreen mode Exit fullscreen mode

With SimplyLouie ($2/month), your custom commands run to completion without interruption. Useful when /audit needs to read 200 files without stopping halfway.

Quick reference

Location Scope When to use
.claude/commands/ Project only Team workflows, project-specific checks
~/.claude/commands/ All projects Personal shortcuts you use everywhere
Variable Value
$ARGUMENTS Everything typed after the command name
Pattern Example
Target file /review src/auth.js
Branch name /deploy feature/login
No args /standup

Custom commands are one of those Claude Code features that most developers discover by accident. Once you start using them, you build a library of project-specific shortcuts that encode your actual workflow — not generic AI prompts, but the exact steps your team runs before deploying your app.

Top comments (0)