Basic Commands
Claude Code has built-in commands that start with /. These give you control over your session.
Essential Commands
/help - Get Help
> /help
Available commands:
/help - Show this help message
/clear - Clear conversation history
/exit - End session
/compact - Summarize and clear history
/cost - Show current session cost
...
โ
/clear - Start Fresh
> /clear
Conversation cleared. Starting fresh!
โ
โTip
Use /clear when you want to start a new task in the same project without old context.
/exit - End Session
> /exit
Session ended. Goodbye!
$
โ
Or just press Ctrl + C.
/cost - Check Usage
> /cost
Session cost: $0.12
- Input tokens: 15,234
- Output tokens: 8,567
โ
๐ฆ๐บAussie Note
Keep an eye on costs while learning! A typical learning session is under $0.50. ๐ฐ
Productivity Commands
/compact - Summarize History
When your conversation gets long:
> /compact
Summarizing conversation...
Conversation compacted. Key context preserved.
โ
This reduces token usage while keeping important context.
/undo - Revert Last Change
> /undo
Reverted: src/App.js
โ
โ Warning
/undo only works for recent file changes made by Claude. For bigger rollbacks, use git.
/diff - See Changes
> /diff src/App.js
Shows what Claude changed in the file
โ
Mode Commands
/plan - Think Before Acting
> /plan
Planning mode enabled. I'll show my plan before making changes.
โ
Great for complex tasks where you want to review the approach first.
/chat - Just Talk
> /chat
Chat mode. I won't make any file changes.
โ
Use this when you just want to discuss or learn without modifying files.
Quick Reference
| Command | What it does |
|---|
/help | List all commands |
/clear | Clear conversation |
/exit | End session |
/compact | Summarize and reduce tokens |
/cost | Show session cost |
/undo | Revert last change |
/diff [file] | Show changes to file |
/plan | Enable planning mode |
/chat | Talk without file changes |
Combining Commands
You can chat and use commands in the same session:
> Build a user authentication system
Claude: I'll create the auth system...
> /cost
Session cost: $0.08
> Actually, use JWT tokens instead
Claude: Good point, I'll switch to JWT...
> /diff src/auth.js
[shows the changes]
> Looks good!
โ
Key Takeaways
- Commands start with
/ /help shows all available commands/clear and /compact manage conversation length/cost helps track API usage/plan mode is great for complex tasks