title: "Claude Code Cheatsheet" last_updated: 2026-03-21 tested_with: claude-code: "1.0.x" status: proven difficulty: beginner

Claude Code Cheatsheet

Installation

npm install -g @anthropic-ai/claude-code

Essential Commands

CommandDescription
claudeStart interactive session in current directory
claude "prompt"Start session with an initial prompt
claude --continueResume the most recent conversation
claude --resumePick a previous conversation to resume
claude -p "prompt"Headless mode -- run a single prompt, print result, exit
claude -p "prompt" --output-file out.txtHeadless mode with output saved to file
claude configOpen configuration settings

Slash Commands

CommandDescription
/helpShow all available commands
/clearClear conversation history and start fresh
/compactSummarize conversation to reclaim context window
/modelSwitch to a different model mid-session
/statusShow current session info (model, project, etc.)
/costDisplay token usage and cost for the current session

Mode Switching

ShortcutDescription
Shift+TabToggle between plan mode and code mode

Plan mode lets the agent reason and propose a plan without making changes. Code mode (default) allows the agent to read and write files.

Key Config Files

FilePurpose
CLAUDE.mdProject memory -- conventions, build commands, architecture notes. Loaded automatically at session start.
~/.claude/CLAUDE.mdUser-level memory applied to all projects.
.claude/settings.jsonProject-level settings (allowed/denied tools, permissions).
~/.claude/settings.jsonUser-level settings.
.claude/commands/*.mdCustom slash commands scoped to the project.
~/.claude/commands/*.mdCustom slash commands available globally.

Permission Model

Claude Code asks for approval before performing potentially risky actions.

CategoryExamplesDefault
ReadReading files, listing directoriesAllowed
WriteCreating/editing filesRequires approval
ShellRunning shell commandsRequires approval

Grant standing permissions via .claude/settings.json:

{
  "permissions": {
    "allow": [
      "Edit",
      "Bash(npm test)",
      "Bash(npm run build)"
    ],
    "deny": [
      "Bash(rm -rf *)"
    ]
  }
}

Keyboard Shortcuts

ShortcutAction
EnterSend message
Shift+TabToggle plan/code mode
EscapeCancel current generation
Ctrl+CCancel or exit
Up arrowCycle through previous prompts

Common Flags

FlagDescription
-p, --printHeadless mode (non-interactive)
--continueResume last conversation
--resumePick a conversation to resume
--output-fileWrite headless output to a file
--modelSpecify model to use
--verboseEnable verbose logging
--allowedToolsSpecify which tools the agent can use
--max-turnsLimit number of agentic turns in headless mode

Environment Variables

VariablePurpose
ANTHROPIC_API_KEYAPI key for direct Anthropic access
CLAUDE_CODE_USE_BEDROCKSet to 1 to use AWS Bedrock as provider
CLAUDE_CODE_USE_VERTEXSet to 1 to use Google Vertex AI as provider
AWS_REGIONAWS region for Bedrock
AWS_PROFILEAWS profile for Bedrock authentication
CLOUD_ML_REGIONGoogle Cloud region for Vertex AI
ANTHROPIC_MODELOverride the default model
DISABLE_PROMPT_CACHINGSet to 1 to disable prompt caching

Quick Tips

  • Run /compact after finishing each sub-task to keep context clean.
  • Put build/test commands in CLAUDE.md so the agent runs them correctly every time.
  • Use claude -p in scripts and CI pipelines for non-interactive use.
  • Start with strict permissions and relax them as you build trust.