Complete reference for Claude Code commands, keyboard shortcuts, and CLI options. Quick lookup for all Claude Code functionality.
Claude Code CLI Commands Cheat Sheet
Quick reference for all Claude Code commands, options, and keyboard shortcuts.
Starting Claude Code
Basic Start
claude
Starts Claude Code in the current directory.
With Options
claude --help # Show all options
claude --version # Show version
claude -p "your prompt" # Start with a prompt
claude --model opus # Use specific model
claude --continue # Continue last session
In-Session Commands
General Commands
| Command |
Description |
/help |
Show all available commands |
/quit or Ctrl+C |
Exit Claude Code |
/clear |
Clear conversation history |
/compact |
Summarize conversation, free context |
/cost |
Show token usage for session |
/model |
Show or change current model |
Context Commands
| Command |
Description |
/add <file> |
Add file to context |
/add <folder> |
Add folder to context |
/remove <file> |
Remove file from context |
/files |
List files in context |
/context |
Show context summary |
Mode Commands
| Command |
Description |
/chat |
Chat mode (no file edits) |
/edit |
Edit mode (can modify files) |
/agent |
Agent mode (autonomous) |
Git Commands
| Command |
Description |
/git status |
Show git status |
/git diff |
Show current diff |
/git commit |
Commit staged changes |
Memory Commands
| Command |
Description |
/memory |
Show stored memories |
/memory add <text> |
Add a memory |
/memory clear |
Clear all memories |
Keyboard Shortcuts
Navigation
| Shortcut |
Action |
↑ / ↓ |
Navigate input history |
Ctrl+R |
Search input history |
Ctrl+A |
Go to beginning of line |
Ctrl+E |
Go to end of line |
Ctrl+U |
Clear line |
Control
| Shortcut |
Action |
Enter |
Send message |
Shift+Enter |
New line (multi-line input) |
Ctrl+C |
Cancel current operation |
Ctrl+D |
Exit Claude Code |
Tab |
Autocomplete file paths |
During Output
| Shortcut |
Action |
Ctrl+C |
Stop generation |
Space |
Pause/resume scrolling |
Response Actions
When Claude Code proposes changes:
| Key |
Action |
y |
Accept changes |
n |
Reject changes |
e |
Edit before applying |
? |
Get more explanation |
CLI Flags
Session Options
--continue, -c # Continue previous session
--new, -n # Start new session
--print, -p # Print mode (output only, no interaction)
Model Options
--model <name> # Choose model (sonnet, opus, haiku)
--max-tokens <n> # Set max output tokens
Output Options
--verbose, -v # Verbose output
--quiet, -q # Minimal output
--json # JSON output format
Configuration
--config <file> # Use specific config file
--no-config # Ignore config files
Configuration File
Located at .claude/config.json:
{
"model": "sonnet",
"instructions": "Project-specific instructions here",
"hooks": {
"post-edit": "npm run lint:fix"
},
"ignore": [
"node_modules",
"dist",
".git"
]
}
Ignore File
Create .claudeignore:
# Ignore patterns (like .gitignore)
node_modules/
dist/
build/
*.log
.env
secrets.json
Environment Variables
| Variable |
Purpose |
ANTHROPIC_API_KEY |
API key (if not using Claude Pro) |
CLAUDE_CODE_CONFIG |
Config file path |
CLAUDE_CODE_MODEL |
Default model |
Prompt Patterns
File Reference
Look at @filename.ts and explain the function
Multi-file
Compare @file1.ts and @file2.ts
Folder Reference
Analyze all files in @src/components/
Quick Recipes
Start Fresh Project
mkdir new-project
cd new-project
git init
claude
> Initialize a Next.js project with TypeScript
Resume Previous Work
claude --continue
Quick Question
claude -p "How do I center a div with Tailwind?"
Review Code
claude -p "Review @src/api/routes.ts for security issues"
Generate Tests
claude -p "Write tests for @src/utils/helpers.ts"
Output Modes
Interactive (Default)
claude
Full interactive session with prompts and responses.
Print Mode
claude -p "Explain this code" --print @file.ts
Output only, no interaction.
JSON Mode
claude -p "List all functions in this file" --json @file.ts
Structured JSON output.
Troubleshooting Commands
Check Version
claude --version
Reset Configuration
rm -rf ~/.claude
claude # Will re-authenticate
View Logs
cat ~/.claude/logs/latest.log
Clear Cache
claude /clear
Common Workflows
Feature Development
/edit
> Add user authentication with these requirements...
[review diff]
y
> Add tests for the auth module
[review diff]
y
/git commit -m "Add user authentication"
Debugging
/chat
> This error occurs: [paste error]
> The relevant file is @src/api/handler.ts
[get explanation]
/edit
> Fix the issue
[review diff]
y
Code Review
/chat
> Review the changes in git diff for:
> - Security issues
> - Performance concerns
> - Code style
/git diff
Need Help?
/help
Shows all available commands in your current version.
Want to master Claude Code? Cedar Operations offers training and support for AI development tools. Book a consultation →
Related reading: