Claude Code commands: slash commands, CLI flags, shortcuts
The Claude Code commands worth knowing, from /init, /compact and /model to CLI flags such as -p and -c, keyboard shortcuts and your own commands.
Claude Code has two kinds of built-in commands. Slash commands such as /init, /compact and /model run inside a session; type / to list them. CLI commands and flags such as claude -p, claude -c and --model run in your terminal. Keyboard shortcuts and your own commands, written as skills, complete the set.
Slash commands or CLI commands?#
| Kind | Where you type it | Example |
|---|---|---|
| Slash command | In the Claude Code prompt, at the start of a message | /compact |
| CLI command or flag | In your terminal, before Claude Code starts | claude -c |
| Keyboard shortcut | In the Claude Code prompt | Shift+Tab |
| Your own command (skill) | In the Claude Code prompt, like a slash command | /fix-issue 123 |
A slash command works only at the start of a message, and any text after its name becomes its arguments. If you send one while Claude is still answering, it waits in a queue, though some, such as /status, /tasks and /usage, run right away. The list depends on your platform, plan and version, so a bare / or /help is the reliable way to see yours.
Which slash commands should you know?#
The ones you'll use most, by when you need them.
Set up a project#
/init: Claude reads the project and writes a starterCLAUDE.md, a file of instructions it loads at the start of every session./memory: opens yourCLAUDE.mdfiles and auto memory for editing./permissions: shows and edits the allow, ask and deny rules for tools./mcp: lists your MCP servers and their status. See MCP in Claude Code./config: opens the settings. You can also set one value directly, such as/config theme=dark.
During a task#
/plan: asks Claude to plan before it edits anything. Add the task after it, such as/plan fix the auth bug./model: switches the model and saves it as the default for new sessions. IfANTHROPIC_MODELis set, as in the setup below, the next launch returns to that model./effort: sets how much the model thinks before it answers./context: shows how full the context window is, as a colored grid./compact: summarizes the conversation to free up context. Add instructions to say what to keep, such as/compact keep the API changes./btw: asks a quick side question. The answer doesn't enter the conversation history, and Claude can't use tools to answer it.
Review and undo#
/diff: opens a viewer of your uncommitted changes./rewind: goes back to an earlier point in the conversation, the code, or both. PressingEsctwice on an empty prompt opens the same menu, and/undoand/checkpointare other names for it./review: asks Claude to review your changes or a pull request, such as/review 1234. It's another name for/code-review./security-review: checks the pending changes on your branch for security problems. It needs a Git remote namedorigin.
Sessions and status#
/clear: starts a new conversation with empty context;/resetand/newdo the same./resume: reopens an earlier session by name or from a list./rename: gives the current session a name you can find later./status: shows the version, model, account and connection./usage: shows the session's cost and your plan's usage limits./costand/statsare other names for it./doctor: a built-in skill that checks your setup and proposes fixes, which Claude applies once you confirm./help: lists the commands available to you.
Which CLI commands and flags matter?#
| Command | What it does |
|---|---|
claude | Starts an interactive session in the current folder |
claude "query" | Starts a session with a first prompt |
claude -p "query" | Answers once in print mode, then exits |
claude -c | Continues the most recent conversation in this folder |
claude -r "name" "query" | Resumes a session by name or ID |
claude update | Updates Claude Code to the latest version |
claude doctor | Checks the install and settings without starting a session |
claude mcp | Configures MCP servers |
The flags you'll reach for most:
--model: picks the model for this session. It wins over themodelsetting and overANTHROPIC_MODEL.--permission-mode: starts in a given mode, such asplanoracceptEdits.--add-dir: lets Claude work in more folders, such asclaude --add-dir ../apps ../lib.-nor--name: names the session, such asclaude -n "auth-refactor", soclaude -r "auth-refactor"finds it later.--output-format json: returns print-mode output as JSON for scripts.--max-turns: caps how many agent turns print mode takes, such asclaude -p --max-turns 3 "query".--allowedTools: lists tools that run without asking, such as"Bash(git diff *)" "Read".
Which keyboard shortcuts save time?#
| Key | What it does |
|---|---|
/ | Opens the list of commands and skills |
! | Runs a shell command (shell mode) |
@ | Mentions a file, with path completion |
Esc | Stops Claude and keeps the work done so far |
Esc Esc | Clears the draft, or opens the rewind menu on an empty prompt |
Shift+Tab | Cycles the permission modes |
Ctrl+C | Clears the input or interrupts; press twice to exit |
Ctrl+R | Searches your prompt history |
Ctrl+O | Opens the transcript viewer |
? | Shows the shortcuts, on an empty prompt |
For a new line without sending, Ctrl+J works in any terminal, and Shift+Enter works natively in Windows Terminal, iTerm2, Apple Terminal, WezTerm, Ghostty, Kitty and Warp. On some Windows setups the permission-mode key is Alt+M instead of Shift+Tab.
Shell mode adds the command and its output to the conversation, and Claude replies to it automatically, which costs the same as a normal prompt. To turn the reply off, set respondToBashCommands to false in your settings.
How do the commands fit together?#
Start in your project#
Open a terminal in the project folder and run
claude. Run/initonce, so Claude writes aCLAUDE.mdthat describes the project.Plan the change#
Type
/planand the task. Claude proposes a plan before it edits any file, and starts once you approve it.Keep the context small#
Check
/contexton long tasks. Run/compactwhen it fills up, or/clearwhen you move to an unrelated task.Check and ship#
Look over the edits with
/diff, ask for a/review, and use/rewindif a change went wrong.
Print mode for scripts#
Print mode answers once and exits, so it fits scripts, Git hooks and CI. You can pipe text into it:
git diff | claude -p "Write a commit message for these changes"
cat error.log | claude -p "Explain the likely cause" --output-format json
claude -c -p "Check for type errors"Print mode reads the same settings file as a normal session, so it uses the same key and model.
How do you add your own commands?#
Your own command is a skill: a folder with a SKILL.md file inside. The folder name becomes the command, so .claude/skills/fix-issue/SKILL.md creates /fix-issue.
- Personal:
~/.claude/skills/<name>/SKILL.mdworks in every project. - Project:
.claude/skills/<name>/SKILL.mdlives in the repository, so your team gets it through Git. - Older format: files such as
.claude/commands/deploy.mdkeep working and create/deploytoo.
Save this as .claude/skills/fix-issue/SKILL.md for a command that fixes a GitHub issue:
---
description: Fix a GitHub issue by number
disable-model-invocation: true
---
Fix GitHub issue $ARGUMENTS.
Read the issue, find the cause, make the fix, add a test, then run the test suite.Type /fix-issue 123 and Claude Code puts 123 where $ARGUMENTS stands; $0 and $1 pick single arguments in order. With disable-model-invocation: true, the command runs only when you type it. Without it, Claude can also start the skill by itself when a task fits its description. /skills lists everything you have, and MCP servers can add their own prompts as commands.
Do the commands work with an API key?#
Yes. 5abeer is an independent service compatible with the Anthropic Messages API, so every command above runs exactly as Anthropic ships it. Only the base URL and the key change, in ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.5abeer.ai",
"ANTHROPIC_AUTH_TOKEN": "YOUR_5ABEER_API_KEY",
"ANTHROPIC_MODEL": "claude-sonnet-5.5"
}
}
~/.claude/settings.json
Create the key in your dashboard first (how to create a key). Then run /status: the Anthropic base URL line should show the 5abeer address.
Two things work differently with a key:
- Spend:
/usageshows Claude Code's own estimate. Your real charges are in the dashboard (usage and balance). - Account commands:
/login,/logoutandclaude setup-tokenare for Claude accounts, andclaude setup-tokenneeds a Claude subscription. With a key in the settings file, you don't need them.
You can run Claude Code on 5abeer in two ways:
- An API key, paid as you go. Pay per token from your balance, and give every key a spend limit, an expiry date and an IP allow-list (key controls). Claude prices are on the Claude API page.
- A 5abeer plan. The 5abeer AI app turns on Claude Code for your plan (what each plan runs). Plans are for the supported apps. To call the models from your own code, create an API key. See the pricing page and the Claude Code app page.
If a request is refused with a code, INVALID_API_KEY means the key is wrong or deleted, and INSUFFICIENT_BALANCE means your balance doesn't cover the request. Every code is in Errors and fixes, and every setting is on the Claude Code docs page.
Questions#
How do I see every command?#
Type / at the start of the prompt, or run /help. Both show the commands and skills in your version. For terminal flags, run claude --help, and check the CLI reference for the flags it leaves out.
What is the difference between /clear and /compact?#
/clear starts a new conversation with empty context, and the old one stays available in /resume. /compact keeps the same conversation but replaces its history with a summary. Use /compact to keep going on a long task, and /clear when you switch to something unrelated.
How do I undo a change Claude made?#
Run /rewind, or press Esc twice on an empty prompt, and pick the point to go back to. You can restore the code, the conversation or both. Treat it as a quick undo and keep using Git for your history.
How do I return to an earlier session?#
Run claude -c to continue the latest conversation in the folder, or claude -r "name" to open a named one. Inside Claude Code, /resume shows a list.
Which commands use my balance?#
Anything that sends a prompt to the model: your messages, /init, /compact, /review, /btw, /doctor, your own skills and Claude's reply after a ! shell command. Settings and viewer commands such as /config, /diff and /help run on your machine.
Which model should I pick?#
Start with the default model, claude-sonnet-5.5, which handles most coding tasks. Move to claude-opus-5.5 or claude-fable-5.1 for the hardest problems. Switch inside Claude Code with /model, or for one session with --model. The full list with prices is on the models page.
Sources#
Checked on 2026-11-01:
- Claude Code docs: Commands
- Claude Code docs: CLI reference
- Claude Code docs: Interactive mode
- Claude Code docs: Skills
Get started#
Set up the editor version in Claude Code in VS Code, install it with Install Claude Code on Windows, or compare costs in The cheapest way to use Claude Code.
Related guides
- Claude Code in VS Code: install, connect an API key, use itInstall the Claude Code extension in VS Code, sign in or connect an API key, and work with diffs, @-mentions, checkpoints and the terminal CLI.
- Install Claude Code on Windows: setup, API key and fixesInstall Claude Code on Windows 10 or 11 with PowerShell, CMD, WinGet or WSL, then sign in or add an API key, and fix the common install errors.
- The cheapest way to use Claude Code: a plan or an API key?What Claude Code costs on a Claude plan and on an API key, Anthropic's published cost per developer, and which route is cheaper for light and heavy use.
Ready to start?
Pick a plan that runs the official apps, or create an API key to use from your own code.