Essential Commands
The 10 Commands You Will Use Every Day
Video Lesson Coming Soon
A video walkthrough for this module is in production. For now, dive into the written content below.
What You'll Learn
- ✓ Slash commands at a glance
- ✓ Session management: /clear, /compact, /resume
- ✓ Cost tracking with /cost
- ✓ Keyboard shortcuts
- ✓ Non-interactive mode
- ✓ Conversation patterns that work
In this module 6 sections
Slash Commands at a Glance
| Command | What It Does |
|---|---|
| /clear | Reset the conversation — start fresh with no prior context |
| /compact | Summarize the conversation to free up context space |
| /cost | Show token usage and estimated cost for this session |
| /resume | Pick up your most recent conversation where you left off |
| /doctor | Diagnose common configuration and setup issues |
| /init | Generate a starter CLAUDE.md file for your project |
| /model | Switch to a different AI model mid-session |
| /memory | View and edit your saved memory files |
| /plan | Enter Plan Mode for read-only analysis |
| /help | Show all available commands and keyboard shortcuts |
Session Management
Every Claude Code conversation accumulates context — the files it has read, the commands it has run, the decisions it has made. This context is valuable because it means Claude Code remembers what you have been working on. But it is also finite.
Three commands manage your session context:
/compact summarizes your conversation without losing the important parts. Use it when things feel slow or when Claude Code starts repeating itself. Think of it as compressing a long email thread into bullet points.
/clear wipes everything and starts fresh. Use it when you are switching to a completely different task. There is no point dragging bug-fixing context into a feature-building conversation.
/resume reconnects to your last conversation. If your terminal crashed, your laptop restarted, or you just closed the window — /resume brings everything back.
# Start working on a bug fix
claude
> Fix the authentication timeout in auth.ts
# ... Claude Code investigates and fixes the bug ...
# Context is getting heavy — compress it
/compact
# Done with the bug — switching to a new feature
/clear
# The next day, resume where you left off
claude -c # or use /resume inside a session Tracking Costs with /cost
Claude Code uses tokens every time it reads files, generates text, or processes your prompts. The /cost command shows you exactly how many tokens you have used and what it costs.
This matters for two reasons. First, if you are on the API plan, every token costs money. Second, even on subscription plans, there are usage limits — and knowing your consumption helps you stay within them.
> /cost
Session usage:
Input tokens: 45,231
Output tokens: 12,847
Total tokens: 58,078
Estimated cost: $0.42
Model: claude-sonnet-4-6 Keyboard Shortcuts
| Shortcut | What It Does |
|---|---|
| Esc | Stop the current generation — Claude Code halts immediately |
| Esc + Esc | Undo — rewind the last action Claude Code took |
| Shift + Tab (twice) | Toggle Plan Mode on and off |
| Tab | Accept autocomplete suggestion |
| Up arrow | Cycle through your previous prompts |
| ? | Show all available keyboard shortcuts |
Esc + Esc is the most important shortcut to remember. If Claude Code makes a change you do not like — edits the wrong file, takes a wrong approach, or runs a command you did not expect — double-tap Escape to rewind the action. It undoes both the conversation and the code change.
Non-Interactive Mode
Claude Code is not limited to interactive conversations. You can use it as a command-line tool that processes input and exits — perfect for scripts, automation, and piping data.
# One-shot query: ask a question and get an answer
claude -p "Explain what the main function does in this project"
# Pipe data into Claude Code
cat error.log | claude -p "What caused this error?"
# Process output from another command
git diff | claude -p "Write a commit message for these changes"
# Use in a shell script
for file in src/components/*.tsx; do
claude -p "Add JSDoc comments to $file"
done Conversation Patterns That Work
Effective Prompting Patterns
- Start broad, then narrow — "Explain the auth system" before "Fix the token refresh bug in auth.ts"
- Reference specific files — "Look at src/utils/date.ts" is better than "look at the date utilities"
- Ask Claude Code to explain before changing — "What does this function do?" before "Refactor this function"
- Break large tasks into steps — "First, find all the API endpoints" then "Now add rate limiting to each one"
- State your constraints — "Fix this without changing the public API" or "Use only standard library functions"
Avoid these patterns that lead to poor results:
- Vague prompts: "Fix bugs" gives worse results than "Fix the null pointer in auth.ts line 42"
- Ignoring the diff preview: Always review what Claude Code plans to change before approving
- Long unfocused sessions: If you have been working for an hour on unrelated tasks, start a fresh session with /clear
Key Takeaways
Ten slash commands give you full control: /clear, /compact, /cost, /resume, /doctor, /init, /model, /memory, /plan, /help
Esc + Esc is your undo button — it rewinds both the conversation and code changes
Non-interactive mode (claude -p) lets you pipe data and use Claude Code in scripts and automation
Effective conversations start broad, reference specific files, and break large tasks into smaller steps