Claude Code CLI Guide
Everything you need to use Claude Code from the PowerShell console. Commands, workflows, and key differences from Claude Desktop.
📥 Installation
Open PowerShell and run this single command to install Claude Code:
# Install Claude Code on Windows
irm https://claude.ai/install.ps1 | iexpowershell
Alternative installation methods:
# With WinGet
winget install Anthropic.ClaudeCode
# With Homebrew (if you use it)
brew install --cask claude-code
# Update to the latest version
claude updatepowershell
💻 Commands from PowerShell
These commands are typed directly in the terminal, before starting a Claude session.
| Command | What it does |
|---|---|
claude | Start an interactive session in the current directory |
claude "your task" | Start a session with a predefined task |
claude -p "question" | Quick mode: answer and exit (non-interactive) |
claude -c | Continue the most recent saved conversation |
claude -r | Show conversation history to resume a past session |
claude update | Update Claude Code to the latest version |
claude doctor | Diagnose your installation and configuration |
Practical examples
# Navigate to your project first
cd C:\Users\YourName\Projects\my-project
# Start Claude
claude
# Quick question without opening a session
claude -p "what does this function do?"
# Continue where you left off yesterday
claude -c
# Resume a specific session from history
claude -rpowershell
⚙ Slash Commands (inside Claude)
These commands are typed while Claude is already running, during an interactive session.
Navigation & session
| Command | What it does | When to use it |
|---|---|---|
/help | Show all available commands | When you're lost or exploring |
/clear | Start a new conversation (saves the current one) | When starting a new task |
/resume | Return to a previous conversation | To pick up pending work |
/exit | Close the Claude session | When you're done |
/context | Show how much of the context window is used | On large projects |
/compact | Compress the conversation to free up space | When context is nearly full |
/login | Re-authenticate or switch accounts | When changing Claude accounts |
Code & changes
| Command | What it does | When to use it |
|---|---|---|
/plan | Planning mode before making large changes | Before big refactors or features |
/diff | Review proposed changes before approving | Before accepting any modification |
/code-review | Ask Claude to review your code | Before committing |
/rewind | Roll back to an earlier point in the session | If something went wrong |
/branch | Fork the conversation to explore alternatives | When trying different approaches |
Configuration
| Command | What it does |
|---|---|
/model | Switch the Claude model (Sonnet, Opus, Haiku) |
/effort [level] | Set reasoning depth: low / medium / high / max |
/debug | Enable detailed logging for troubleshooting |
Tab inside Claude to autocomplete commands. For example: /c + Tab suggests /clear or /code-review.
🏴 Flags & Options
These options are added to the claude command when launching from PowerShell.
| Flag | Description |
|---|---|
-p "text" | Non-interactive mode: answer and exit |
-c | Continue the last conversation |
-r "name" | Resume a session by name |
--effort high | Reasoning level: low / medium / high / max |
--model opus | Specify the model to use |
--permission-mode acceptEdits | Auto-approve all changes without prompting |
--max-budget-usd 2.00 | Cap spending in USD per session |
# Complex task with deep reasoning
claude --effort high "optimize these SQL queries"
# Use Opus for very complex tasks
claude --model opus "refactor the entire authentication layer"
# Auto mode (careful: approves everything without asking)
claude --permission-mode acceptEditspowershell
🏃 Basic Workflow
Here's what a typical Claude Code session looks like from scratch:
📄 Working with Your Code
Claude Code automatically reads files from your project — no manual uploads needed.
Exploring the project
# Inside Claude, type in plain language:
what does this project do?
explain the folder structure
what technologies does it use?
where is the main entry point?claude
Making code changes
# Claude finds the file, shows the change, and asks for approval
add a function that validates email addresses to utils.js
create a reusable button component
add error handling to all API callsclaude
Multi-file changes
# Claude coordinates changes across multiple files automatically
add input validation to the registration form,
update both the frontend and the backendclaude
CLAUDE.md file at the root of your project with instructions, architecture notes, and coding standards. Claude reads it automatically at the start of every session.
🍀 Git Integration
You can ask Claude to perform Git operations in plain language:
# View changes and status
what files have I modified?
show me the last 5 commits
# Commits
commit my changes with a descriptive message
# Branches
create a new branch called feature/auth-redesign
switch to the develop branch
# Code review before committing
/code-reviewclaude
🚀 PowerShell Pipes & Automation
One of the CLI's biggest advantages is chaining commands through the PowerShell pipeline:
# Analyze the last lines of a log
Get-Content app.log -Tail 100 | claude -p "what errors are here?"
# Summarize test failures
npm test 2>&1 | claude -p "summarize failures and suggest fixes"
# Auto-generate a README
claude -p "generate a README.md for this project" > README.md
# Run tests and commit if they pass
claude "run the tests and commit if they pass"
# Scan specific code for issues
Get-Content src/auth.js | claude -p "look for security vulnerabilities"powershell
⚖ CLI vs Claude Desktop (GUI)
▶ Claude Code CLI (PowerShell)
- Text-based interaction in the console
- Review changes with
/diffin terminal - One session per terminal window
- Approve with
y/n - Ideal for scripting and automation
- Chain with PowerShell pipelines
- Fully keyboard-driven
- Lightweight and quick to launch
👁 Claude Desktop (GUI)
- Visual, intuitive chat interface
- Side-by-side visual diffs
- Multiple parallel tabs
- Approve / reject buttons
- Better for visual change review
- Visual context usage meter
- More beginner-friendly interface
- System notifications
CLAUDE.md files are shared between CLI and Desktop. You can start in the console and continue in the GUI, or vice versa.
⚡ Quick Reference
Everything essential at a glance:
| What you want to do | Command |
|---|---|
| Start Claude in my project | cd project && claude |
| Quick question without a session | claude -p "question" |
| Continue where I left off | claude -c |
| Browse session history | claude -r |
| See all commands | /help |
| Start a new task | /clear |
| Review changes before approving | /diff |
| Review code before committing | /code-review |
| Plan large changes | /plan |
| Check context usage | /context |
| Free up context space | /compact |
| Undo recent changes | /rewind |
| Close Claude | /exit or Ctrl+D |
| Diagnose installation | claude doctor |
| Update Claude Code | claude update |
💡 Context Tips
Claude has a context limit (session memory). For large projects:
| Situation | Solution |
|---|---|
| Very long conversation, want to keep going | /compact — summarizes without losing the thread |
| Want a fresh start but keep history | /clear — saves the current session for /resume |
| Check how much space is left | /context |
| Want Claude to remember your project rules | Create a CLAUDE.md file at the project root |
Keyboard shortcuts inside Claude
| Key | Action |
|---|---|
Tab | Autocomplete slash commands |
Shift+Tab | Cycle permission modes when approving changes |
↑ (up arrow) | Recall previous prompts in the session |
Ctrl+D | Exit Claude (same as /exit) |
Ctrl+C | Cancel the current operation |