Power User's Guide: CLI and Interactive Mode Reference
Power User’s Guide: CLI and Interactive Mode Reference
Section titled “Power User’s Guide: CLI and Interactive Mode Reference”Become a master of the command line. This chapter is your go-to resource for quickly finding the right command, flag, or keyboard shortcut for any situation. We’ll cover the full CLI, the interactive session, and the powerful slash commands that unlock advanced functionality.
Full CLI Reference
Section titled “Full CLI Reference”The main entry point is claude, often aliased as cc. You can pass a prompt directly to it or pipe content from another command.
# Pass a prompt directlyclaude "Write a Python function to calculate a factorial"
# Pipe a file for Claude to explaincat complex_script.js | claude "Explain this code to me"Common command-line flags:
| Flag | Alias | Description |
|---|---|---|
--model | -m | Specify the model to use (e.g., claude-3-opus-20240229). |
--file | -f | Provide a file or directory as context for the prompt. |
--edit | -e | Apply the generated code directly to the specified file(s). |
--yes | -y | Automatically accept all suggestions without prompting for confirmation. |
--config | Path to a custom configuration file. |
Nuances of the Interactive Mode
Section titled “Nuances of the Interactive Mode”Running claude without any arguments drops you into an interactive session. This mode is a powerful, stateful environment where Claude remembers the context of your conversation, including files you’ve discussed and code you’ve generated. It’s ideal for iterative development, debugging, and complex problem-solving.
- Session History: Use the Up and Down arrow keys to navigate through your command history for the current session.
- Multi-line Input: On most terminals, you can use
Option+Enter(macOS) orShift+Enterto add a new line to your prompt without submitting it. Run/terminal-setupfor better integration. - Permission Modes: Cycle through different execution modes with
Shift+Tab. Modes include ‘Normal’ (asks for confirmation), ‘Plan Mode’ (shows a plan before execution), and ‘Auto-Accept’ (executes commands without confirmation).
Complete Slash Commands Reference
Section titled “Complete Slash Commands Reference”Slash commands are your shortcuts to productivity within the interactive mode. They allow you to perform specific actions quickly and efficiently.
| Command | Description & Example |
|---|---|
/add [file/dir] | Adds one or more files/directories to the session context. Ex: /add src/components |
/clear | Clears the conversation history and context, starting a fresh session. |
/config | Opens the user settings file in your default editor for modification. |
/edit [file] | Instructs Claude that the next prompt should modify the specified file. Ex: /edit package.json |
/help | Displays a list of all available slash commands and a brief description of each. |
/history | Shows the recent conversation history within the current session. |
/install-github-app | Starts an interactive wizard to help you install the Claude Code GitHub Action. |
/login | Initiates the login process for your Anthropic account (not used for Bedrock/Vertex AI). |
/ls | Lists the files and directories currently included in the session context. |
/rm [file] | Removes a file or directory from the session context. Ex: /rm dist/bundle.js |
/run [command] | Executes a shell command and adds its output to the conversation context. Ex: /run npm install |
/test [prompt] | Asks Claude to generate a test for the code currently in context based on the prompt. |