Type / in a session and it lists the commands available to you. Type ? on an empty line and you get the shortcuts. Some commands don't show up, depending on your plan and platform.
Starting a session
| Command | What it does |
|---|---|
claude | Opens an interactive session. |
claude "explain this project" | Opens the session with this first message. |
claude -c | Continues the last conversation in this folder. |
claude -r | Opens the session list. Give it a name or ID and it goes back to that session. |
claude -p "explain this function" | Writes the answer and exits. This is how you run it in a script and in CI. |
cat logs.txt | claude -p "explain" | Hands Claude the output of another command. |
claude --model sonnet | Opens just this session with the model you pick. |
claude --permission-mode plan | Opens in plan mode, and Claude doesn't change any file until you approve. |
claude -w feature-auth | Opens in a separate git worktree, so the work in two terminals doesn't get mixed up. |
claude update | Updates to the latest version. |
Inside a session
A command only works at the start of the message. The text you write after it becomes its argument.
| When | Command | What it does |
|---|---|---|
| First session in a repo | /init | Reads the code and writes the first CLAUDE.md. If the file exists, it suggests improvements. |
/permissions | Shows the allow, ask and deny rules and lets you add and remove them. | |
| While the work is going | /plan | Switches to plan mode. Write a task after it and it starts with that. |
/model | Changes the model and makes it the default. For this session only, press s in the list. | |
/context | Shows what's filling up the context. | |
/compact | Summarizes the conversation to free up room. You can write what the summary should focus on. | |
/btw | You ask a side question, and it doesn't get added to the conversation history. | |
| Before opening a PR | /diff | Shows the changes you haven't committed, the ones Claude made included. |
/code-review | Looks for correctness bugs in the diff, and --fix applies the findings. /review is the same command. | |
/security-review | Looks for security vulnerabilities in the changes on your branch. | |
| Between sessions | /clear | Opens a new conversation with an empty context. CLAUDE.md and auto memory stay. You go back to the old one with /resume. |
| When something goes wrong | /rewind | Rolls the code and the conversation back to a checkpoint. |
/doctor | Finds installation and settings problems, and fixes them if you approve. |
For a command of your own, write the file .claude/skills/deploy/SKILL.md and the command shows up as /deploy. A file in the older format, .claude/commands/deploy.md, creates the same command too.
Keyboard shortcuts
| Shortcut | What it does |
|---|---|
Esc | Stops Claude. The work it did stays, and you can change direction. |
Enter while Claude is working | Your message joins the queue without interrupting the work. |
Esc twice | Clears the text on the line, and the up arrow brings it back. If the line is empty, it opens the rewind menu. |
Ctrl+C | Interrupts the running work. When idle, the first press clears the line and the second one exits. |
Shift+Tab | Changes the permission mode. It cycles through Manual, acceptEdits and plan, and if they're turned on, bypassPermissions and auto are in the cycle too. |
| Up arrow | Brings back your earlier messages, old sessions of the same project included. |
Ctrl+R | Searches your old messages. |
Ctrl+S | Puts what you typed aside and brings it back on an empty line. |
Ctrl+V | Adds the image on the clipboard to the message. In iTerm2 it's Cmd+V, on Windows Alt+V. |
Ctrl+B | Sends the running command to the background. In tmux, press it twice. |
\ and Enter | Starts a new line, and works in every terminal. |
Start the line with ! and the command runs in the shell, with its output going into the conversation. Type ! npm test and Claude explains the failing tests without waiting for a second message. Type @ and the file path autocompletes, and the file you pick gets added to the message.
CLAUDE.md and auto memory
Two things carry information from one session to the next, the CLAUDE.md you write and the auto memory Claude keeps on its own.
Project rules sit in CLAUDE.md in the root directory and reach the team once you commit it. Preferences that apply to all your projects go in ~/.claude/CLAUDE.md. For project notes that are yours alone, create CLAUDE.local.md and add it to .gitignore.
Keep every CLAUDE.md under 200 lines. The longer it gets, the more room it takes up and the less Claude follows the rules. Write each rule so it can be checked, like "use 2-space indentation" instead of "format the code properly".
These files are read as context, and nothing enforces a ban written in them. Work that has to be blocked whatever Claude decides goes into the deny list below or into a PreToolUse hook.
If you tell Claude to remember something like "always use pnpm instead of npm", it writes that into auto memory. If you want it in CLAUDE.md, say "add this to CLAUDE.md", or open the file with /memory and edit it yourself.
To see which files are loaded, type /context and look at the Memory files list.
Permissions
What Claude can do without asking you sits under the permissions key in settings.json.
| File | Who it affects |
|---|---|
~/.claude/settings.json | You, in all your projects on this machine |
.claude/settings.json | Everyone working on the project, once it's committed to the repo |
.claude/settings.local.json | Only you, only in this project |
Add the example below to ~/.claude/settings.json and the lint and test commands in the allow list run without asking you. The deny list stops Claude from reading .env files.
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run test *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)"
]
}
}
Once you save, type /status and you'll see the file loaded in the Setting sources line.
A comment written with // or a trailing comma counts as an error in the settings file, and Claude Code shows a Settings Error the next time it opens. If you'd rather not touch the JSON, type /update-config and describe the change you want.
If you get a lot of permission prompts, run /fewer-permission-prompts. It builds an allow list from the read-only commands that ran often in your past sessions and adds it to the project's .claude/settings.json file. Look at the diff before you commit it.
The allow rules in .claude/settings.json stay on hold until each teammate confirms they trust the folder. The deny rules apply from the first session.
Hooks
A hook is a shell command Claude Code runs by itself at certain moments. Put work that has to happen every time into a hook. This example runs the file Claude edited through Prettier, and it needs jq installed. Add it to .claude/settings.json, and it shows up under PostToolUse when you type /hooks.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
}
]
}
]
}
}
This hook runs after the edit is done, so it can't stop the edit. To block something, write a separate hook under PreToolUse and have the command exit with exit 2 only in the case you want blocked. Claude Code then doesn't do the work, and it passes the reason you wrote to stderr on to Claude.
Common workflows
Writing tests
First have Claude find the functions that have no tests, then have it write tests for them. Say plainly which behavior you want checked. Claude follows the style and the framework of the tests already in the repo. Make your last message "run the new tests and fix the ones that fail".
Opening a PR
Tell Claude "open a PR for my changes". Before you send it to your team for review, read the PR and ask Claude about possible risks. A PR Claude opens is linked to the session, and claude --from-pr 123 lists that PR's sessions later on.
Review
/code-review looks for correctness bugs in the new commits on your branch and in your uncommitted changes. It runs in a separate subagent, so it doesn't fill up your conversation. --fix applies the findings to the code. Give it a PR number like /code-review 1234 and it reviews that PR.
Sources
The commands and shortcuts were taken from these pages.