Skip to main content
BlogResourcesPodcast
⌨️ Module 3 of 10 15 min read Phase 1: Foundations

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

CommandWhat It Does
/clearReset the conversation — start fresh with no prior context
/compactSummarize the conversation to free up context space
/costShow token usage and estimated cost for this session
/resumePick up your most recent conversation where you left off
/doctorDiagnose common configuration and setup issues
/initGenerate a starter CLAUDE.md file for your project
/modelSwitch to a different AI model mid-session
/memoryView and edit your saved memory files
/planEnter Plan Mode for read-only analysis
/helpShow 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.

Session workflow
# 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 output example
> /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

ShortcutWhat It Does
EscStop the current generation — Claude Code halts immediately
Esc + EscUndo — rewind the last action Claude Code took
Shift + Tab (twice)Toggle Plan Mode on and off
TabAccept autocomplete suggestion
Up arrowCycle through your previous prompts
?Show all available keyboard shortcuts
🧠
Your Undo Button

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.

Non-interactive examples
# 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"
⚠️
Common Mistakes

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

1

Ten slash commands give you full control: /clear, /compact, /cost, /resume, /doctor, /init, /model, /memory, /plan, /help

2

Esc + Esc is your undo button — it rewinds both the conversation and code changes

3

Non-interactive mode (claude -p) lets you pipe data and use Claude Code in scripts and automation

4

Effective conversations start broad, reference specific files, and break large tasks into smaller steps

📝 My Notes
← Installation The Memory System →