Claude Code CLI Commands: Complete Cheat Sheet (2026)
Every command, flag, and shortcut for Claude Code
Start Building with Hypereal
Access Kling, Flux, Sora, Veo & more through a single API. Free credits to start, scale to millions.
No credit card required • 100k+ developers • Enterprise ready
Claude Code CLI Commands: The Complete Cheat Sheet for 2026
Claude Code is Anthropic's official command-line interface for interacting with Claude directly in your terminal and codebase. Whether you are using it for code generation, debugging, refactoring, or full-feature development, knowing the CLI commands and flags is essential for maximizing your productivity.
This cheat sheet covers every major command, slash command, flag, and configuration option available in Claude Code as of early 2026.
Installation
Install Claude Code globally via npm:
npm install -g @anthropic-ai/claude-code
Verify the installation:
claude --version
Update to the latest version:
npm update -g @anthropic-ai/claude-code
Basic Usage
Launch Claude Code in interactive mode from any directory:
claude
Send a one-shot prompt without entering interactive mode:
claude "explain what this project does"
Pipe input into Claude Code:
cat error.log | claude "explain this error and suggest a fix"
Resume the most recent conversation:
claude --resume
CLI Flags Reference
| Flag | Short | Description |
|---|---|---|
--version |
-v |
Print the installed version |
--help |
-h |
Show help information |
--resume |
-r |
Resume the most recent conversation |
--continue |
-c |
Continue the last conversation |
--print |
-p |
Print mode: respond without interactive session |
--model |
-m |
Specify the model to use |
--output-format |
Set output format: text, json, stream-json |
|
--max-turns |
Limit the number of agentic turns | |
--system-prompt |
Provide a custom system prompt | |
--allowedTools |
Restrict available tools | |
--disallowedTools |
Exclude specific tools | |
--mcp-config |
Path to MCP servers config file | |
--permission-mode |
Set permission mode: default, plan, auto-edit |
|
--verbose |
Enable verbose logging output | |
--dangerously-skip-permissions |
Skip all permission prompts (use with caution) |
Examples of Flag Usage
Run Claude in print mode with a specific model:
claude -p -m claude-sonnet-4 "write a Python function to parse CSV files"
Limit agentic turns to prevent runaway operations:
claude --max-turns 5 "refactor the auth module"
Use JSON output for scripting:
claude -p --output-format json "list all TODO comments in this project"
Run with a custom system prompt:
claude --system-prompt "You are a security auditor. Review code for vulnerabilities." "audit src/"
Slash Commands (Interactive Mode)
Once inside an interactive Claude Code session, you can use slash commands:
| Command | Description |
|---|---|
/help |
Show available commands and usage information |
/clear |
Clear the conversation history and start fresh |
/compact |
Condense the conversation to save context window |
/config |
View or modify configuration settings |
/cost |
Display token usage and estimated cost for the session |
/doctor |
Run diagnostics to check for configuration issues |
/init |
Initialize a CLAUDE.md file in the current project |
/login |
Authenticate with your Anthropic account |
/logout |
Sign out of the current session |
/mcp |
View or manage MCP server connections |
/model |
Switch the active model mid-conversation |
/permissions |
View or modify tool permissions |
/review |
Request a code review of staged changes |
/status |
Show current session status and configuration |
/terminal-setup |
Configure terminal integration (keybindings, shell) |
/vim |
Toggle vim keybinding mode |
The CLAUDE.md File
Claude Code reads a CLAUDE.md file from your project root to understand project-specific context. Initialize one with:
claude /init
Or create it manually. A typical CLAUDE.md includes:
# Project Overview
This is a Next.js 14 application using TypeScript and Tailwind CSS.
# Tech Stack
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS + shadcn/ui
- Database: PostgreSQL via Prisma
- Auth: NextAuth.js v5
# Coding Conventions
- Use functional components with hooks
- Prefer named exports
- Use absolute imports with @/ prefix
- Write tests with Vitest
# File Structure
- src/app/ - Next.js app router pages
- src/components/ - Reusable UI components
- src/lib/ - Utility functions and shared logic
- prisma/ - Database schema and migrations
Configuration
View your current configuration:
claude /config
Configuration is stored in ~/.claude/ and includes:
| File | Purpose |
|---|---|
~/.claude/settings.json |
Global user settings |
~/.claude/mcp_servers.json |
MCP server configurations |
.claude/settings.json |
Project-level settings (commit to repo) |
CLAUDE.md |
Project context file |
~/.claude/CLAUDE.md |
Global context file (applies to all projects) |
Permission Modes
Claude Code has three permission modes that control how much autonomy the AI has:
| Mode | Behavior |
|---|---|
default |
Asks permission for file writes and command execution |
plan |
Read-only mode; Claude can analyze but not modify files |
auto-edit |
Automatically approves file edits, still asks for commands |
Set the mode when launching:
claude --permission-mode plan "analyze the architecture of this project"
Or configure specific tool permissions in .claude/settings.json:
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"Bash(npm test)",
"Bash(npm run lint)"
],
"deny": [
"Bash(rm *)",
"Bash(git push)"
]
}
}
MCP Server Management
List connected MCP servers:
claude /mcp
Add an MCP server via the config file at ~/.claude/mcp_servers.json:
{
"github": {
"command": "npx",
"args": ["@anthropic/mcp-server-github"],
"env": {
"GITHUB_TOKEN": "ghp_xxxxxxxxxxxx"
}
}
}
Useful Patterns and Workflows
Quick code review before committing:
git diff --staged | claude -p "review these changes for bugs and suggest improvements"
Generate commit messages:
git diff --staged | claude -p "write a concise commit message for these changes"
Explain an unfamiliar codebase:
claude "give me a high-level overview of this project's architecture"
Run tests and fix failures:
claude "run the test suite and fix any failing tests"
Batch processing with scripts:
for file in src/components/*.tsx; do
claude -p "add JSDoc comments to all exported functions" < "$file"
done
Keyboard Shortcuts (Interactive Mode)
| Shortcut | Action |
|---|---|
Ctrl+C |
Cancel the current generation |
Ctrl+D |
Exit Claude Code |
Up Arrow |
Scroll through prompt history |
Tab |
Accept autocomplete suggestions |
Esc |
Toggle between single-line and multi-line input |
Shift+Tab |
Reject the current suggestion |
Cost Monitoring
Track your spending during a session:
/cost
This displays:
- Total input tokens consumed
- Total output tokens generated
- Estimated cost in USD
- Cache hit rate (for repeated context)
Troubleshooting
Claude Code is not reading my CLAUDE.md:
Ensure the file is in the root of your working directory. Claude Code looks for CLAUDE.md in the current directory and parent directories.
MCP servers fail to connect: Check that the command specified in your MCP config is available on your PATH. Run the command manually to verify it works.
High token usage:
Use /compact regularly to compress conversation history. This reduces context window usage and costs.
Permission denied errors:
Check your .claude/settings.json permissions configuration. You may need to add specific tools to the allow list.
Conclusion
Claude Code is one of the most powerful AI coding assistants available in 2026, and mastering its CLI commands gives you full control over your AI-powered development workflow. Keep this cheat sheet bookmarked for quick reference.
If you are building applications that need AI media generation -- images, videos, audio, or talking avatars -- check out Hypereal AI. Hypereal offers a unified API with pay-as-you-go pricing, fast generation times, and access to the latest models like Flux, Kling, and Wan 2.2.
Related Articles
Start Building Today
Get 35 free credits on signup. No credit card required. Generate your first image in under 5 minutes.
