Skip to content

Essential Claude Code Slash Commands Every Developer Should Know

Problem

When I use Claude Code for long coding sessions, I face three problems:

  1. Context runs out - My conversation history grows until Claude warns me about context limits
  2. No rollback - When experiments go wrong, I lose work
  3. Security blindspots - I commit code without checking for vulnerabilities

I discovered that Claude Code has slash commands that solve all three problems. But I didn’t know about them at first.

Environment

  • Claude Code CLI
  • Used for: coding, refactoring, debugging
  • Typical session: 2-4 hours

What Are Slash Commands?

Slash commands start with / and do specific tasks. They’re not regular chat messages - they trigger Claude to take action.

The 10 most essential commands fall into 4 categories:

CategoryCommands
Context Management/compact, /context, /btw
Workflow Safety/rewind, /diff
Planning & Execution/plan, /effort
Security & Insights/security-review, /insights, /init

Context Management Commands

/compact [instructions]

This is the most important command. It compresses your conversation history to free up context space.

Usage examples
/compact
/compact focus on the auth module, ignore migration files
/compact preserve the debugging steps, summarize other discussions

Key insight from Reddit: Run it at 70-75% context usage, not when Claude warns you. Always pass instructions - without them, you get a generic summary that loses important context.

/context

Shows what’s consuming your context window.

Sample output
/context
# Output:
# System prompts: 15,000 tokens
# Conversation: 45,000 tokens
# File contents: 30,000 tokens
# Total: 90,000 / 200,000 (45%)

Use this to decide when to run /compact.

/btw [question]

Asks a quick question without adding to your conversation history. Zero context cost.

Usage example
/btw How do I check if a Python dict has a key?
# Answer appears, but doesn't pollute main conversation

Perfect for “how do I…” questions that don’t need project context.

Workflow Safety Commands

/rewind

Creates checkpoints and lets you rollback. This is your safety net for experiments.

How it works
# Before risky changes, Claude may create a checkpoint
# If something goes wrong:
/rewind
# Select the checkpoint to restore
# Reverts both conversation AND file changes

Use this before major refactors or when trying unfamiliar approaches.

/diff

Shows what changed in your files.

Usage
/diff
# Interactive viewer shows:
# - Which files changed
# - What was added/removed
# - Changes per turn

Use this before commits to understand your changes.

Planning & Execution Commands

/plan [description]

Starts a structured planning session for complex tasks.

Usage example
/plan Refactor authentication middleware to support JWT and OAuth2
# Claude enters planning mode
# Creates step-by-step approach
# Identifies risks and dependencies

/effort [level]

Controls how much reasoning Claude puts into responses.

Effort levels
/effort low # Simple tasks: formatting, small fixes
/effort medium # Normal tasks: default level
/effort high # Complex tasks: architecture decisions
/effort max # Critical: bug investigations, security analysis

Match effort to task complexity. Don’t use max for everything - it’s slower and uses more tokens.

Security & Insights Commands

/security-review

Analyzes your git diff for vulnerabilities. I run this before every PR.

Workflow
# Complete your feature
git add .
git commit -m "feat: add user endpoint"
# Review changes
/diff
# Check for security issues
/security-review
# Output shows potential vulnerabilities with severity

This caught subtle input handling issues I would have shipped. It’s fast because it only analyzes changed code, not the whole codebase.

/insights

Shows patterns in your Claude Code usage.

What it reveals
/insights
# Output:
# - Average context usage per session
# - Most used commands
# - Common task patterns
# - Productivity suggestions

Use weekly to identify workflow bottlenecks.

/init

Generates a CLAUDE.md file for a new project.

Usage
/init
# Claude analyzes your codebase and creates:
# - Project structure overview
# - Technology stack identification
# - Suggested development guidelines

Use when starting with a new codebase or after major project changes.

Common Mistakes

Mistake 1: Waiting for context warning before /compact

Don’t wait. Claude performs worse near context limits. Check /context and compact at 70-75%.

Mistake 2: Running /compact without instructions

You lose important context. Always tell it what to preserve.

Mistake 3: Using regular chat for quick questions

Context pollution. Use /btw instead.

Mistake 4: Skipping /security-review for “small” changes

Even 5-line changes can have vulnerabilities. Run it before every PR.

Mistake 5: Not using /rewind proactively

Create checkpoints before experiments, not just after failures.

My Daily Workflow

Here’s how I use these commands in a typical session:

Morning session workflow
# Start work
/init # If new project
# Check context periodically
/context # At start, after file reads
# Plan complex feature
/plan Add rate limiting to API endpoints
# Work on implementation...
# (coding happens here)
# Quick question mid-work
/btw How do I mock datetime in pytest?
# At 70% context
/compact focus on API implementation, ignore test setup discussions
# Before commit
/diff # Review changes
/security-review # Check for vulnerabilities
# If experiment fails
/rewind # Rollback safely

Summary

In this post, I covered the 10 essential Claude Code slash commands. The key takeaways are:

  1. Context management - Use /compact at 70% with focused instructions, not when warned
  2. Workflow safety - /rewind and /diff let you experiment confidently
  3. Security - /security-review catches vulnerabilities before they ship
  4. Efficiency - /btw for zero-cost questions, /effort to match reasoning to task

Start with /context and /compact - they have the biggest impact on daily workflow. Then add /security-review to your PR process.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments