beginner15 min read· Module 4, Lesson 3
⌨️Claude Code Essential Commands
Master the core commands and interactive features
Essential Claude Code Commands
Starting a Session
# Start interactive mode in current directory
claude
# Ask a one-off question
claude "explain what this project does"
# Start with a specific prompt
claude -p "analyze this codebase for security issues"In-Session Slash Commands
When you're inside a Claude Code session, these commands are available:
| Command | What It Does |
|---|---|
/help | Show available commands |
/clear | Clear conversation history |
/compact | Summarize conversation to save context |
/cost | Show token usage and cost |
/doctor | Check health of your setup |
/init | Create a CLAUDE.md for your project |
/memory | View saved memories |
/review | Review code changes |
/fast | Toggle fast mode |
Common Workflows
Explore a codebase:
claude "explain the architecture of this project"
claude "what does the main entry point do?"
claude "find where user authentication is handled"Write code:
claude "add a login page with email and password fields"
claude "write unit tests for the auth module"
claude "create a REST API endpoint for user profiles"Fix bugs:
claude "fix the TypeError in src/utils/parser.ts"
claude "this test is failing: [paste error]. fix it"Git operations:
claude "commit my changes with a descriptive message"
claude "create a new branch called feature/login"
claude "open a PR for my current changes"Piping Data to Claude
Claude Code follows Unix philosophy — you can pipe data into it:
# Analyze logs
tail -200 app.log | claude -p "find any errors or anomalies"
# Review changed files
git diff main --name-only | claude -p "review these changes for issues"
# Process a file
cat data.csv | claude -p "summarize this data"Non-Interactive Mode
For scripts and automation, use the -p flag (pipe/print mode):
# Get a quick answer
claude -p "what is the main export of src/index.ts?"
# Generate code to stdout
claude -p "write a dockerfile for a node app" > DockerfileKeyboard Shortcuts
| Shortcut | Action |
|---|---|
Enter | Send message |
Escape | Cancel current generation |
Ctrl+C | Exit Claude Code |
Tab | Accept suggestion |
Up Arrow | Previous message |
Next up: Learn about CLAUDE.md — the file that teaches Claude about your project.