ASK KNOX
beta
LESSON 45

Commands, Shortcuts, and Slash Commands

The complete reference for Claude Code slash commands, keyboard shortcuts, CLI flags, and configuration — from /help to --dangerously-skip-permissions, covering every control you need for efficient daily use.

9 min read·Getting Started with Claude Code

Knowing the commands separates fluid Claude Code usage from constant friction. This lesson is the reference you come back to — every slash command, keyboard shortcut, useful CLI flag, and configuration option, explained concisely.

Slash Commands

Slash commands are typed directly in the Claude session prompt. They begin with / and execute immediately.

Session Management

/help Displays all available slash commands with brief descriptions. Run this when you forget a command.

/clear Resets the conversation context. CLAUDE.md files are re-read. Your actual code files are not affected. Use when switching between unrelated tasks.

/compact Summarizes the conversation history to reduce token usage while keeping key context. Claude creates a condensed summary and continues from there. Use mid-session when you are approaching context limits.

/exit (or Ctrl+D) Ends the Claude Code session and returns to your regular terminal prompt.

Reviewing and Committing

There is no built-in /commit command. Committing is something you ask Claude to do in plain language — "commit these changes with a clear message" — and Claude runs the git commands for you. If you commit constantly, author your own reusable command: drop a Markdown file in .claude/commands/ (for example .claude/commands/commit.md) and it becomes a project-specific /commit you control. See the “Custom Slash Commands” lesson for custom slash commands.

/code-review Reviews your current working diff for correctness bugs and for reuse, simplification, and efficiency cleanups. Pass --fix to apply the findings to your working tree, or --comment to post them as inline GitHub PR comments. This is the command you reach for before committing — an instant review of what you just changed.

/review Reviews a pull request locally in your current session. Use it when you want Claude to read an existing PR (yours or a teammate's), not the uncommitted changes in your working tree — for that, use /code-review.

Project Initialization

/init Scans your project directory and creates a CLAUDE.md file with inferred context — structure, tech stack, patterns it detects from the code. Run this once when starting work in an existing codebase. Then edit the generated file to add anything Claude missed.

Information

/status Opens the Settings interface (Status tab): the installed version, the active model, your account, and connectivity. It does not show context usage or cost — for those, use /context (context breakdown) and /cost (session cost and plan usage). /status works even while Claude is mid-response.

/model Displays the current Claude model and lets you switch models mid-session. The current default is Claude Sonnet 4.6; switch up to Claude Opus 4.8 for a complex task, or to a faster model for simple edits.

Beyond the Basics

As you go deeper, a few more commands become daily drivers:

/plan Enters plan mode — Claude researches and proposes a step-by-step plan without changing any files until you approve. Plan mode is primarily a permission mode you reach by cycling Shift+Tab; /plan is the shortcut to jump straight into it (optionally with a task, e.g. /plan fix the auth bug).

/context Shows a breakdown of what is currently filling your context window — files, tool output, and history — so you can see what to trim.

/memory Opens your CLAUDE.md memory files for editing without leaving the session. The # shortcut adds a single line to memory on the fly.

/config Opens an in-session settings menu to toggle theme, model, permission mode, and other preferences.

/mcp Manages Model Context Protocol servers, which connect Claude Code to external tools and data sources.

/agents Manages subagents — specialized helpers Claude can dispatch for focused or parallel work.

Keyboard Shortcuts

These work during any Claude Code session in the terminal.

ShortcutAction
Ctrl+CCancel the current operation. If Claude is mid-tool-call, this interrupts it.
EscapeCancel Claude's current response mid-stream and return to the prompt.
Escape EscapeDouble-tap to rewind — edit an earlier message and branch the conversation from there.
Shift+TabCycle permission modes (default → accept-edits → plan) without restarting.
/ Browse message history. Press Up to retrieve your previous prompts.
Shift+EnterInsert a newline in your message without submitting. Use for multi-line prompts.
Ctrl+DExit the session (same as /exit).
TabAutocomplete slash commands. Type /c and press Tab to see completions.
!Start a line with ! to run a shell command directly, without Claude interpreting it.
#Start a line with # to append a note to your CLAUDE.md memory.

CLI Flags (Passed at Launch)

These flags modify how Claude Code starts. Pass them when running claude from your terminal.

claude --help Full help documentation for the Claude Code CLI. Covers all flags and configuration options.

claude --version Shows the installed Claude Code version.

claude --dangerously-skip-permissions Launches in bypass mode — Claude auto-approves all tool calls without prompting. Use only in sandboxed, controlled environments. Never in production codebases.

claude --model claude-sonnet-4-6 Specifies which Claude model to use. The default is the current Sonnet (Claude Sonnet 4.6). Pass --model claude-opus-4-8 to pin Opus for a complex task, or pin any specific model version this way.

claude --debug Enables verbose debug logging. Shows internal state, API calls, and timing information. Use when diagnosing installation or authentication issues.

claude -p "Your prompt here" Print mode — runs Claude non-interactively with a single prompt and exits. Useful for scripting Claude into shell scripts or automation pipelines.

claude -p "Review the last git commit and summarize what changed"

Configuration: ~/.claude/

Claude Code stores its global configuration in ~/.claude/. Understanding this directory helps you customize behavior.

~/.claude/settings.json — Global settings file. Editable directly in any text editor or via the in-session /config menu. Key settings:

{
  "model": "claude-sonnet-4-6",
  "theme": "dark",
  "verbose": false,
  "permissions": {
    "defaultMode": "default"
  }
}

The Safe Way to Reduce Prompts: permissions Allow/Deny Lists

When Claude Code keeps stopping to ask "can I run this command?", the tempting fix is --dangerously-skip-permissions — which approves everything, including a destructive command you never meant to allow. There is a precise, safe alternative: the permissions block in settings.json. Instead of turning prompts off wholesale, you pre-approve the commands you trust and hard-block the ones you never want, so Claude stops asking about the routine while the dangerous stays gated.

The allow and deny lists take tool-call patterns. Bash(npm test) pre-approves exactly that command; Bash(npm run test:*) allows any script under test:; Bash(rm -rf *) on the deny list blocks it outright, even if you later get sloppy:

{
  "permissions": {
    "allow": [
      "Bash(npm test)",
      "Bash(npm run lint)",
      "Bash(git status)",
      "Read(src/**)"
    ],
    "deny": [
      "Bash(rm -rf *)",
      "Bash(git push:*)",
      "Read(.env)"
    ]
  }
}

The two lists are not symmetric in authority: deny always wins. If a command matches both an allow and a deny rule, it is denied — so a deny rule is a true guardrail you cannot accidentally override with a broad allow. Anything matching allow runs without a prompt; anything matching deny is blocked without a prompt; everything else falls through to the normal ask-the-human flow. That is the whole model: routine commands stop interrupting you, dangerous commands can never slip through, and the genuinely novel still pauses for your judgment.

This is the correct answer to "I'm tired of approving the same commands." Reach for a scoped allow list, not --dangerously-skip-permissions. You get the same reduction in friction with none of the blast radius — the difference between handing over a labeled set of keys and leaving the door wide open.

~/.claude/CLAUDE.md — Your global Claude instructions. Anything in this file applies to every Claude Code session on your machine, regardless of which project you are in. Use it for personal preferences that apply across all projects:

# Global Claude Instructions

## My Preferences
- I prefer TypeScript over JavaScript when given a choice
- Always add JSDoc comments to exported functions
- Never use `var` — always `const` or `let`
- Use 2-space indentation

## My Context
- I'm a beginner-to-intermediate developer
- Explain your reasoning briefly so I can learn from it
- If you see a simpler approach, suggest it even if I didn't ask

Common Configuration Patterns

There is no claude config set subcommand — you change settings in one of three ways:

Set a default model — add it to ~/.claude/settings.json:

{
  "model": "claude-sonnet-4-6"
}

Switch model mid-session — use the /model command, or pass --model at launch.

Toggle settings interactively — run /config inside a session to open the settings menu (theme, permission mode, model, and more).

Project-Level vs. Global Settings

Two separate systems are easy to conflate, so keep them apart.

settings.json — configuration. When the same setting appears at multiple scopes, Claude Code resolves it in this priority order (highest first):

  1. Managed settings — org-deployed policy; cannot be overridden by anything
  2. CLI flags — temporary session overrides passed at launch
  3. Local.claude/settings.local.json (gitignored; your personal per-project overrides)
  4. Project.claude/settings.json (checked into the repo, shared with the team)
  5. User~/.claude/settings.json (your global defaults)
  6. Defaults — built into the tool, lowest priority

So a local setting beats project, project beats user, a CLI flag beats all of those, and managed policy beats everything.

CLAUDE.md — memory, not config. This is the separate system. CLAUDE.md files are additive context (memory), not configuration — a project CLAUDE.md does not override a value in settings.json. Memory has its own hierarchy that layers rather than competing winner-take-all: enterprise/managed memory, then project ./CLAUDE.md (and any nested CLAUDE.md in subdirectories), then your user ~/.claude/CLAUDE.md. All applicable memory files are loaded and combined.

Practical Command Sequences

Starting a new task:

/clear
[describe your new task]

After a long session, before a big task:

/compact
[describe the next thing you want to do]

Reviewing and committing changes:

/code-review    # if the code-review plugin is installed; otherwise ask Claude in plain language
[if review looks good, just ask Claude in plain language:]
Commit these changes with a clear message.

Checking what you've used so far:

/context    # what's filling the context window
/cost       # session cost and plan usage

Lesson Drill

Open a Claude session in any project and run through these commands in order:

  1. /help — read every command listed; note which plugin-provided commands like /code-review appear (they will only show if the plugin is installed)
  2. /status — note the version, model, and account; then /context to see context usage
  3. Make a small code change (or ask Claude to make one)
  4. Review the change: run /code-review if it appears in /help, or ask Claude directly — "Review my current diff for bugs and improvements" — if the plugin is not installed. Both produce a review.
  5. Ask Claude in plain language: "Commit this change with a clear message" (there is no /commit command)
  6. /clear — reset the context
  7. Verify CLAUDE.md is still loaded by asking a question about your project

This takes about 10 minutes and builds muscle memory for the daily workflow.

Bottom Line

Slash commands control session state (/clear, /compact), code review (/code-review for your working diff, /review for a PR), and project setup (/init). There is no built-in /commit — you ask Claude to commit in plain language, or author your own command in .claude/commands/. Keyboard shortcuts give you escape hatches (Ctrl+C, Escape) and productivity shortcuts (↑ for history, Shift+Enter for multi-line). CLI flags configure launch behavior for special modes. settings.json configuration is layered (managed → CLI → local → project → user → defaults); CLAUDE.md memory is a separate, additive system that does not override settings.

Next: the skill that unlocks faster problem-solving — debugging with Claude Code.