◆ Official Reference

Claude Code CLI Guide

Everything you need to use Claude Code from the PowerShell console. Commands, workflows, and key differences from Claude Desktop.

Windows / PowerShell Claude Code CLI Git Integration July 2026

📥 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
Windows Note If you have Git for Windows installed, Claude Code will use Bash as its shell. Otherwise, it uses PowerShell. On WSL, Git for Windows is not required.

💻 Commands from PowerShell

These commands are typed directly in the terminal, before starting a Claude session.

CommandWhat it does
claudeStart 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 -cContinue the most recent saved conversation
claude -rShow conversation history to resume a past session
claude updateUpdate Claude Code to the latest version
claude doctorDiagnose 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

CommandWhat it doesWhen to use it
/helpShow all available commandsWhen you're lost or exploring
/clearStart a new conversation (saves the current one)When starting a new task
/resumeReturn to a previous conversationTo pick up pending work
/exitClose the Claude sessionWhen you're done
/contextShow how much of the context window is usedOn large projects
/compactCompress the conversation to free up spaceWhen context is nearly full
/loginRe-authenticate or switch accountsWhen changing Claude accounts

Code & changes

CommandWhat it doesWhen to use it
/planPlanning mode before making large changesBefore big refactors or features
/diffReview proposed changes before approvingBefore accepting any modification
/code-reviewAsk Claude to review your codeBefore committing
/rewindRoll back to an earlier point in the sessionIf something went wrong
/branchFork the conversation to explore alternativesWhen trying different approaches

Configuration

CommandWhat it does
/modelSwitch the Claude model (Sonnet, Opus, Haiku)
/effort [level]Set reasoning depth: low / medium / high / max
/debugEnable detailed logging for troubleshooting
Tip: Autocomplete Press 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.

FlagDescription
-p "text"Non-interactive mode: answer and exit
-cContinue the last conversation
-r "name"Resume a session by name
--effort highReasoning level: low / medium / high / max
--model opusSpecify the model to use
--permission-mode acceptEditsAuto-approve all changes without prompting
--max-budget-usd 2.00Cap 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:

1
cd C:\...\my-project
Navigate to your project
2
claude
Start Claude Code
3
"what does this project do?"
Ask in plain language
4
"add validation to the login"
Request a specific change
5
/diff
Review proposed changes
6
y (Enter)
Approve the changes
7
"commit with a good message"
Claude runs git commit
8
/exit
Close the session
The key mindset shift Instead of clicking buttons, you describe what you want in plain language. Claude explores the code on its own and always asks for your approval before modifying files.

📄 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 — Your instruction file Create a 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 /diff in 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
They are the same Claude Code Settings, conversation history, and 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 doCommand
Start Claude in my projectcd project && claude
Quick question without a sessionclaude -p "question"
Continue where I left offclaude -c
Browse session historyclaude -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 installationclaude doctor
Update Claude Codeclaude update

💡 Context Tips

Claude has a context limit (session memory). For large projects:

SituationSolution
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 rulesCreate a CLAUDE.md file at the project root
Useful keyboard shortcut Press Shift+Tab when Claude asks for approval to cycle through permission modes: always ask, accept edits, accept everything automatically.

Keyboard shortcuts inside Claude

KeyAction
TabAutocomplete slash commands
Shift+TabCycle permission modes when approving changes
↑ (up arrow)Recall previous prompts in the session
Ctrl+DExit Claude (same as /exit)
Ctrl+CCancel the current operation