Skip to main content

Claude Code CLI Cheatsheet

Claude Code is Anthropic's AI coding assistant CLI tool that integrates into terminal workflows, supporting code generation, editing, review, debugging, and more. This cheatsheet covers common commands and configurations from basic startup to advanced extensions.

Updated: 2026-07-17·31 commands

Overview

Claude Code is Anthropic's official AI coding assistant CLI, deeply integrated into terminal development workflows. It supports interactive sessions, code generation and editing, file operations, Git integration, and extensibility through the MCP protocol.

Quick Start

``bash # Start an interactive session claude

# One-shot query claude -p "Explain this codebase"

# Start with a specific model claude --model claude-sonnet-4-20250514 `

Refer to the command table below for detailed usage.

Basic Commands

Use the claude command to start an interactive session, or -p for one-shot queries. --resume restores the previous session context. --print outputs in plain text (non-interactive).

Session Commands

Manage conversations with / prefixed commands: /help for assistance, /clear to clear the screen, /compact to compress context and save tokens, /cost to view session costs, /doctor to diagnose issues.

Code Operations

Use /bug to analyze code bugs, /review to review code changes, /add and /drop to manage context files, /read and /write for file I/O, /edit for code editing, /diff to view changes, /undo to revert modifications.

Configuration

Project-level configuration is defined in CLAUDE.md. User-level settings go in .claude/settings.json. Hooks provide custom script triggers. MCP tools and Extensions offer extensible integration capabilities.

Advanced

Advanced features include claude update for version updates, claude --verbose for detailed output, claude --version to check version, claude ssh for remote SSH mode, and claude mcp` for MCP tool management.

Basic Usage(5)

CommandLevel
claude
Start an interactive Claude Code session
Basic
claude -p
One-shot prompt without interactive session
Basic
claude --resume
Resume context from the last interactive session
Basic
claude --print
Output in plain text format, suitable for piping
Basic
claude --model
Specify which Claude model to use
Intermediate

Chat Commands(5)

CommandLevel
/help
Show help for all available commands
Basic
/clear
Clear the current session terminal display
Basic
/compact
Compact session context to save tokens
Intermediate
/cost
Show current session token usage and cost estimate
Basic
/doctor
Diagnose Claude Code environment issues
Intermediate

Code Operations(9)

CommandLevel
/bug
Analyze specified files for potential bugs
Intermediate
/review
Review code changes or entire files
Intermediate
/add
Add files to the session context
Basic
/drop
Remove files from the session context
Basic
/read
Read file contents into the session context
Basic
/write
Write generated content to a file
Basic
/edit
Edit code or text content
Intermediate
/diff
View diff of changes in current context
Basic
/undo
Undo the last code modification
Basic

Configuration(7)

CommandLevel
CLAUDE.md
Project-level instruction file (auto-loaded into context)
Intermediate
.claude/settings.json
User-level configuration file (JSON format)
Intermediate
claude hooks
Configure custom hook scripts (pre/post actions)
Expert
MCP tools
Integrate external tools and data sources via MCP protocol
Expert
claude extensions
Manage Claude Code extensions
Expert
CLAUDE_PROJECT.md
Shared project-level instruction file across projects
Intermediate
claude config
View or modify Claude Code configuration
Intermediate

Advanced(5)

CommandLevel
claude update
Update Claude Code to the latest version
Basic
claude --verbose
Enable verbose logging output
Intermediate
claude --version
Show Claude Code version information
Basic
claude ssh
Connect to a remote Claude Code session via SSH
Expert
claude mcp
Manage MCP tools (add/remove/list)
Expert

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-17.