Most people use Claude Code the same way: type a prompt, wait, accept the edits, repeat. That works, but it leaves the best part of the tool untouched. Under the surface sits a control layer of slash commands, keyboard shortcuts, and CLI flags that turn a chat prompt into a real development cockpit. These are the commands that let you roll back a bad change, switch models mid task, ask a side question without derailing your work, and keep long sessions fast instead of sluggish.
This guide walks through the hidden Claude Code commands that experienced developers reach for every day, grouped by when you actually need them rather than dumped in an alphabetical list. Everything here reflects the current Claude Code (the 2.x line), and where a command behaves differently by version or plan, that is called out. If you are brand new, skim the first two sections and come back for the rest once the basics feel comfortable.
What are Claude Code commands?
Claude Code commands are the built-in slash commands, keyboard shortcuts, and command-line flags that ship with Claude Code but rarely show up in a first tutorial. They are not secret features you unlock. They are standard capabilities that most users never discover because they never type / to browse the menu or read past the getting-started page. Learning a handful of them, such as /rewind, /context, /btw, and the double-Escape rollback, is the difference between poking at the tool and driving it.
There are three families to know:
Slash commands run inside a session and start with /, like /compact or /model. Keyboard shortcuts control the interface itself, like double-Escape to rewind or Ctrl+B to background a task. CLI flags are options you pass when launching Claude Code from your terminal, like claude --model opus. Each family solves a different kind of problem, and the sections below cover all three.
How to find every command yourself
Before the list, learn the one habit that makes the rest optional. Type / on an empty prompt and Claude Code shows every command available to you: built-in commands, bundled skills, your own custom commands, and anything contributed by connected plugins or MCP servers. Keep typing letters to filter the list live, so /re narrows to /resume, /review, /rewind, and friends.
Two more discovery tools are worth pinning to memory. /help prints the full command list with short descriptions. Pressing ? on an empty input toggles a keyboard-shortcut help panel so you never have to guess a binding. One important caveat: not every command appears for every person. Availability depends on your plan, your platform, and your Claude Code version, which is exactly why some commands you read about online may not show up in your menu.
Context management commands that save long sessions
The first place Claude Code quietly degrades is context. As a session fills the model's context window, responses get slower and less sharp. These commands keep that from happening.
/context shows a visual grid of what is currently eating your context window, from tool definitions to memory files to the conversation itself. It flags bloat and warns you when you are close to capacity. Run it whenever a session starts feeling heavy, and you will usually spot the culprit in seconds.
/compact compresses the conversation history into a dense summary and frees up space, so you can keep going without losing the thread. You can steer what it keeps by passing instructions, for example /compact focus on the auth module and the current test failures. Use it when your context is getting full but you are still on the same task.
/clear starts a fresh conversation with an empty context while keeping your project memory. Reach for this when you switch to a genuinely new task, not just to trim a long one. The rule of thumb: /compact to continue the same work with more room, /clear to begin something new. You can pass a name, like /clear auth-refactor, to label the old conversation in your resume list.
/btw is one of the most underused commands in the whole tool. It lets you ask a quick side question without adding anything to the main conversation. Say Claude is halfway through a large refactor and you suddenly need to remember which config file held a setting. Instead of interrupting the task, you type /btw which file has the database url? and get an answer in a dismissible overlay that never touches your working context. It even works while Claude is still processing a response. Side questions see everything in your session but have no tools, so they answer from what Claude already knows.
Navigating and rescuing sessions
Everyone eventually sends Claude down the wrong path or wants to try two approaches to the same problem. This is the toolkit for that.
Double-Escape (rewind) is the shortcut to learn first. Press Esc twice on an empty prompt to open the rewind menu, then choose to restore your code, your conversation, or both to an earlier checkpoint. Claude Code tracks your edits automatically, so this is faster than git stash for quick experiments. If the prompt already has text, double-Escape clears the draft and saves it to history instead, so pressing Up brings it back.
/rewind does the same thing from the command line and can also summarize part of the conversation rather than deleting it. Think of it as your undo button for the whole session, code and chat together.
/resume returns you to an earlier conversation. Pair it with the labels you set in /clear and you can jump straight back to last week's work.
/branch splits the current conversation at this point so you can try a different direction while keeping the original intact. You switch into the branch, and the original waits for you under /resume.
/fork copies the current conversation into a new background session and lets you keep working where you are. The two sessions run independently from that point, which is perfect when you want a second experiment running without babysitting it.
/background (alias /bg) detaches the whole session to keep running on its own and frees your terminal. Monitor detached work with claude agents from the shell. /remote-control goes further and lets you continue a local session from another device, so you can start something on your laptop and check on it from your phone.
Controlling model, effort, and cost
You should not pay top-tier rates for boilerplate, and you should not run your hardest architecture problem on a fast, cheap model. These commands match the horsepower to the task.
/model switches the active model and saves it as your default. With no argument it opens a picker where you can pick per session only. In the current lineup that means choosing between the flagship, a strong daily coding model, and a fast lightweight one, with availability depending on your plan. The shortcut Option+P (macOS) or Alt+P (Windows and Linux) switches models without clearing whatever you have already typed.
/effort sets how much reasoning the model applies, from low through medium, high, xhigh, and max, with the available levels depending on the model. Lower effort is faster and cheaper for simple, scoped work. Higher effort is worth it for deep debugging and design. A common pattern is high effort for planning and lower effort for mechanical execution.
/fast toggles fast mode for latency-sensitive work that does not need deep intelligence, and the shortcut Option+O or Alt+O flips it without leaving the prompt.
/usage (with /cost as its alias) shows what your session is spending, so cost stops being a mystery. Check it once during a long session and you will quickly build an instinct for which tasks are expensive.
One more model-adjacent gem: Option+T or Alt+T toggles extended thinking on and off, so you can turn on deeper reasoning for a single hard prompt and turn it back off afterward.
Keyboard shortcuts most developers never find
Slash commands are only half the story. The interactive interface is a full terminal application with shortcuts that most people never touch. A note for macOS users first: several of these use the Option key as Meta, which you enable once in your terminal settings (in iTerm2, set the Option key to "Esc+" under Profiles then Keys).
! shell mode. Start a line with ! to run a shell command directly, like ! npm test. The command and its output get added to your conversation, and in current versions Claude responds to the result automatically, so ! npm test can surface an explanation of the failures without a second prompt.
@ file mentions. Type @ to trigger file-path autocomplete and reference a specific file in your prompt, so you can point Claude at exactly the right place without pasting the path.
Ctrl+B background a task. Move a running Bash command or agent to the background so you can keep working while builds, tests, or servers run. Tmux users press it twice.
Ctrl+X Ctrl+K stop background subagents. When a runaway subagent is chewing through tokens, this stops all background subagents in the session. Press it twice within three seconds to confirm. This is the current binding, and it is worth memorizing because a stalled agent is the fastest way to waste money.
Ctrl+R reverse history search. Search interactively through your previous prompts, newest first, so you can reuse a command you typed an hour ago instead of retyping it.
Ctrl+G external editor. Open your prompt in your default text editor for long or complex instructions, then save to send. Far better than fighting a multi-line prompt inside the terminal.
Ctrl+O transcript viewer. Toggle a detailed view of tool usage and execution, including which model handled each message and expanded MCP calls that normally collapse to a single line.
Ctrl+T task checklist. Show or hide Claude's own to-do list for multi-step work, so you can see what is pending, in progress, and done at a glance.
Shift+Tab cycle permission modes. Step through the modes, including plan mode. Plan mode is a hidden productivity unlock on its own: Claude reads and analyzes but cannot edit anything until you approve its plan, which stops it from touching critical files before you are ready. You can also jump straight in with the /plan command.
/vim mode. If you live in vim, enable vim-style editing through /config and get modal editing, text objects, and motions right in the prompt input.
Quality and review commands
Before you ship, these commands catch what a tired human reviewer misses.
/diff opens an interactive viewer of your uncommitted changes and lets you browse per-turn diffs, so you can see exactly what changed and when.
/code-review reviews the current diff for correctness bugs and cleanup opportunities. Pass --fix to apply the findings, or run it against a pull request for a deeper multi-agent pass. It is the closest thing to a second engineer reading your work.
/security-review checks the diff specifically for security vulnerabilities, a focused pass that pairs well with a general code review before a merge.
/review gives a fast, read-only, single-pass review of a GitHub pull request when you want a quick signal rather than a deep audit.
Diagnostics and self-improvement
These are the commands you forget exist until something breaks or you want to understand your own habits.
/doctor (alias /checkup) runs a setup checkup that diagnoses installation and configuration problems and can fix them. It catches duplicate installs, PATH issues, broken settings files, and unused skills or MCP servers that are quietly costing you context. Run it when anything feels off, or occasionally as hygiene.
/debug turns on debug logging for the current session and reads back the log to troubleshoot issues, with an optional description to focus the analysis.
/insights generates a report on your own Claude Code sessions: the areas you work in, your interaction patterns, and where you hit friction. It is a mirror for your workflow, and the friction points it surfaces are often things you can fix with a custom command.
/powerup teaches Claude Code features through short interactive lessons with animated demos, which is the friendliest way to discover even more of what the tool can do.
Building your own hidden commands
The real leverage comes when you stop hunting for commands and start making your own. In current Claude Code, custom commands have merged into skills, but the simple form still works exactly as before: drop a Markdown file into .claude/commands/ and its filename becomes a command.
Here is a minimal example. Create .claude/commands/optimize.md containing a single line:
Analyze this code for performance issues and suggest optimizations.Now typing /optimize runs that prompt. Project commands live in .claude/commands/ and get shared with your team through git. Personal commands live in ~/.claude/commands/ and follow you across every project.
A few features turn a one-liner into a genuine tool:
Arguments. Use $ARGUMENTS to capture whatever the user types after the command. A fix-issue.md file with the body Fix GitHub issue $ARGUMENTS following our coding standards turns /fix-issue 123 into a real instruction. You can also grab arguments by position with $0, $1, and so on.
Dynamic context. Prefix a line with a shell command in backticks to run it before Claude ever sees the prompt, and its output gets inlined. A review command that starts with !git diff HEAD hands Claude your actual working changes instead of asking it to guess.
Frontmatter. Add a small YAML block at the top to set an argument-hint for autocomplete, a description so Claude knows when to use it, and allowed-tools to pre-approve specific tools so the command runs without permission prompts.
The moment you notice yourself pasting the same instructions twice, that is the signal to save them as a command.
CLI flags and non-interactive power moves
Not everything happens inside a session. When you launch Claude Code from your terminal, flags let you start it exactly how you want, and they are the backbone of scripting and automation.
claude -p "your prompt" runs in print mode: Claude executes and exits without an interactive session, which is what makes it scriptable in pipelines and git hooks.
--model and --effort set the model and reasoning level at launch, so claude --model opus --effort high starts a heavy session for a hard problem.
--add-dir grants access to extra directories, which is essential for monorepos and multi-repo work. There is also an in-session /add-dir command for the same thing.
--continue and --resume pick up a previous session so you never lose your place between terminal windows.
--debug and --verbose surface what Claude Code is doing under the hood, which is invaluable when a hook or an MCP server is misbehaving.
Flags combine freely, so a single launch like claude --model opus --verbose --add-dir src/ gives you the model, the logging, and the directory access you want in one shot.
Claude Code hidden commands cheat sheet
Command or shortcut | What it does | When to reach for it |
|---|---|---|
| Shows what is filling the context window | A session feels slow or heavy |
| Summarizes history to free space | Context full, same task continues |
| Fresh context, keeps project memory | Switching to a new task |
| Ephemeral side question, no context cost | A quick aside mid task |
| Opens the rewind menu | Undo code and conversation |
| Split or copy the conversation | Trying two approaches |
| Switch model | Match power to the task |
| Set reasoning depth | Save cost or go deeper |
| Show session spend | Track cost on long sessions |
| Run a shell command in context | Quick test or git command |
| Background a running task | Builds, servers, long tests |
| Stop background subagents | A runaway agent |
| Search prompt history | Reuse an earlier prompt |
| Cycle modes, enter plan mode | Analyze before editing |
| Review the diff for bugs | Before you ship |
| Check the diff for vulnerabilities | Before a merge |
| Diagnose and fix setup issues | Something feels broken |
| Analyze your own session patterns | Improve your workflow |
| Your own custom commands | Repeated instructions |
Key takeaways
Learning Claude Code's command layer is less about memorizing a list and more about building a few habits. Compact your context before it overflows, rewind instead of fighting a bad path, switch models by task instead of paying top rates for everything, and save your repeated instructions as commands. Type / to browse and ? for shortcuts whenever you forget. The developers getting the most out of Claude Code are not writing dramatically better prompts. They are using the control layer deliberately.