Quick Reference

Claude Code Cheat Sheet

Essential commands, shortcuts, and patterns for productive Claude Code sessions.

Tip: Print this page (Ctrl/Cmd+P) for a handy desk reference

Slash Commands

/help

Show help and available commands

/clear

Clear conversation history and start fresh

/compact

Compress conversation to save context space

/cost

Show token usage and cost for current session

/doctor

Check Claude Code installation and configuration

/init

Initialize AGENTS.md in current project

/bug

Report a bug to Anthropic

/config

Open or edit configuration

/login

Sign in to your Anthropic account

/logout

Sign out of your account

/memory

Edit persistent memory across sessions

/model

Switch between Claude models

/permissions

View or modify file permissions

/review

Request a code review of recent changes

/status

Show current session status

/vim

Toggle vim keybindings

Keyboard Shortcuts

Ctrl+C

Cancel current operation or clear input

Ctrl+D

Exit Claude Code

Ctrl+L

Clear the terminal screen

Ctrl+R

Search command history

Up/Down

Navigate through command history

Tab

Autocomplete file paths

Esc

Cancel current input (vim mode)

CLI Arguments

claude

Start interactive session

e.g., claude

claude "prompt"

Run single prompt and exit

e.g., claude "explain this file"

claude -c

Continue previous conversation

e.g., claude -c "now add tests"

claude -p

Use specific project

e.g., claude -p /path/to/project

claude --model

Use specific model

e.g., claude --model claude-3-opus

claude --version

Show version number

claude --help

Show CLI help

echo "x" | claude

Pipe input to Claude

e.g., cat error.log | claude "explain"

File Operations

Read [file]

Read file contents

e.g., Read src/index.ts

Read [file:line]

Read from specific line

e.g., Read src/index.ts:50

Write [file]

Create or overwrite file

Edit [file]

Make targeted edits to file

@[file]

Include file in context

e.g., @package.json

@[folder/]

Include folder in context

e.g., @src/components/

Common Patterns

Explain this codebase

Get an overview of the project structure and purpose

Find where X is defined

Locate function, variable, or type definition

e.g., Find where handleSubmit is defined

Add [feature] to [file]

Add new functionality

e.g., Add form validation to ContactForm.tsx

Fix the error in [file]

Debug and fix an issue

e.g., Fix the TypeScript error in api/users.ts

Refactor [X] to [Y]

Transform code structure

e.g., Refactor useAuth to use React Query

Write tests for [file]

Generate test coverage

e.g., Write tests for utils/formatDate.ts

Review [file] for issues

Get code review feedback

e.g., Review api/checkout.ts for security issues

Configuration Files

AGENTS.md

Project instructions for Claude (auto-loaded)

.claudeignore

Files to exclude from context (like .gitignore)

.claude/settings.json

Project-specific settings

~/.claude/settings.json

Global user settings

~/.claude/memory.md

Persistent memory across sessions

Context Management

/clear

Reset context completely

/compact

Summarize and compress context

Forget about X

Remove specific topic from context

Focus on X only

Narrow context to specific area

Summarize our conversation

Get compressed summary

Git Integration

What changed?

Show git diff summary

Commit these changes

Create commit with AI message

Create a PR for this

Generate pull request

Review the last commit

Analyze recent changes

Undo the last change

Revert recent modifications

Pro Tips

  • Start messages with verbs: "Fix", "Add", "Refactor", "Explain"
  • Be specific about files: "@src/components/Button.tsx" not "the button"
  • Include context: "Following our existing patterns in auth.ts"
  • Ask for confirmation: "Show me the plan before making changes"
  • Chain tasks: "First lint, then test, then commit if passing"
  • Reference examples: "Like we did in UserProfile.tsx"

AGENTS.md Starter Template

# Project: [Your Project Name]

## Overview
[Brief description of what the project does]

## Architecture
- `/src/app` - Next.js pages and routes
- `/src/components` - React components
- `/src/lib` - Utilities and helpers
- `/src/services` - Business logic

## Conventions
- TypeScript strict mode
- Use interfaces for object shapes
- Named exports (not default)
- Tailwind CSS for styling

## DO NOT
- Never commit secrets or API keys
- Never use `any` type
- Never skip error handling

## Common Tasks
### Adding a new page
1. Create file in /src/app/[route]/page.tsx
2. Add to navigation if needed
3. Follow existing page patterns