Skip to content

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.

The main entry point is claude, often aliased as cc. You can pass a prompt directly to it or pipe content from another command.

Terminal window
# Pass a prompt directly
claude "Write a Python function to calculate a factorial"
# Pipe a file for Claude to explain
cat complex_script.js | claude "Explain this code to me"

Common command-line flags:

FlagAliasDescription
--model-mSpecify the model to use (e.g., claude-3-opus-20240229).
--file-fProvide a file or directory as context for the prompt.
--edit-eApply the generated code directly to the specified file(s).
--yes-yAutomatically accept all suggestions without prompting for confirmation.
--configPath to a custom configuration file.

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) or Shift+Enter to add a new line to your prompt without submitting it. Run /terminal-setup for 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).

Slash commands are your shortcuts to productivity within the interactive mode. They allow you to perform specific actions quickly and efficiently.

CommandDescription & Example
/add [file/dir]Adds one or more files/directories to the session context. Ex: /add src/components
/clearClears the conversation history and context, starting a fresh session.
/configOpens 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
/helpDisplays a list of all available slash commands and a brief description of each.
/historyShows the recent conversation history within the current session.
/install-github-appStarts an interactive wizard to help you install the Claude Code GitHub Action.
/loginInitiates the login process for your Anthropic account (not used for Bedrock/Vertex AI).
/lsLists 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.