Claude Code Cheat Sheet: Complete Keyboard Shortcuts & Commands

WRITTEN BY
Alex. A Personally Tested
Head of AI Architecture & Automation @ Lexmation

Alex builds custom AI agents, automated n8n pipelines, and secure cloud infrastructure, testing every framework across real-world production environments.

Alex. A
Lexmation Core Reviewed by Lexmation Engineering Core
Last Updated: October 24, 2026

Key Insight: Master Claude Code CLI with this complete cheat sheet: keyboard shortcuts, readline navigation, slash commands, CLI flags, and Vim mode.

Key Takeaways for Engineers

Terminal-first agentic coding CLI tools like Claude Code from Anthropic represent a significant productivity leap for modern software engineers, DevOps teams, and automation architects. By operating directly inside your terminal, Claude Code eliminates the constant context-switching between IDE windows, browser tabs, and shell environments.

This cheat sheet compiles every keyboard shortcut, readline navigation trick, multiline technique, slash command, and runtime CLI flag into a single reference guide designed for speed and daily terminal productivity.

Part 1: Interactive Mode Keyboard Shortcuts

Mastering terminal navigation inside an active Claude Code session enables rapid iteration without touching your mouse.

Session and Navigation Controls

  • Ctrl + C: Cancels current execution, aborts long-running agent tool calls, or interrupts code generation safely without closing the session.
  • Ctrl + D: Closes session cleanly if input buffer is empty (standard EOF signal).
  • Ctrl + L: Clears the terminal screen while preserving the underlying conversation context and agent memory.
  • Up / Down Arrows: Cycles backward and forward through prompt command history.
  • Tab: Triggers contextual auto-completion for slash commands, local file paths, and git branch targets.

Readline-Style Text Editing Shortcuts

  • Ctrl + A: Jump cursor instantly to the beginning of the line.
  • Ctrl + E: Jump cursor directly to the end of the line.
  • Ctrl + U: Clear the entire line before the current cursor position.
  • Ctrl + K: Kill/delete all text from the cursor to the end of the line.
  • Ctrl + W: Delete the preceding word behind the cursor.
  • Alt + B (or Option + B): Move cursor backward by one full word.
  • Alt + F (or Option + F): Move cursor forward by one full word.

Multiline Input Methods

  • Shift + Enter: Inserts a newline without submitting the prompt (supported in modern terminal emulators).
  • Ctrl + J: Standard terminal newline insertion fallback when Shift+Enter sends a carriage return.
  • """ (Triple Quotes): Enclose code blocks, stack traces, or configuration files in triple quotes to enter multi-line prompt capture mode safely.
  • Backslash (\) at line end: Escapes newline and continues prompt entry on the subsequent line.

Quick Input Prefixes

  • !<command>: Direct bash command execution bypass (e.g. !git status or !npm test) executed locally without agent LLM reasoning overhead.
  • @<path>: Explicitly attaches file contents or directory context into the immediate reasoning window.
  • /<command>: Invokes specialized Claude Code runtime slash commands.

Part 2: Transcript Viewer and History Search

Navigating historical execution logs and multi-step agent tool executions requires dedicated overlay controls.

/btw Side Question Overlay

  • /btw <question>: Opens a lightweight overlay to ask clarifying technical questions without polluting or appending tokens to your primary conversation context window.
  • Esc: Closes the /btw overlay instantly and returns focus to your active prompt buffer.

History Search (Ctrl + R Mode)

  • Ctrl + R: Activates reverse incremental search across historical prompts and submitted instructions.
  • Enter: Selects the highlighted historical query and loads it into your active input line.
  • Ctrl + G (or Esc): Cancels search and restores original input line.

Part 3: Vim Mode Navigation

Engineers accustomed to modal text editing can enable Vim keybindings within Claude Code settings for seamless buffer manipulation.

Mode Switching

  • Esc: Switch from INSERT mode to NORMAL command mode.
  • i: Enter INSERT mode before the cursor position.
  • a: Enter INSERT mode after the cursor position.
  • A: Jump to the end of the line and enter INSERT mode.
  • I: Jump to the start of the first non-blank character and enter INSERT mode.

Navigation & Editing in NORMAL Mode

  • h / j / k / l: Standard directional cursor movement (left, down, up, right).
  • w / b / e: Jump forward by word, backward by word, or to word ending.
  • 0 / $: Jump to absolute beginning or end of line.
  • dd: Delete entire current line and save to register.
  • dw: Delete word from cursor position forward.
  • cw: Change word (deletes word and enters INSERT mode immediately).
  • u: Undo previous in-buffer text modification.
  • p: Paste register contents directly after cursor.

Part 4: Complete Slash Commands Reference

Slash commands control session context, invoke background workers, and govern agent capabilities.

Session & Context Management

  • /compact: Summarizes and prunes conversation history to reclaim context window space while preserving key architectural decisions.
  • /clear: Completely wipes conversation history and starts a fresh context window.
  • /cost: Displays detailed breakdown of input tokens, output tokens, cache hits, and estimated session expenses.
  • /context: Visualizes loaded files, memory files, system instructions, and token budget consumption.

Planning & Execution Modes

  • /plan: Toggles step-by-step architectural planning mode before executing file modifications or bash operations.
  • /review: Performs automated code review against git diffs, inspecting security vulnerabilities, code smells, and edge cases.
  • /init: Initializes a project-level CLAUDE.md memory file with codebase guidelines and test instructions.
  • /bug: Packages active diagnostic logs, reproduction steps, and system info to report tool anomalies.

Parallel Agents and Tooling

  • /agents: Lists, inspects, and manages concurrent background subagent workers.
  • /mcp: Manages Model Context Protocol (MCP) server connections, inspects available tools, and tests protocol endpoints.
  • /help: Displays interactive documentation for all available CLI commands and aliases.
  • /logout: Invalidates current credentials and clears stored Anthropic authentication tokens.

Part 5: Core CLI Flags Reference

Launch flags configure execution environments, model tier selection, and automation parameters directly from your shell.

Execution and Model Selection Flags

  • claude: Launches Claude Code interactive CLI in the current directory.
  • claude -p "<prompt>": Non-interactive batch mode; processes prompt, prints response to stdout, and exits (ideal for CI/CD pipelines).
  • claude --model <model-name>: Explicitly overrides default model selection (e.g., claude-3-7-sonnet-20250219).
  • claude --dangerously-skip-permissions: Runs agent without prompting for bash execution or file modification approvals (use exclusively in isolated containers).

Session, Memory & Debugging Flags

  • claude --continue: Resumes the most recent conversation session in the active repository workspace.
  • claude --system-prompt <file>: Appends custom system prompt constraints or architectural compliance guardrails.
  • claude --verbose: Enables raw HTTP trace logging, MCP transport messages, and internal agent step telemetry.
  • claude --add-dir <path>: Exposes additional directories outside the current git root into the agent's safe read/write perimeter.

Enterprise Best Practices for Agentic CLI Tools

For engineering organizations deploying terminal-based coding agents at scale:

  • Define CLAUDE.md Standards: Maintain an authoritative CLAUDE.md in repository roots detailing package build commands, linter conventions, branch naming schemas, and architectural red lines.
  • Enforce Permission Boundaries: Avoid using automated permission bypass flags on host workstations containing production credentials. Run unconstrained agents inside Docker sandboxes or ephemeral VM runners.
  • Audit Token Economics: Regularly execute /cost and employ prompt caching mechanisms to optimize API token budgets across large development teams.

Frequently Asked Questions

Q: What is the difference between interactive mode and non-interactive (-p) mode in Claude Code?
A: Interactive mode opens a stateful conversational terminal shell allowing iterative back-and-forth debugging and manual tool call approvals. Non-interactive mode (-p) executes a single prompt to completion, writes results or file modifications, and exits immediately, making it ideal for CI/CD automation and shell scripts.
Q: How does the /compact command prevent context window degradation?
A: The /compact command executes an LLM-assisted summarization pass over your active conversation transcript. It strips redundant tool call outputs and repetitive terminal logs while preserving critical decisions, file paths, and current task state, freeing up significant token capacity.
Q: Can Claude Code run custom terminal commands without asking for permission every time?
A: Yes. Individual commands or paths can be permanently approved within your local configuration settings, or you can launch Claude Code with the --dangerously-skip-permissions flag in containerized or sandboxed environments where automated execution is safe.