Skip to content

Basic Commands

Claude Code understands natural language, but knowing these patterns will make you more effective.

Terminal window
# Start interactive mode in current directory
claude
# Start with a specific task
claude "explain this codebase"
# Print mode - get answer and exit
claude --print "what does main.py do"
# Use a specific model
claude --model opus

Just type naturally. Claude understands context:

> what does this function do?
> why is this test failing?
> how does authentication work in this project?
> what's the database schema?

Tell Claude what you want changed:

> fix the bug in the login function
> add input validation to the API endpoint
> refactor this class to use dependency injection
> rename all instances of 'user_name' to 'username'

Claude can execute shell commands:

> run the tests
> start the development server
> install the requests package
> check git status

Claude will show you the command and ask for permission before executing.

Use @ to reference files directly in your prompt:

@src/main.py explain this file
Compare @src/v1/api.py and @src/v2/api.py - what changed?

Paths are relative to project root. Use @./ for current directory or @../ for parent.

Start a line with ! to run shell commands. Output is added to context:

!git status
!npm test
!git diff HEAD~1

The ! only works at the start of a line, not inline. After running a command, reference its output in your next prompt.

Two-step example:

!npm test

Then:

Based on @src/api/routes.py fix the failing tests shown above

For complex tasks, use plan mode by pressing Alt+M to cycle through modes until you reach plan mode:

> add a user registration feature

Claude will:

  1. Ask clarifying questions
  2. Create a detailed plan
  3. Wait for your approval before executing
CommandDescription
/helpShow all available commands
/modelSwitch models
/clearClear conversation history
/compactSummarize and compact the conversation
/configView or modify settings
> /clear # Start fresh
> /compact # Summarize context to save tokens

Claude can read and write files:

> show me the contents of config.py
> create a new file called utils.py with helper functions
> delete the temp files in the build directory
> move the tests to a tests/ folder

Claude can search your codebase:

> find all usages of the deprecated API
> search for TODO comments
> where is the database connection defined?
> find all files that import the auth module

Claude understands Git:

> what changed in the last commit?
> show me the diff for app.py
> create a commit message for my changes
> which files have I modified?
ShortcutAction
Ctrl+CCancel current operation
Ctrl+DExit Claude Code
/ Navigate command history
TabAuto-complete commands and paths
Shift+TabToggle permission modes (default/auto-accept)
Alt+MCycle through modes (normal/plan)
Shift+EnterInsert newline (multi-line input)
Esc EscOpen rewind menu
Ctrl+OToggle transcript mode (show thinking)
Ctrl+BBackground current operation