DEV Community

brian austin
brian austin

Posted on

Claude Code custom commands: the slash commands I use every day

Claude Code custom commands: the slash commands I use every day

If you're still typing the same instructions into Claude Code every session, you're missing one of its most useful features.

Custom slash commands let you define reusable prompts that run with a single /command. Here are the ones I use constantly — copy them directly.

How custom commands work

Create a directory: .claude/commands/

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

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

Then:

# Usage inside Claude Code:
/review-pr
/write-tests
/explain-this
Enter fullscreen mode Exit fullscreen mode

You can also create global commands that work across all projects:

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

My most-used custom commands

/review-pr — code review before every commit

File: .claude/commands/review-pr.md

Review the staged git changes as if you're a senior engineer doing a PR review.

Check for:
- Logic bugs or edge cases
- Security issues (SQL injection, XSS, auth bypasses, exposed secrets)
- Performance problems (N+1 queries, missing indexes, blocking operations)
- Missing error handling
- Tests that should exist but don't

Output format:
- BLOCKER: things that must be fixed before merge
- WARNING: things worth addressing
- SUGGESTION: optional improvements

Be direct. Don't explain what the code does — only flag problems.
Enter fullscreen mode Exit fullscreen mode

/write-tests — generate test coverage for current file

File: .claude/commands/write-tests.md

Write comprehensive tests for the current file or the file I specify.

Rules:
- Use the testing framework already in the project (detect from package.json or existing tests)
- Cover: happy path, edge cases, error cases, boundary conditions
- Mock external dependencies (HTTP calls, database, filesystem)
- Each test should have a clear description of what it's testing
- No redundant tests — quality over quantity

If the code is untestable (no dependency injection, side effects everywhere), tell me what refactoring is needed first.
Enter fullscreen mode Exit fullscreen mode

/explain-this — understand unfamiliar code quickly

File: .claude/commands/explain-this.md

Explain the code I'm looking at as if I've never seen this codebase.

Cover:
1. What this code does (one sentence)
2. How it works (key logic, important variables)
3. What it connects to (dependencies, callers, side effects)
4. What could break (known edge cases, implicit assumptions)

Don't use jargon. Be specific about THIS code, not generic principles.
Enter fullscreen mode Exit fullscreen mode

/fix-this — targeted bug fix

File: .claude/commands/fix-this.md

Fix the problem I describe. 

Before changing anything:
1. Confirm you understand the bug
2. Identify the root cause (not just the symptom)
3. Show me what you're going to change

Then fix it. Don't refactor unrelated code. Don't add features. Fix the specific problem.

After fixing, explain why the original code was wrong.
Enter fullscreen mode Exit fullscreen mode

/security-audit — quick security scan

File: .claude/commands/security-audit.md

Run a security audit on the current codebase or the file I specify.

Check for:
- Injection vulnerabilities (SQL, command, LDAP)
- Authentication/authorization flaws
- Sensitive data exposure (hardcoded secrets, logging PII)
- Insecure direct object references
- Missing input validation
- Dependency vulnerabilities (check package.json if present)
- CORS misconfiguration
- Missing rate limiting

Prioritize by severity: CRITICAL → HIGH → MEDIUM → LOW

For each finding: what it is, where it is, how to fix it.
Enter fullscreen mode Exit fullscreen mode

/git-commit — write a proper commit message

File: .claude/commands/git-commit.md

Write a git commit message for the staged changes.

Format:
Enter fullscreen mode Exit fullscreen mode

():


Types: feat, fix, docs, style, refactor, test, chore

Rules:
- First line max 72 characters
- Body explains motivation and context, not implementation
- Don't list every changed file
- Past tense for fixes, present tense for features
Enter fullscreen mode Exit fullscreen mode

Global commands (work in every project)

Put these in ~/.claude/commands/ — they're available everywhere.

~/.claude/commands/daily-standup.md

Look at my recent git commits (last 24h) and draft a standup update.

Format:
- What I did yesterday
- What I'm doing today  
- Any blockers

Be brief. One sentence per item.
Enter fullscreen mode Exit fullscreen mode

~/.claude/commands/rubber-duck.md

I'm going to explain a problem I'm stuck on. Ask me clarifying questions to help me think it through.

Don't jump to solutions. Help me find the answer myself by asking the right questions.

Start with: 'What have you already tried?'
Enter fullscreen mode Exit fullscreen mode

Commands with arguments

Custom commands can include $ARGUMENTS — whatever you type after the command name gets substituted in:

File: .claude/commands/pr-description.md

Write a pull request description for: $ARGUMENTS

Include:
- What this PR does (2-3 sentences)
- Why it was needed
- How to test it
- Any migration steps or breaking changes

Tone: clear and professional, not overly formal.
Enter fullscreen mode Exit fullscreen mode

Usage: /pr-description add user authentication with JWT

The full command directory structure

~/.claude/commands/          # Global (all projects)
  daily-standup.md
  rubber-duck.md

.claude/commands/            # Project-specific
  review-pr.md
  write-tests.md
  explain-this.md
  fix-this.md
  security-audit.md
  git-commit.md
  pr-description.md
Enter fullscreen mode Exit fullscreen mode

One more thing: rate limits

If you're hitting Claude's rate limits mid-session while running these commands, you can point Claude Code at an alternative endpoint:

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

This routes through SimplyLouie — a $2/month Claude proxy that removes rate limits. The slash commands all work identically.


What custom commands have you built? Drop them in the comments.

Top comments (0)