---
title: "Claude Code Commands Cheat Sheet (2026): Slash Commands and Shortcuts"
description: "Claude Code slash commands and shortcuts grouped by session, context, permissions and config, with when to use each one and how to choose /compact vs /clear."
url: https://cdnping.org/en/blog/claude-code-commands-cheatsheet
language: en
published: 2026-11-25
category: "Developer tools"
tags: ["Claude Code","slash commands","keyboard shortcuts","context management","getting started"]
source: cdnping.org
license: Free to quote and summarize with a link to the url above.
---
# Claude Code Commands Cheat Sheet (2026): Slash Commands and Shortcuts

Claude Code's everyday commands fall into four groups: session (/clear, /resume), context (/compact, /context), permissions (/permissions, Shift+Tab), and configuration (/model, /config, /doctor). Type `/` in a session to list every command your current version supports. The cheat sheet below covers the ones you will use most often.

These commands are built into Claude Code and may be added, removed, or renamed between versions. For exact behavior, check the official docs and the output of `/help` on your machine. This article does not list model version names or any parameters I am not sure about.

## How should I group these commands?

It is easier to remember them by the problem you are trying to solve than alphabetically:

- The conversation is a mess, or you want to switch topics: session commands
- The conversation is long, slow, or the model is forgetting things: context commands
- You are tired of confirming every step, or you want to tighten permissions: permission commands
- You need to switch models, diagnose a problem, or change settings: configuration commands

## Which session commands are there?

| Command | What it does | When to use it |
|---|---|---|
| `/clear` | Clears the current conversation history and starts a new session | You are moving to an unrelated task and don't want old context interfering |
| `/resume` | Lists past sessions so you can pick one to resume | Yesterday's task isn't finished and you want to continue it |
| `/rewind` | Rolls back the conversation (in some versions, code changes too) | The model went off track and you want to return to an earlier step |
| `/export` | Exports the current conversation (check `/help` for availability) | You want a record, or want to share how you debugged something |
| `/exit` | Exits | You are done |

From the terminal you can also run `claude --continue` to pick up the most recent session, or `claude --resume` to choose from past sessions. Those are launch flags, not in-session commands.

## Which context commands are there?

Context is the total amount of content the model can "see" at once. The longer the conversation, the more of it is used up, and responses usually get slower and more expensive.

| Command | What it does | When to use it |
|---|---|---|
| `/compact` | Compresses the existing conversation into a summary to free up space | The task isn't done, but the conversation is already long |
| `/context` | Shows how much context is in use | You want to know what is taking up the space |
| `/cost` | Shows usage for this session; whether a dollar amount appears depends on how you logged in | Estimating consumption |
| `/memory` | Edits memory files (such as CLAUDE.md) | You want project conventions to persist |
| `/init` | Generates an initial CLAUDE.md for the current project | You just entered a new project |

### Should I use /compact or /clear?

- The same task is still going and you need to keep the key information: use `/compact`.
- The task is finished and the next one is unrelated: use `/clear`.

You can add a note after `/compact` to tell it what to keep in the summary, for example:

```
/compact Keep the confirmed API design and the list of unfinished tests
```

Compression loses detail. Write important decisions into CLAUDE.md instead of relying on the conversation to remember them. To estimate monthly consumption, see "[How to estimate Claude Code token usage: work out your monthly cost from your own usage](/en/blog/ai-coding-agent-token-cost-estimate)". If your quota is tight, see "[Claude Code quota not enough: check consumption first, then decide whether to upgrade or change billing](/en/blog/claude-code-quota-not-enough)".

## How do the permission commands and shortcuts work?

Before reading or writing files or running commands, Claude Code asks for confirmation. These are the controls for adjusting that behavior:

| Action | What it does | When to use it |
|---|---|---|
| `/permissions` | View and adjust the allow and deny rules for tools | A certain kind of command (such as `git status`) asks for confirmation every time and you want to allow it |
| `Shift+Tab` | Switches between permission modes (such as plan mode) | You want it to produce a plan only, without touching files |
| `Esc` | Interrupts the operation currently running | It is heading the wrong way and you want it to stop now |
| `Esc` twice | Jumps back to an earlier message so you can edit it | You want to rewrite your previous prompt |

Be careful with allow rules: don't add commands like delete or force-push to the auto-allow list. For the exact rule syntax, see the official docs.

## Which configuration commands are there?

| Command | What it does | When to use it |
|---|---|---|
| `/model` | Shows and switches the model | Use a lighter model for simple tasks and a stronger one for complex tasks |
| `/config` | Opens the settings UI | Adjust theme, notifications, and other options |
| `/status` | Shows version, account, API endpoint, and other status | Confirm what you are actually connected to |
| `/doctor` | Checks for installation and configuration problems | Commands misbehave, or behavior is wrong after an upgrade |
| `/login`, `/logout` | Switches login | Change accounts or authentication method |
| `/mcp` | Manages MCP servers | Connect or inspect external tools |
| `/agents` | Manages subagents | Define your own specialized agents |
| `/hooks` | Configures hooks | You want scripts to run automatically before or after tool calls |

For more detail: switching models is covered in "[How to switch models in Claude Code: /model and config files](/en/blog/claude-code-switch-model)", config file precedence in "[Claude Code settings.json levels, precedence, and env configuration](/en/blog/claude-code-settings-json-guide)", and login problems in "[Claude Code won't log in? Troubleshoot by authentication method](/en/blog/claude-code-login-failed)".

## What symbols and shortcuts help in the input box?

| Input | What it does |
|---|---|
| `@file-path` | References a file or directory so it reads it directly |
| `!command` | Enters shell mode: runs a shell command directly and brings the output into the conversation |
| `\` then Enter | Inserts a newline (some terminals support Shift+Enter; run `/terminal-setup` if needed) |
| `Ctrl+C` | Cancels the current input or operation |
| `Ctrl+D` | Exits |
| `Ctrl+L` | Clears the screen |
| `Ctrl+R` | Searches input history |

Terminals handle key combinations differently. If a key does nothing, first check whether the terminal itself has claimed it.

## A daily workflow you can follow

1. Go to your project directory and run `claude`. The first time, use `/init` to generate CLAUDE.md.
2. For a complex task, press `Shift+Tab` to switch to plan mode first, and confirm the plan before letting it make changes.
3. Every so often, check usage with `/context`. If it is high, run `/compact` and say what to keep.
4. If it goes off track, press `Esc` to interrupt, then use `/rewind` to go back.
5. When the task is done, run `/clear`, then start the next one.
6. When something goes wrong, run `/doctor` and `/status` first, then look at the network and authentication.

## Commands work but the connection fails. What now?

The commands themselves don't need the network, but the requests that call the model do. If you see timeouts or 401 errors, first check whether the API service is healthy. cdnping's [/en/status/anthropic](/en/status/anthropic) probes the official API entry point from the Cloudflare edge every 5 minutes, and [/en/down/claude-code](/en/down/claude-code) pulls together the status page, probes, and user reports. After that, work through "[Troubleshooting Claude Code connection timeouts and errors: a four-layer network checklist](/en/blog/claude-code-connection-troubleshooting)" layer by layer.

## What if I don't have a Claude account or can't easily pay?

Claude Code can connect to a third-party gateway through a custom API endpoint, so logging in with a Claude account is not strictly required. See "[Custom API endpoints for Claude Code, Codex, and OpenCode](/en/blog/configure-custom-api-endpoint-claude-code-codex)" for the approach.

AGI Plan is a multi-provider LLM aggregation gateway. It is billed monthly, settled in RMB, and does not require an overseas credit card. A single subscription includes capability groups such as frontier reasoning, balanced general-purpose, Chinese flagship models, and fast lightweight models. To use Claude Code or Codex, you only change the API endpoint to its address. Note that the service states clearly that it is not an officially authorized channel, and some models are marked "overseas only"; check [agiplan.dev/models](https://agiplan.dev/models) for specifics. AGI Plan is a commercial partner of cdnping. To learn how to connect, see [agiplan.dev/startup](https://agiplan.dev/startup).

Before connecting, also read "[Is a Claude API relay reliable? Four main risks and self-checks you can run](/en/blog/is-claude-api-relay-safe)" and then decide whether to use any relay service.

## Next steps

Type `/help` in the terminal and compare the output with this article to check the commands in your version. Get comfortable with the most common ones: `/compact`, `/clear`, `/rewind`, and `Shift+Tab`. If you haven't finished installing yet, start with "[Claude Code installation guide (macOS / Linux / Windows)](/en/blog/install-claude-code-npm)", then continue with "[How to use Claude Code: from installation to your first code change](/en/blog/claude-code-beginner-guide)".
