Module 2: Getting Started with Claude CodeLesson 5 of 6
0%
Lesson 5ยท4 min

Basic Commands

Learn the essential slash commands for Claude Code

Basic Commands

Claude Code has built-in commands that start with /. These give you control over your session.

Essential Commands

/help - Get Help

Terminal
> /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

Terminal
> /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

Terminal
> /exit
Session ended. Goodbye!
$
โ–Œ

Or just press Ctrl + C.

/cost - Check Usage

Terminal
> /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:

Terminal
> /compact
Summarizing conversation...
Conversation compacted. Key context preserved.
โ–Œ

This reduces token usage while keeping important context.

/undo - Revert Last Change

Terminal
> /undo
Reverted: src/App.js
โ–Œ

Warning

/undo only works for recent file changes made by Claude. For bigger rollbacks, use git.

/diff - See Changes

Terminal
> /diff src/App.js
Shows what Claude changed in the file
โ–Œ

Mode Commands

/plan - Think Before Acting

Terminal
> /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

Terminal
> /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

CommandWhat it does
/helpList all commands
/clearClear conversation
/exitEnd session
/compactSummarize and reduce tokens
/costShow session cost
/undoRevert last change
/diff [file]Show changes to file
/planEnable planning mode
/chatTalk without file changes

Combining Commands

You can chat and use commands in the same session:

Terminal
> 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