tutorial9 min read

Claude Code Cheat Sheet: Every Command, Shortcut & Workflow (2026)

A complete Claude Code reference: slash commands, keyboard shortcuts, CLI flags, hooks, subagents, and skills — organized into scannable tables you can bookmark and use daily.

Claude Code Cheat Sheet: Every Command, Shortcut & Workflow (2026)

Claude Code has grown from a simple terminal chatbot into a full agentic development environment — slash commands, background sessions, hooks, subagents, skills, and a plugin ecosystem all layered on top of the core CLI. That's a lot of surface area to remember mid-flow, which is exactly the problem a cheat sheet solves: you shouldn't have to re-read the docs every time you want to spin up a background agent or figure out whether a task needs a skill or a subagent.

This is a working reference, not a marketing page. Every table below is something you can act on the next time you're in a terminal with Claude Code open.

Getting Oriented: Core CLI Commands

These are the commands you type before Claude Code even starts a session, or that manage the session itself.

CommandWhat it does
claudeStart an interactive session in the current directory
claude "prompt"Start a session with an initial prompt already queued
claude -p "prompt"Run a single prompt non-interactively and print the result (good for scripts/CI)
claude --continueResume your most recent session in this directory
claude --resumePick a previous session from a list to resume
claude agentsOpen the agent view to manage background sessions
claude mcpManage MCP server connections (add, remove, list, authenticate)
claude --model Start a session pinned to a specific model
claude updateUpdate Claude Code to the latest version
Model selection at a glance: as of mid-2026, Sonnet 5 is the default model in Claude Code, with a native 1M-token context window out of the box. Switch to Opus 4.8 with /model opus when a task needs deeper reasoning (architecture decisions, gnarly bugs, multi-file refactors), and drop to Haiku 4.5 for cheap, high-volume mechanical work. Effort and cost scale together — don't reach for Opus on a one-line fix.

Slash Commands You'll Actually Use

Slash commands are typed shortcuts that trigger a specific, predictable action — as opposed to skills, which Claude loads implicitly when it decides they're relevant. If you want something to happen exactly when you type it, it belongs in this table.

CommandPurpose
/initScaffold a new CLAUDE.md by scanning the current repo
/compactSummarize the conversation to free up context without losing key facts
/contextShow current context window usage broken down by category
/reviewReview a GitHub pull request
/code-reviewReview the current diff for bugs and cleanup opportunities
/code-review --fixReview the diff and apply the fixes automatically
/simplifyCleanup-only pass on changed code (no bug hunting)
/security-reviewRun a security-focused review of pending changes
/agentsList, create, or edit subagent definitions
/modelSwitch the active model for the session
/permissionsView or edit tool permission settings
/configOpen quick settings (theme, model, notifications)
/clearClear the conversation and start fresh in the same directory
/helpList available commands and get contextual help

Custom slash commands live in .claude/commands/*.md — a Markdown file with frontmatter becomes a reusable prompt template you invoke with /your-command-name. This is the fastest way to codify a repeated workflow (a deploy checklist, a commit-message format, a test-writing template) without building a full skill.

Keyboard Shortcuts and Input Prefixes

Inside an interactive session, a handful of prefixes and keystrokes change how your input is treated:

InputEffect
!command at the start of a lineRuns command as a raw shell command and includes the output in context
#note at the start of a lineAdds a note to memory/CLAUDE.md rather than sending a prompt
/Opens the slash command menu
Shift+TabCycles between permission modes (ask / auto-accept edits / plan-only)
Ctrl+C (once)Interrupts the current response
Ctrl+C (twice)Exits the session
EscCancels the current input or stops a running tool call
Ctrl+RSearch session history

These prefixes matter more than they look — ! and # let you inject shell output or durable notes into a conversation without breaking your typing flow, which adds up over a long session.

Hooks, Subagents, and Skills: Picking the Right Tool

This is the part of Claude Code that trips people up most, because the three mechanisms overlap in what they can do but differ sharply in when they fire and how much you control them. A simple rule of thumb:

MechanismFires whenBest for
Slash commandYou type it, explicitlyManual, repeatable actions ("run my deploy checklist now")
SkillClaude decides it's relevantDomain knowledge and helper files Claude should pull in automatically
SubagentYou (or Claude) delegate work to itIsolated, parallelizable, or context-heavy exploration
HookA defined lifecycle event occurs (PreToolUse, PostToolUse, Stop, etc.)Deterministic enforcement — rules that must never depend on the model remembering

The distinction that matters most: hooks are code, not instructions. A CLAUDE.md rule that says "never run rm -rf" depends on Claude reading and following it every single time. A PreToolUse hook that blocks the command pattern is enforced at the system level regardless of what the model decides. If a rule is genuinely non-negotiable — blocking destructive commands, injecting required context, logging every tool call for audit — put it in a hook, not a prompt.

A basic hook lives in .claude/settings.json:

json{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "./scripts/block-dangerous-commands.sh"
          }
        ]
      }
    ]
  }
}

Subagents, by contrast, are about context isolation, not enforcement. When you fork exploratory work — "search the whole codebase for every place we call this deprecated function" — into a subagent, that search's verbose output stays in the subagent's own context window instead of polluting your main conversation. You get the answer back; you don't get the noise. This is the single biggest lever for keeping long sessions coherent: delegate anything that would otherwise dump thousands of tokens of grep output into your main thread.

CLAUDE.md: The File That Sets the Rules

CLAUDE.md is the project-level memory Claude reads at the start of every session in a repo. A few hard-earned rules for writing one:
  • Brevity is a performance requirement, not a nice-to-have. The longer CLAUDE.md gets, the more the probability of any individual instruction being followed drops. A 40-line file with five load-bearing rules beats a 400-line file with fifty half-remembered ones.
  • Put durable facts here, not task state. Architecture decisions, naming conventions, and "always do X" rules belong in CLAUDE.md. "I'm currently refactoring the auth module" belongs in your conversation, not the file.
  • Nest CLAUDE.md files in subdirectories for monorepos — Claude Code reads the nearest one up the directory tree, so a packages/api/CLAUDE.md can add API-specific rules without bloating the root file.
  • Use /init to bootstrap, then prune. The auto-generated version tends to over-document obvious things (like the fact that package.json lists dependencies). Cut anything a competent engineer could infer from the code itself.

MCP Servers: Connecting Claude to the Outside World

MCP (Model Context Protocol) servers give Claude Code tools beyond its built-in file and shell access — GitHub, databases, Slack, browser automation, and dozens of other integrations. Manage them with claude mcp:

CommandPurpose
claude mcp add Add a new MCP server connection
claude mcp listList configured MCP servers and their connection status
claude mcp remove Remove a server
/mcpManage MCP connections from inside a session

A permissions note worth internalizing: deny-first is safer than block-with-hooks for sensitive files. Setting a path to deny in permissions makes it invisible to Claude entirely — it can't read it, can't be tricked into reading it, can't accidentally surface its contents in a response. A hook that blocks access after Claude has already tried to read the file is a weaker guarantee than a permission that stops the read from happening at all.

A Practical Workflow Checklist

Putting it together, a solid default working pattern looks like this:

  • Start with /init on a new repo, then prune the generated CLAUDE.md down to what actually matters.
  • Reach for skills first for anything domain-specific and repeatable — they're the cheapest to create and the easiest for Claude to discover on its own.
  • Add hooks the moment you find yourself writing "never do X" in a prompt for the third time. If it's non-negotiable, enforce it in code.
  • Delegate to subagents for wide exploration, parallel independent work, or anything that would otherwise flood your main context with intermediate output.
  • Use slash commands for anything you want to trigger manually and predictably — deploy steps, review passes, commit formatting.
  • Match the model to the task. Sonnet 5 for the default day-to-day work, Opus 4.8 when the problem is genuinely hard, Haiku 4.5 for high-volume mechanical edits.
  • Key Takeaways

    • Slash commands are explicit triggers; skills are things Claude decides to load — pick based on whether you want manual control or automatic context.
    • Hooks enforce rules deterministically at the system level; CLAUDE.md instructions depend on the model remembering — use hooks for anything truly non-negotiable.
    • Subagents exist primarily for context isolation, not just parallelism — delegate noisy exploratory work so it doesn't pollute your main session.
    • Keep CLAUDE.md short. A shorter file with fewer, sharper rules outperforms a long one every time.
    • ! and # prefixes let you inject shell output and durable notes into a session without leaving the prompt.

    Next Steps

    Bookmark this page — it's built to be a working reference, not a one-time read. If you're studying for the Claude Certified Architect (CCA) exam, the sections on hooks, subagents, and skills map directly onto tested material around agentic tool design and context management. AI for Anything's CCA practice test bank covers exactly this territory with exam-style questions and explanations, so you can check whether you actually understand the distinctions above or just recognize the vocabulary.

    Ready to Start Practicing?

    300+ scenario-based practice questions covering all 5 CCA domains. Detailed explanations for every answer.

    ⚡ Get the hottest AI insights, daily

    One short email a day — the AI news, tools, and how-tos that actually matter. Plus, be first to hear when the personalized 30-Day AI Mastery Challenge launches.