DEV Community

Cover image for Claude Code Commands Beginner’s Handbook
preeti deshmukh
preeti deshmukh

Posted on

Claude Code Commands Beginner’s Handbook

A practical guide to every CLI command, flag, and in-session slash command you need to get productive with Claude Code fast.


Think of this as the Claude Code command cheat sheet your future self wishes your past self had found sooner. Every command Claude Code understands, laid out in one place, with real examples and plain-English explanations of what actually happens when you run them. No detours, no rabbit holes, no Vim. Bookmark it, print it, tape it to your monitor — your future self (the one who finishes work before dinner) will thank you.

⚠️ Full disclosure: I didn't write this cheat sheet—Claude did. 🤖 I'm just the copy-paste department. 📋 If you trust Claude, we're good. 😎


Table of contents


Getting started in 60 seconds

# 1. Install
npm install -g @anthropic-ai/claude-code

# 2. Log in
claude auth login

# 3. Open your first session
claude
Enter fullscreen mode Exit fullscreen mode

Inside a session, type /help to see all available commands at any time.


Part 1 — Session commands

These are the commands you run from your terminal (shell) to start, manage, and control Claude Code sessions.

Command Syntax Example Expected output
Start interactive session claude $ claude Claude Code prompt appears, ready for input
Start with initial message claude "query" $ claude "explain this project" Session opens and Claude immediately responds
One-shot mode (no interaction) claude -p "query" $ claude -p "what does this function do" Answer printed, Claude exits
Pipe file contents to Claude `cat file \ claude -p "query"` `$ cat logs.txt \
Continue last conversation {% raw %}claude -c $ claude -c Previous session reloaded with full history
Resume a named session claude -r "name" "query" $ claude -r "auth-refactor" "finish the PR" Named session reopens with your message
Log in to your account claude auth login $ claude auth login Browser opens for auth, then "Logged in" confirmation
Log out claude auth logout $ claude auth logout "Logged out" confirmation
Check login status claude auth status $ claude auth status JSON showing login state
Update Claude Code claude update $ claude update Latest version downloaded and installed
Install a specific version claude install [version] $ claude install stable Native binary installed
View background agents claude agents $ claude agents --json Live list of sessions as JSON
Stop a background session claude stop <id> $ claude stop 7c5dcf5d Session stopped
View background session logs claude logs <id> $ claude logs 7c5dcf5d Recent output from that session
Configure MCP servers claude mcp $ claude mcp MCP configuration menu
Delete project data claude project purge [path] $ claude project purge ~/work/repo --dry-run Preview of what would be deleted
Generate a CI/CD token claude setup-token $ claude setup-token Long-lived token printed (not saved)

Part 2 — CLI flags

Flags modify how a command behaves. Append them to any claude command.

Flag What it does Example Expected output
-p / --print Non-interactive mode — Claude answers and exits. Use in scripts. claude -p "explain main.py" Answer printed, process exits with code 0
-c / --continue Load the most recent conversation in the current folder. claude --continue Previous session loaded
-r / --resume Resume a session by name or ID. No value = interactive picker. claude -r "auth-refactor" Named session reopens
-n / --name Give your session a friendly name for later resumption. claude -n "my-feature-work" Session name shown in title and session list
-v / --version Print the installed version number. claude -v Version string e.g. 2.1.x
--model Use a specific model this session (aliases: sonnet, opus). claude --model sonnet Session runs on the specified model
--effort Set effort level: low, medium, high, xhigh, max. claude --effort high Session uses the chosen effort level
--verbose Show all intermediate steps and tool calls. claude --verbose Full turn-by-turn output including tool use
--output-format Set output format for -p mode: text, json, stream-json. claude -p "query" --output-format json Structured JSON with cost, duration, response
--max-turns Limit agentic turns in -p mode. Exits with error if exceeded. claude -p --max-turns 3 "fix tests" Claude runs at most 3 turns then stops
--permission-mode How Claude handles permissions: default, acceptEdits, plan, auto, bypassPermissions. claude --permission-mode plan Claude proposes changes before making them
--add-dir Grant Claude read/write access to extra directories. claude --add-dir ../lib ../apps Files in those paths become accessible
--tools Restrict which built-in tools Claude can use. claude --tools "Read" Claude can only read files, not edit or run commands
--system-prompt Replace Claude's default system prompt with your own. claude --system-prompt "You are a Python expert" Claude follows your custom instructions
--append-system-prompt Add extra instructions on top of Claude's default prompt. claude --append-system-prompt "Always use TypeScript" Claude follows defaults + your extra rule
--bg Start session in the background and return to terminal immediately. claude --bg "investigate flaky test" Session ID and control commands printed
--mcp-config Load MCP servers from a JSON config file. claude --mcp-config ./mcp.json MCP servers from that file available in session
--debug Enable debug logging. Optionally filter: "api,mcp". claude --debug "api,mcp" Detailed debug logs printed
--bare Minimal startup — skips hooks, skills, plugins. Faster for scripts. claude --bare -p "query" Fast response with basic tools only
--max-budget-usd Cap API spend for one -p run. claude -p --max-budget-usd 5.00 "refactor auth" Claude stops when $5.00 is reached
--chrome Enable Chrome browser integration for web automation. claude --chrome Claude can now control a browser
--rc / --remote-control Start a session you can also control from the Claude app. claude --rc "My Project" Session appears in Claude app as controllable

Part 3 — In-session slash commands

Once you are inside a Claude Code session, these / commands control the session itself.

Command What it does Example Expected output
/help Show all available slash commands. /help Full list of commands with descriptions
/clear Wipe conversation context entirely. Use between unrelated tasks. /clear Context reset, fresh session starts
/compact [instructions] Compress history to free context space. Optionally focus the summary. /compact Focus on the API changes History summarized with your focus applied
`/resume [name\ id]` Resume a previous session (interactive picker or by name). /resume auth-refactor
/add-dir <path> Grant access to an extra directory mid-session. /add-dir ../shared-lib Files in that path become accessible
/rename <name> Rename the current session. /rename payment-refactor Name updated immediately
/rewind Go back to a previous message checkpoint. /rewind Interactive checkpoint picker appears
/debug Run Claude's built-in debug skill on your current code. /debug Claude investigates errors systematically
/code-review Run a structured code review on current changes. /code-review Findings listed by severity
/simplify Simplify the current code for readability. /simplify Simplified version suggested
/batch Process a task across multiple files at once. /batch Claude iterates over files and summarizes results

Part 4 — In-prompt special syntax

You can use these special characters inside any prompt while in a session.

Syntax What it does Example Expected output
@./path/to/file Reference a specific file. Claude reads it and applies your instruction. Review @./src/auth.ts for bugs Claude reads the file and gives a detailed review
!shell-command Run a shell command from inside Claude Code without leaving the session. !npm test Command runs; output shown inline

Beginner cheat sheet

# Start a session
claude

# Ask a quick question without opening a session
claude -p "explain what a closure is in JavaScript"

# Pipe a file and ask about it
cat server.js | claude -p "find any security issues"

# Come back to your last conversation
claude -c

# Name a session so you can find it later
claude -n "feature-login"

# Resume it later
claude -r "feature-login"

# Inside a session — reference a file
> Review @./src/api.ts and suggest improvements

# Inside a session — run a shell command
> !git status

# Inside a session — compact when context gets long
> /compact
Enter fullscreen mode Exit fullscreen mode

Source: Claude Code official documentation — June 2026

Top comments (0)