Cheat Sheet
Reference
beginner
Starting Claude Code
| Command | Description |
|---|---|
claude |
Interactive mode in current directory |
claude "prompt" |
One-shot mode (answer and exit) |
claude --resume |
Resume last conversation |
claude --model opus |
Use a specific model |
claude --headless -p "prompt" |
Non-interactive for scripting |
Session Commands (Slash Commands)
| Command | Description |
|---|---|
/help |
Show all available commands |
/clear |
Wipe conversation, start fresh |
/compact |
Summarise conversation to save context |
/cost |
Show token usage for this session |
/quit |
Exit Claude Code |
/model |
Switch the AI model mid-session |
/permissions |
View current permission settings |
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Enter |
Send message |
Shift+Enter |
New line (multi-line input) |
Ctrl+C |
Cancel current generation |
Ctrl+D |
Exit Claude Code |
Esc |
Cancel current input |
Up Arrow |
Recall previous message |
Tab |
Accept autocomplete suggestion |
Permission Responses
When Claude asks for approval:
| Response | Meaning |
|---|---|
y |
Yes, approve this action |
n |
No, reject and suggest alternative |
a |
Always allow this type of action |
| Custom text | Provide feedback/modification |
Command-Line Flags
| Flag | Description |
|---|---|
-p "prompt" |
Pass prompt directly (for scripting) |
--headless |
No interactive UI (for automation) |
--model [name] |
Choose model (opus, sonnet, haiku) |
--output-format [type] |
Output as text, json, or markdown |
--resume |
Resume last conversation |
--version |
Show version |
--dangerously-skip-permissions |
Skip all approval prompts |
File Operations Quick Reference
| Task | Prompt Pattern |
|---|---|
| Create a file | "Create [path] that [description]" |
| Edit a file | "In [path], change [what] to [what]" |
| Delete a file | "Delete [path]" |
| Rename a file | "Rename [old] to [new]" |
| Move a file | "Move [path] to [new-location]" |
| Read a file | "Show me [path]" or "Read [path]" |
| Find files | "Find all files that [criteria]" |
| Search code | "Search for [pattern] in [scope]" |
Git Operations Quick Reference
| Task | Prompt Pattern |
|---|---|
| Status | "What's the git status?" |
| Commit | "Commit with an appropriate message" |
| Diff | "Show me what changed" |
| Branch | "Create a branch for [feature]" |
| PR | "Create a PR for this branch" |
| Merge conflicts | "Help me resolve the merge conflicts" |
| Log | "Show recent commit history" |
| Stash | "Stash my current changes" |
Common Workflow Patterns
Start a new feature
> I want to add [feature]. Let's plan first:
> 1. What files need to change?
> 2. What's the approach?
> Then implement it step by step.
Debug an issue
> I'm getting this error: [paste error]
> It happens when [trigger].
> The relevant code is in [file/area].
Refactor code
> Refactor [component/function] to [improvement].
> Keep the same external interface.
> Make sure tests still pass.
Code review
> Review the changes on this branch vs main.
> Focus on [bugs/security/performance/style].
Generate tests
> Write tests for [file/function].
> Cover: happy path, error cases, edge cases.
> Use [testing framework].
Configuration File Locations
| File | Location | Purpose |
|---|---|---|
| CLAUDE.md | Project root | Project instructions |
| .claude/settings.json | Project | Shared team settings |
| .claude/settings.local.json | Project | Personal settings (gitignored) |
| .claude/commands/*.md | Project | Custom slash commands |
| ~/.claude/settings.json | Home | Global user settings |
| ~/CLAUDE.md | Home | Global instructions |
Context Management
| Situation | Action |
|---|---|
| Long session, quality dropping | /compact |
| Starting unrelated task | /clear or new session |
| Need to reference earlier work | --resume |
| Large codebase | Focus: "I'm working in src/api/" |
| Context overwhelm | Break into smaller tasks |
Cost Awareness
| Action | Approximate Tokens |
|---|---|
| Simple question | 1-5K |
| File creation | 5-15K |
| Multi-file edit | 10-50K |
| Full feature | 50-200K |
| Long debugging session | 100-500K |
Use /cost to check actual usage during a session.