DEV Community

brian austin
brian austin

Posted on

Claude Code slash commands I use every day (and how to build your own)

Claude Code slash commands I use every day (and how to build your own)

Claude Code ships with a handful of built-in slash commands. Most developers use maybe two of them. Here's what's actually available, which ones I reach for constantly, and how to add your own project-specific commands in under five minutes.

The built-in commands worth knowing

/help          — show all available commands
/clear         — clear conversation history (saves context)
/compact       — summarize conversation to save tokens
/review        — review recent changes
/pr            — create a pull request from staged changes
/init          — generate CLAUDE.md for this project
/bug           — report a Claude Code bug
Enter fullscreen mode Exit fullscreen mode

The ones I actually use daily: /clear, /compact, and /review.

/clear is underrated. When you've been in a session for an hour and context is bloating, /clear resets the conversation without closing the terminal. Cheaper than starting a new session and re-explaining your project.

/compact is the subtler version — it keeps the conversation but summarizes it, so Claude retains context without burning tokens on the full history.

/review before every commit. Takes 10 seconds, catches the obvious stuff.

The real power: custom slash commands

This is where Claude Code gets interesting. You can define project-specific commands in .claude/commands/.

Setup

mkdir -p .claude/commands
Enter fullscreen mode Exit fullscreen mode

Each .md file in that directory becomes a slash command.

Example: /deploy

Create .claude/commands/deploy.md:

Run the deployment checklist:
1. Run `npm test` — if any tests fail, STOP and report failures
2. Run `npm run build` — if build fails, STOP and report errors  
3. Check git status — if there are uncommitted changes, ask me to confirm
4. Run `git push origin main`
5. Wait 30 seconds, then check if the service is responding at localhost:3000
6. Report: tests passed, build succeeded, pushed, service health status
Enter fullscreen mode Exit fullscreen mode

Now you type /deploy and Claude runs your entire deployment checklist. It asks for confirmation on ambiguous steps. It stops and reports on failure.

Example: /review

Create .claude/commands/review.md:

Review all changes since the last git commit:
1. Run `git diff HEAD` to see all changes
2. For each changed file, check:
   - Are there any hardcoded secrets, API keys, or passwords?
   - Are there any obvious logic errors?
   - Are there any missing error handlers?
   - Are there any console.log statements that shouldn't be in production?
3. Run `npm test` to make sure nothing is broken
4. Summarize what changed and flag any concerns
Enter fullscreen mode Exit fullscreen mode

Example: /todo

Create .claude/commands/todo.md:

Scan the entire codebase for TODO and FIXME comments:
1. Run: grep -r "TODO\|FIXME\|HACK\|XXX" --include="*.js" --include="*.ts" --include="*.py" .
2. Group results by file
3. For each TODO, assess: is this blocking? Is it stale? Should it be an issue?
4. Output a prioritized list: BLOCKING / SHOULD FIX / LOW PRIORITY
Enter fullscreen mode Exit fullscreen mode

Example: /staging

Create .claude/commands/staging.md:

Deploy to staging environment:
1. Run `npm test` — fail fast if tests broken
2. Run `npm run build`
3. Run `./scripts/deploy-staging.sh`
4. Run `./scripts/smoke-test.sh staging`
5. If smoke tests pass: report success with staging URL
6. If smoke tests fail: run `./scripts/rollback-staging.sh` and report what failed
Enter fullscreen mode Exit fullscreen mode

Global commands (available in every project)

For commands you want everywhere, put them in ~/.claude/commands/ instead of .claude/commands/.

I keep a /security command here that I use across all my projects:

Run a security audit:
1. Check package.json for known vulnerable packages: run `npm audit`
2. Scan for hardcoded secrets: grep -r "password\|secret\|api_key\|apikey" --include="*.js" . | grep -v node_modules | grep -v ".git"
3. Check .gitignore — is .env listed? Are there any .env files that shouldn't be committed?
4. Check for SQL injection risks in any database queries
5. Report findings by severity: CRITICAL / HIGH / MEDIUM / INFO
Enter fullscreen mode Exit fullscreen mode

The argument injection pattern

You can reference the text after your slash command with $ARGUMENTS:

Create .claude/commands/pr.md:

Create a pull request for: $ARGUMENTS

1. Run `git status` to see what's staged
2. Run `git diff --staged` to review changes
3. Write a PR description covering: what changed, why, how to test
4. Run `gh pr create --title "$ARGUMENTS" --body "[generated description]"`
Enter fullscreen mode Exit fullscreen mode

Now /pr fix the login bug creates a PR with that title and an auto-generated description.

Rate limits kill slash commands mid-task

The one thing that breaks custom slash commands: rate limits. You set up a /deploy that runs tests, builds, checks health... and Claude hits a rate limit halfway through. The command fails silently. You don't know if the deploy actually happened.

The fix is setting ANTHROPIC_BASE_URL to a proxy that removes rate limits:

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

This routes Claude Code through SimplyLouie's Claude proxy ($2/month). No rate limits, no mid-task interruptions. Your custom slash commands actually complete.

I use this specifically for long-running commands like /deploy and /security — the ones where getting cut off halfway is worse than not running at all.

The full workflow

Here's my actual setup:

# Global commands (~/.claude/commands/)
/security    — runs across all projects
/snippets    — my personal code patterns

# Project commands (.claude/commands/)
/deploy      — project-specific deployment
/staging     — staging deploy + smoke test
/review      — pre-commit check
/todo        — scan and prioritize TODOs
/pr          — create PR with generated description
Enter fullscreen mode Exit fullscreen mode

Total setup time: about 20 minutes the first time. Now every project has a consistent deploy/review/audit workflow that doesn't depend on me remembering the steps.

Quick reference

Command location Scope Use for
~/.claude/commands/ All projects Security audits, personal patterns
.claude/commands/ This project only Deploy, test, staging workflows
Built-in /clear All sessions Reset context when session gets long
Built-in /compact All sessions Summarize without losing context
Built-in /review All sessions Pre-commit sanity check

The commands directory is version-controlled with your project. Your whole team gets the same /deploy workflow. No more "how do I deploy this thing" questions.


Tired of Claude Code rate limits killing your slash commands mid-task? SimplyLouie.com is a $2/month Claude proxy — set ANTHROPIC_BASE_URL=https://simplylouie.com and your commands actually complete.

Top comments (0)