CLI
The CLI is the most powerful way to use Claude Code. It runs directly in your terminal and gives you full control.
What is Claude Code CLI?
Claude Code CLI is a command-line interface that lets you interact with Claude directly from your terminal. It’s perfect for developers who love working in the terminal and want to integrate AI assistance into their coding workflow.
Installation
Install Claude Code CLI using the installation script:
curl -fsSL https://claude.ai/install.sh | bashAfter installation, verify it’s working:
claude --versionBasic Usage
Start an interactive session
Navigate to your project directory and run:
claudeThis starts an interactive chat session where you can ask Claude to help with your code.
Run a one-off command
You can also pass a prompt directly:
claude "explain what this function does" --file mycode.jsCommon Commands
Initialize a project
Let Claude scan your project for better context:
/initThis helps Claude understand your project structure and saves credits by avoiding repeated context sharing.
Commit changes
After Claude makes changes, commit them:
/commitClaude will generate a meaningful commit message based on the changes.
Clear conversation
Start fresh:
/clearGet help
See all available commands:
/helpAdvanced Features
Working with files
Claude can read, edit, and create files directly:
claude "refactor the authentication logic in auth.js"Running commands
Claude can execute shell commands for you:
claude "install the dependencies and run the dev server"Multi-file operations
Claude can work across multiple files:
claude "update all components to use TypeScript"Pro Tips
Always review Claude’s changes before committing. Use git to track changes and easily revert if needed.
- Use
/initat the start of each session to give Claude context - Be specific in your prompts for better results
- Leverage Claude’s ability to read documentation and error messages
- Use version control (git) so you can safely experiment
Keyboard Shortcuts
Ctrl+C- Cancel current operationCtrl+D- Exit Claude CodeUp/Down arrows- Navigate command history
Configuration
Customize Claude Code by editing ~/.claude/config.json:
{
"model": "claude-sonnet-4.5",
"temperature": 0.7,
"auto_commit": false
}Next Steps
Now that you know the CLI basics, try building something! Check out the platform-specific guides to learn how to build for different platforms.