guide8 min read8d ago

Claude Code Keyboard Shortcuts & Commands Cheat Sheet (2026)

Every Claude Code keyboard shortcut, slash command, and CLI flag in one reference page. Copy this cheat sheet and keep it next to your terminal.

Claude Code Keyboard Shortcuts & Commands Cheat Sheet (2026)
claude codekeyboard shortcutscommandscheat sheetreferenceCLIdeveloper tools2026

Claude Code Keyboard Shortcuts & Commands Cheat Sheet (2026)

By Sarah Walker | March 26, 2026 | 10 min read


Bookmark this page. Every Claude Code keyboard shortcut, slash command, CLI flag, and configuration option in one place. Updated for March 2026. Print it, pin it, or keep it in a tab — you will reference it more than you expect.


Table of Contents

  1. Keyboard Shortcuts
  2. Slash Commands
  3. CLI Flags and Options
  4. Configuration Files
  5. Environment Variables
  6. Quick Reference Card
  7. Frequently Asked Questions

Keyboard Shortcuts {#keyboard-shortcuts}

These work inside an active Claude Code session in your terminal.

Essential Shortcuts (Memorize These)

ShortcutActionWhen to use
-------------------------------
Ctrl+CCancel current generationClaude is writing something you don't need — stop it immediately
Ctrl+DExit Claude CodeEnd your session gracefully
EscCancel current input / dismissYou started typing a prompt and want to clear it
EnterSend messageSubmit your prompt to Claude
Shift+EnterNew line in inputWrite multi-line prompts without sending
Up ArrowPrevious messageScroll through your prompt history
Down ArrowNext messageNavigate forward through prompt history
ShortcutActionNotes
-------------------------
TabAccept suggestion / autocompleteWhen Claude suggests a file path or command
Ctrl+LClear screenClears visual clutter but keeps session context
Ctrl+AMove cursor to start of lineStandard terminal behavior, works in Claude Code
Ctrl+EMove cursor to end of lineStandard terminal behavior
Ctrl+WDelete word before cursorQuick editing while typing prompts
Ctrl+UDelete entire lineClear your current input and start over

Tool Approval Shortcuts

When Claude wants to use a tool (read a file, run a command, etc.), you see an approval prompt:

ShortcutAction
------------------
y or EnterApprove the tool use
nReject the tool use
aApprove all tool uses for this session (trust mode)
eEdit the command before running it

Tip: If you trust Claude's actions for the current session and do not want to approve each one individually, press a once. This enables auto-approval for the remainder of the session. You can always press Ctrl+C to stop an action in progress.


Slash Commands {#slash-commands}

Type these at the Claude Code prompt (where you normally type your messages). They start with /.

Session Management

CommandWhat it does
----------------------
/helpShow all available commands and shortcuts
/clearClear conversation history and start fresh (resets context)
/compactCompress the conversation to save context space
/costShow how much the current session has cost in API credits
/exitExit Claude Code (same as Ctrl+D)

Configuration

CommandWhat it does
----------------------
/configView or modify Claude Code settings
/doctorRun diagnostics — checks your installation, API connection, and MCP servers
/modelView or change the AI model being used

Context Management

CommandWhat it does
----------------------
/add-dir Add a directory to Claude's context
/add-file Add a specific file to Claude's context

MCP and Skills

CommandWhat it does
----------------------
/mcpShow status of connected MCP servers
/skill Run a saved skill (custom command)

Detailed Breakdown of Key Commands

/clear

Resets the entire conversation. Claude forgets everything from the current session — files it read, decisions it made, context it gathered. Use this when you are switching to a completely different task and the old context is getting in the way.

When to use: You have been debugging one feature for 20 minutes and now want to work on something unrelated. The old context is using up your context window for no benefit.

When NOT to use: You are in the middle of a multi-step task. Clearing will erase Claude's understanding of what has been done.

/compact

Compresses the conversation to use less context space without losing the key information. Claude summarizes what has happened so far and continues from the summary. This extends your session when you are running into context limits.

When to use: Claude mentions it is running low on context, or you notice responses getting shorter and less detailed (a sign of context pressure).

Tip: Run /compact proactively after completing a major sub-task. This keeps the session lean.

/cost

Shows your spending for the current session. The output breaks down input tokens, output tokens, and total cost. Use this to monitor spending on expensive operations.

Example output:

Session cost: $0.42
  Input tokens: 145,230 ($0.22)
  Output tokens: 52,100 ($0.20)
  Cache reads: 89,000 (free)

/doctor

Runs a diagnostic check on your Claude Code installation. It verifies:

  • API connection is working
  • API key is valid
  • MCP servers are connected and responsive
  • Node.js version is compatible
  • Configuration files are valid

Run this first when something is not working. It catches most configuration issues.


CLI Flags and Options {#cli-flags}

These are used when launching Claude Code from your terminal (before the session starts).

Starting a Session

CommandWhat it does
----------------------
claudeStart an interactive session in the current directory
claude "your prompt"Run a single prompt and exit (non-interactive)
claude -p "your prompt"Print mode — output only, no interactive session
claude -cContinue your last conversation (resume where you left off)

Model Selection

FlagWhat it does
-------------------
--model Use a specific model (e.g., --model claude-sonnet-4-20250514)

Output Control

FlagWhat it does
-------------------
-p / --printPrint Claude's response to stdout (useful for piping to other commands)
--output-format jsonOutput in JSON format (for scripting)
--output-format textOutput in plain text (default)
--verboseShow detailed information about tool calls and reasoning

Session Options

FlagWhat it does
-------------------
-c / --continueResume the last conversation
--no-cacheDisable prompt caching (rarely needed)

Piping and Scripting

Claude Code supports Unix-style piping:

# Pipe file content to Claude
cat error.log | claude -p "What caused this error?"

# Pipe Claude's output to a file
claude -p "Write a bash script that backs up my database" > backup.sh

# Chain commands
git diff | claude -p "Summarize these changes for a commit message"

This is one of Claude Code's most powerful features for automation. You can integrate it into shell scripts, CI/CD pipelines, and makefiles.


Configuration Files {#config-files}

Claude Code reads configuration from several files. Here is where each one lives and what it controls.

CLAUDE.md (Project Instructions)

Location: ./CLAUDE.md (project root)

This file tells Claude how your project works. It is the most important configuration file — Claude reads it at the start of every session.

# My Project

## Tech Stack
- Next.js 15 with App Router
- TypeScript strict mode
- Tailwind CSS + shadcn/ui
- Drizzle ORM with Postgres

## Conventions
- Components in src/components/
- Server actions in src/actions/
- Always use TypeScript, never JavaScript

## Do NOT
- Use CSS modules
- Use default exports (except for pages)
- Use any type

.claude/mcp.json (MCP Server Configuration)

Location: ./.claude/mcp.json (project-level) or ~/.claude/mcp.json (global)

Configures MCP server connections:

{
  "mcpServers": {
    "server-name": {
      "command": "npx",
      "args": ["-y", "package-name"],
      "env": {
        "API_KEY": "your-key"
      }
    }
  }
}

.claude/settings.json (Project Settings)

Location: ./.claude/settings.json

Project-specific settings like allowed/denied tools:

{
  "permissions": {
    "allow": ["Read", "Write", "Edit", "Bash"],
    "deny": []
  }
}

~/.claude/settings.json (Global Settings)

Location: ~/.claude/settings.json

User-level settings that apply to all projects.


Environment Variables {#env-vars}

VariablePurposeDefault
----------------------------
ANTHROPIC_API_KEYYour API key for ClaudeRequired
CLAUDE_MODELDefault model to useclaude-sonnet-4-20250514
CLAUDE_CONFIG_DIROverride config directory location~/.claude

Set these in your shell profile (~/.bashrc, ~/.zshrc, or ~/.bash_profile):

export ANTHROPIC_API_KEY="sk-ant-your-key-here"

Quick Reference Card {#quick-reference}

Print this section and keep it next to your monitor.

KEYBOARD SHORTCUTS
  Ctrl+C .......... Cancel generation
  Ctrl+D .......... Exit session
  Esc ............. Cancel input
  Shift+Enter ..... New line (multi-line prompt)
  Up/Down ......... Prompt history
  Tab ............. Accept suggestion
  Ctrl+L .......... Clear screen

TOOL APPROVAL
  y / Enter ....... Approve
  n ............... Reject
  a ............... Approve all (session)
  e ............... Edit before running

SLASH COMMANDS
  /help ........... Show help
  /clear .......... Reset conversation
  /compact ........ Compress context
  /cost ........... Show session cost
  /doctor ......... Run diagnostics
  /config ......... View settings
  /model .......... Change model
  /mcp ............ MCP server status

CLI USAGE
  claude .......... Interactive session
  claude "msg" .... Single prompt
  claude -p "msg" . Print mode (pipe-friendly)
  claude -c ....... Continue last session

CONFIG FILES
  CLAUDE.md ............ Project instructions
  .claude/mcp.json ..... MCP servers
  .claude/settings.json  Project settings
  ~/.claude/mcp.json ... Global MCP servers

For a deeper dive into skills, MCP servers, and advanced Claude Code workflows, check the Skiln ecosystem directory — we catalog every skill, MCP server, and configuration pattern in the Claude Code ecosystem.


Frequently Asked Questions {#faq}

How do I check which version of Claude Code I am running?

Run claude --version in your terminal. This shows the installed version number. To update to the latest version, run npm update -g @anthropic-ai/claude-code. Claude Code updates frequently — checking weekly is a good habit.

Can I customize the keyboard shortcuts?

Not currently. Claude Code's keyboard shortcuts are built-in and cannot be remapped. The shortcuts follow standard terminal conventions (Ctrl+C, Ctrl+D, Ctrl+L), so they should feel familiar if you use other terminal tools. Feature requests for custom keybindings can be submitted through the Claude Code GitHub repository.

What does /compact actually do to my conversation?

The /compact command takes your entire conversation history and compresses it into a shorter summary. Claude identifies the key information — files read, decisions made, tasks completed — and replaces the full history with a condensed version. You lose the detailed back-and-forth but keep the important context. This frees up context space for new work.

How do I run Claude Code commands in a script or CI pipeline?

Use the -p (print) flag for non-interactive usage: claude -p "your prompt". This sends a single prompt, prints the response to stdout, and exits. You can pipe input in (cat file | claude -p "analyze this") and pipe output out (claude -p "write a test" > test.js). For JSON output, add --output-format json. This makes Claude Code scriptable for CI/CD pipelines, cron jobs, and shell scripts.

Is there a way to see what MCP tools are available in my current session?

Yes. Type /mcp in your Claude Code session to see all connected MCP servers and their status. Claude will also list available tools when you ask — try "what tools do you have access to?" For a full catalog of available MCP servers you can install, browse the Skiln MCP directory.


Frequently Asked Questions

How do I check which version of Claude Code I am running?
Run 'claude --version' in your terminal. To update to the latest version, run 'npm update -g @anthropic-ai/claude-code'. Claude Code updates frequently — checking weekly is a good habit.
Can I customize Claude Code keyboard shortcuts?
Not currently. Claude Code's keyboard shortcuts are built-in and cannot be remapped. They follow standard terminal conventions (Ctrl+C, Ctrl+D, Ctrl+L), so they should feel familiar if you use other terminal tools.
What does the /compact command actually do to my conversation?
The /compact command compresses your conversation history into a shorter summary. Claude identifies key information — files read, decisions made, tasks completed — and replaces the full history with a condensed version. You lose detailed back-and-forth but keep important context, freeing up space for new work.
How do I run Claude Code commands in a script or CI pipeline?
Use the -p (print) flag: 'claude -p "your prompt"'. This sends a single prompt, prints the response, and exits. You can pipe input and output. For JSON output, add --output-format json. This makes Claude Code scriptable for CI/CD pipelines and shell scripts.
Is there a way to see what MCP tools are available in my Claude Code session?
Type /mcp in your session to see all connected MCP servers and their status. Claude will also list available tools when you ask — try 'what tools do you have access to?'

Stay in the Loop

Join 1,000+ developers. Get the best new Skills & MCPs weekly.

No spam. Unsubscribe anytime.

Claude Code Keyboard Shortcuts & Commands Cheat Sheet (2026)