Essential Claude Code Slash Commands Every Developer Should Know
Problem
When I use Claude Code for long coding sessions, I face three problems:
- Context runs out - My conversation history grows until Claude warns me about context limits
- No rollback - When experiments go wrong, I lose work
- 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:
| Category | Commands |
|---|---|
| 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.
/compact/compact focus on the auth module, ignore migration files/compact preserve the debugging steps, summarize other discussionsKey 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.
/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.
/btw How do I check if a Python dict has a key?
# Answer appears, but doesn't pollute main conversationPerfect 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.
# Before risky changes, Claude may create a checkpoint# If something goes wrong:/rewind
# Select the checkpoint to restore# Reverts both conversation AND file changesUse this before major refactors or when trying unfamiliar approaches.
/diff
Shows what changed in your files.
/diff
# Interactive viewer shows:# - Which files changed# - What was added/removed# - Changes per turnUse this before commits to understand your changes.
Planning & Execution Commands
/plan [description]
Starts a structured planning session for complex tasks.
/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 low # Simple tasks: formatting, small fixes/effort medium # Normal tasks: default level/effort high # Complex tasks: architecture decisions/effort max # Critical: bug investigations, security analysisMatch 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.
# Complete your featuregit add .git commit -m "feat: add user endpoint"
# Review changes/diff
# Check for security issues/security-review
# Output shows potential vulnerabilities with severityThis 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.
/insights
# Output:# - Average context usage per session# - Most used commands# - Common task patterns# - Productivity suggestionsUse weekly to identify workflow bottlenecks.
/init
Generates a CLAUDE.md file for a new project.
/init
# Claude analyzes your codebase and creates:# - Project structure overview# - Technology stack identification# - Suggested development guidelinesUse 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:
# 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 safelySummary
In this post, I covered the 10 essential Claude Code slash commands. The key takeaways are:
- Context management - Use
/compactat 70% with focused instructions, not when warned - Workflow safety -
/rewindand/difflet you experiment confidently - Security -
/security-reviewcatches vulnerabilities before they ship - Efficiency -
/btwfor zero-cost questions,/effortto 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