The Basics
Getting started with Claude Code — installing it, signing in, configuring your editor, feeding it files, and running your first session.
Chapter 1 | The Basics Written for: newcomers who have never used Claude Code — covering every level
How to install Claude Code
Updated September 2026 The recommended way to install has moved from npm to the native installer. The difference that matters most: the native installer updates itself automatically in the background, while Homebrew and WinGet do not — you have to trigger those yourself.
What you need first
| Requirement | Details |
|---|---|
| A terminal | Terminal on macOS/Linux, or PowerShell/CMD on Windows |
| A project | A code folder for Claude to work in |
| An account | Claude Pro, Max, Team or Enterprise / a Claude Console account / or through a supported cloud provider |
Node.js is no longer required, and neither is an API key up front — not on the recommended route.
Route 1 — Native installer (recommended)
# macOS, Linux, WSL
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
If you get The token '&&' is not a valid statement separator, you are in PowerShell, not CMD. If you get 'irm' is not recognized, you are in CMD, not PowerShell. The quick tell is the prompt: PowerShell starts a line with PS C:\, while CMD shows just C:\.
On native Windows, install Git for Windows as well so Claude Code can use the Bash tool. Without it, PowerShell becomes the shell instead. If you are on WSL, you do not need Git for Windows.
Route 2 — Package manager
# macOS — Homebrew
brew install --cask claude-code
# Windows — WinGet
winget install Anthropic.ClaudeCode
Homebrew has two casks. claude-code follows the stable channel, which lags by about a week and skips releases with serious problems. claude-code@latest gets each new release the moment it ships.
Neither of these updates itself. You have to run brew upgrade claude-code or winget upgrade Anthropic.ClaudeCode yourself.
On Debian, Fedora, RHEL and Alpine you can install through apt, dnf or apk as well.
Check the install worked
claude --version
The command prints a version number followed by (Claude Code).
Step 2 — Sign in
Claude Code needs an account before it will run. The simplest route is to run claude on its own and let it take you to browser authentication.
claude
To switch accounts or sign in again later, type /login in an open session.
Accounts that work:
- Claude Pro, Max, Team or Enterprise (recommended)
- A pre-paid Claude Console account, which creates a workspace named “Claude Code” automatically on first login so all your spending is tracked in one place
- Enterprise cloud providers: Amazon Bedrock, Google Cloud Agent Platform and Microsoft Foundry
- A Claude apps gateway your organisation runs itself, where the administrator sets the URL for you and
/loginopens the Cloud gateway page for signing in with your organisation’s SSO
If
ANTHROPIC_API_KEYis set, Claude Code skips the login page and asks you to approve that key instead. This route still works, but it is no longer the recommendation for ordinary use — signing in with an account is easier to manage and leaves no key sitting on your machine.
Once you have signed in successfully the credential is stored, so you never sign in again.
| 3 | Start working Open a terminal, go to the project folder, and run claude |
|---|
cd /path/to/your/project
claude
Steps: Windows (PowerShell)
Windows supports Claude Code through PowerShell directly, or through WSL2.
# Install (no need to run as Administrator)
irm https://claude.ai/install.ps1 | iex
# Sign in with an account — the recommended way
claude
# If you genuinely need an API key, set it for this session only
$env:ANTHROPIC_API_KEY = "sk-ant-api03-xxxxxxxxxxxx"
# Set it permanently in the PowerShell profile
Add-Content $PROFILE '$env:ANTHROPIC_API_KEY = "sk-ant-api03-xxxx"'
💡 Install Git for Windows too
It lets Claude Code use the Bash tool. Without it, PowerShell becomes the shell instead. Download it at git-scm.com/downloads/win
Route 2 — Installing through WSL2 on Windows
WSL2 (Windows Subsystem for Linux) gives the closest thing to Linux you can get on Windows. Recommended for developers working with a Linux stack
# 1. Open PowerShell as Administrator and install WSL2
wsl --install
# 2. Restart the machine, then open Ubuntu from the Start Menu
# 3. Update packages
sudo apt update && sudo apt upgrade -y
# 4. Install Claude Code (Node.js is no longer a prerequisite)
curl -fsSL https://claude.ai/install.sh | bash
💡 Reaching Windows files from WSL2
Windows files live under /mnt/c/Users/name/ — for example cd “/mnt/c/Users/John/Projects/myapp” and then run claude
Route 3 — Installing in a Docker container
Suited to teams that want one standard environment, or to use in a CI/CD pipeline.
# Example Dockerfile
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y curl ca-certificates git && curl -fsSL https://claude.ai/install.sh | bash
WORKDIR /workspace
# Build and run
docker build -t claude-code .
docker run -it -e ANTHROPIC_API_KEY="sk-ant-..." \
-v $(pwd):/workspace claude-code claude
An example install on VS Code
VS Code is the most popular code editor there is, and Claude Code works with it very well — through both the built-in terminal and an extension.
Method 1 — Through the integrated terminal (the simplest)
No extension to install. Use the terminal VS Code already has.
| 1 | Open a terminal in VS Code Press Ctrl+` (backtick) or go to View → Terminal |
|---|
| 2 | Navigate to the project folder If you opened the folder through VS Code, the terminal is already there |
|---|
# Check you are in the right folder
pwd
# Start Claude Code
claude
| 3 | Start working together Give Claude instructions in the terminal below while you edit code in the window above |
|---|
💡 The split terminal trick
Press Ctrl+Shift+5 to split the terminal into two panes — run Claude Code on the left, run your program or watch logs on the right
Method 2 — Install an extension
Extensions exist that make Claude Code smoother to use. Search the VS Code Marketplace:
| Extension | Publisher | Notable feature |
|---|---|---|
| Claude Code (Official) | Anthropic | Connects to Claude Code directly, with a sidebar UI |
| Continue | Continue.dev | Supports several LLMs, Claude among them, through the API |
| Cursor | Cursor | A separate IDE with Claude built in |
Installing the extension
Press Ctrl+Shift+X to open the Extensions panel
Type “Claude” in the search box
Pick the extension you want and press Install
Press Reload Window so the extension takes effect
Open the extension and enter your API key in its settings
💡 Use claude —add-dir
Run claude —add-dir /path/to/project to give Claude a folder outside the current working directory
Model selection
Claude Code supports several models, so you can pick the one that suits the job. Choosing the right model saves money and gets more done.
Supported models and what they are for
Use an alias rather than a full model name. An alias always points at the newest model in that line, so you write it once and it does not go stale when a new release lands.
| Alias | Suited to |
|---|---|
fable | The hardest and longest-running work |
best | The newest model your account can reach |
opus | Work that needs complex reasoning |
sonnet | Everyday coding |
haiku | Simple work repeated a lot |
opusplan | Opus while planning, then a switch to Sonnet for the work itself |
sonnet[1m] / opus[1m] | Opens a 1-million-token context window for long sessions and large codebases |
If you really do want to pin a version, the full names supported as of September 2026 are claude-fable-5-1, claude-fable-5, claude-opus-5, claude-sonnet-5, claude-opus-4-8, claude-opus-4-7, claude-opus-4-6, claude-sonnet-4-6, claude-sonnet-4-5 and claude-haiku-4-5
Pricing The official documentation does not publish per-token prices on the model settings page, but prices do appear in the
/modelpicker when Claude Code talks to the Anthropic API directly. Outside providers such as Amazon Bedrock set their own prices, so those rows in the picker show no price at all — do not take a price from any guide; read it from the real picker or from the provider’s pricing page
How to choose a model
Method 1: Specify it on the command line
# Use the account default
claude
# Specify with an alias
claude --model opus
claude --model sonnet
claude --model haiku
# Open the 1-million-token context
claude --model sonnet[1m]
Method 2: Set an environment variable
# The recommended variable (needs Claude Code v2.1.236 or later)
export ANTHROPIC_DEFAULT_MODEL="sonnet"
# Add it to .zshrc or .bashrc to make it permanent
echo 'export ANTHROPIC_DEFAULT_MODEL="sonnet"' >> ~/.zshrc
The older ANTHROPIC_MODEL still works. The order of precedence is --model first, then ANTHROPIC_MODEL, then the model value in a settings file — including whatever /model saved — and finally the organisation default. ANTHROPIC_DEFAULT_MODEL takes effect only when none of the above sets anything.
Method 3: Change model mid-session
While Claude Code is running, type /model to see the models and switch straight away.
💡 A rule of thumb for choosing
Always start with Sonnet. Move to Opus only when Sonnet cannot answer, or the work is genuinely complex. Use Haiku for batch processing and CI/CD work
⚠️ Watch out for model looping
If Claude repeats itself or gets stuck on the same problem, switch to Opus for a while. Opus reasons more deeply and often solves what Sonnet is stuck on
Configuring your editor
Claude Code can connect to the code editor you already use, so it opens files and shows diffs (the differences in the code) automatically
Set the default editor
# See the current editor
claude config get editor
# Set it to VS Code
claude config set editor "code"
# Set it to Cursor
claude config set editor "cursor"
# Set it to Vim
claude config set editor "vim"
# Set it to Neovim
claude config set editor "nvim"
Configuring through settings.json
The main settings file is at ~/.claude/settings.json and you can edit it directly.
{
"editor": "code",
"model": "sonnet",
"autoApproveEdits": false,
"theme": "dark",
"notifications": true
}
| editor | The program that opens files, such as code, cursor, vim, nano |
|---|---|
| model | The default model, which can be given as an alias such as sonnet |
| autoApproveEdits | true = approve edits automatically (careful!), false = ask every time |
| theme | UI theme colour: dark or light |
| notifications | Show a notification when work finishes |
Configuring the diff view
When Claude edits a file it shows you a diff of the change before you approve it, and you can have that diff open in your editor.
# Open diffs in VS Code
claude config set diffTool "code --diff"
# Or use vimdiff
claude config set diffTool "vimdiff"
Giving files to Claude Code
Claude Code can read and analyse files in several ways, from naming a path directly to handing over several files at once.
Method 1 — Reference a file with @ in the prompt
The simplest and most direct way. Type @ followed by the file path.
# Read one file
> explain the code in @src/utils/auth.js
# Read several files at once
> compare @old_api.py with @new_api.py and tell me how they differ
# Read and give an instruction at the same time
> fix the bug in @src/components/Login.tsx where validation does not run
Method 2 — Reference file paths in a one-shot prompt
Correction (updated 2026-09) The previous edition told you to use a
--fileflag. That flag does not exist. Put the path in the prompt text instead, and allow theReadtool.
# One file
claude -p "summarise report.pdf for me" --allowedTools "Read"
# Several files
claude -p "review the code in api.py and test_api.py" --allowedTools "Read"
Method 3 — Pipe content straight into Claude
# Send file contents through a pipe
cat error.log | claude -p "analyse these errors"
# Send the output of another command
git diff HEAD~1 | claude -p "write a commit message for me"
# Send output from a command
npm test 2>&1 | claude -p "fix the failing tests"
Supported file types
| Type | Extensions | Notes |
|---|---|---|
| Code | .py .js .ts .go .java .cpp .rs .rb | Every programming language is supported |
| Documents | .md .txt .rst .csv | Can be read and analysed |
| Config | .json .yaml .toml .env | Can be inspected and edited |
| Logs | .log .out | Errors can be analysed |
| Images | .png .jpg .gif .webp | Claude 3+ can read them (vision) |
💡 Hand over a whole folder
Type @src/ to have Claude read every file in the folder, but be careful with very large folders — they can fill the context. Name only the files that matter
Having Claude Code search the internet
Claude Code can search the internet through an MCP browser tool and web search, which keeps the information it works from current.
Method 1 — Web search through MCP
Install an MCP browser server first; after that Claude searches on its own whenever you ask.
Installing an MCP browser server
# The recommended way: let claude write the settings file for you
claude mcp add --transport stdio browser -- npx @playwright/mcp
# If you write it yourself, put it in .mcp.json at the project root
# (MCP is not configured in settings.json — see the scopes section in Chapter 2)
{
"mcpServers": {
"browser": {
"command": "npx",
"args": ["@playwright/mcp"]
}
}
}
Examples
# Once the MCP browser is installed, just ask
> find out what new features Next.js 15 has
> open https://docs.anthropic.com and summarise the latest API for me
> find a fix for the error "Cannot read properties of undefined" in React 18
Method 2 — Brave Search MCP
The Brave Search API gives good results and is more privacy-friendly. It needs a Brave Search API key.
# Add to ~/.claude/settings.json
{
"mcpServers": {
"brave-search": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
"env": {
"BRAVE_API_KEY": "BSA-xxxxxxxxxxxxxxxxxx"
}
}
}
}
# Sign up for a Brave API key at brave.com/search/api/
Method 3 — Fetch a URL directly
If you want Claude to read one particular page, no extra MCP is needed — just ask.
# Ask Claude to fetch a URL directly
> read and summarise the content at https://react.dev/blog/2024/04/25/react-19
> compare the documentation at
https://docs.python.org/3/library/asyncio.html
with https://anyio.readthedocs.io/
💡 Check whether MCP is running
Run /mcp in Claude Code to see which MCP servers are connected. If browser shows green, it is ready to search
Having Claude Code search files on your machine
Claude Code can search and analyse files on your machine directly, through both built-in tools and an MCP filesystem server.
Searching with the built-in file tools
Claude Code ships with file-search tools; there is nothing extra to install.
# Find files by name
> find every file named config.json in this project
# Find code containing a specific word
> find the function named "getUserById" in this project
# Search by pattern
> find every file that imports from "@/components/ui"
# Analyse the structure
> show me the full folder structure of this project
Installing an MCP filesystem server (search the whole machine)
To search outside the folder you have open, or across several folders at once, install MCP Filesystem.
# Add to .mcp.json at the project root (not settings.json)
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/john/Projects",
"/Users/john/Documents"
]
}
}
}
# List the folders you want Claude to be able to reach
MCP Filesystem examples
# Search across projects
> find every .env file in the Projects folder
# Compare projects
> compare the package.json of ProjectA and ProjectB
# Search for a pattern across the machine
> find the function named "sendEmail" in every .ts file under /Projects
Using ripgrep (rg) with Claude
ripgrep is a very fast text search tool, and you can use it with Claude through the Bash tool.
# Install ripgrep
# macOS: brew install ripgrep
# Ubuntu: sudo apt install ripgrep
# Ask Claude to search with rg
> use rg to find every "TODO" in this project and summarise them for me
> find every async function in src/ and review whether the error handling is complete
💡 Ask for something specific
Tell Claude exactly what you want found — “find every TODO that is still unfixed” or “find console.log calls someone forgot to remove” — and Claude picks the right tool itself
Driving Claude Code by voice
Claude Code accepts spoken instructions through speech-to-text, which makes the work easier — particularly when the explanation you need to type is a long one
Method 1 — Use your OS voice system
macOS: Dictation
| 1 | Turn on Dictation Go to System Settings → Keyboard → Dictation and switch on Enable Dictation |
|---|
| 2 | Set a shortcut Choose a shortcut, such as pressing fn twice or holding fn down |
|---|
| 3 | Use it Click the Claude Code input field, press the shortcut, speak your instruction, and press Enter when done |
|---|
# An example of something spoken and sent to Claude
> "write a function to validate an email address,
make it support Thai domains too, and include unit tests"
Windows: Windows Speech Recognition
# Turn on Windows Speech Recognition
1. Press Win + H to open Voice Typing
2. Or search for "Speech Recognition" in Settings
3. Click the Claude Code window, press Win + H, and speak
Method 2 — WhisperKit or Whisper (recommended)
OpenAI Whisper is a very accurate speech-to-text model with good Thai support, and its output pipes straight into Claude.
# Install Whisper
pip install openai-whisper
# Install ffmpeg (required)
# macOS: brew install ffmpeg
# Ubuntu: sudo apt install ffmpeg
# Record audio and turn it into a prompt
# 1. Record audio (5 seconds)
rec -r 16000 -c 1 command.wav trim 0 5
# 2. Transcribe it and send it to Claude
whisper command.wav --language Thai --model medium | \
grep -oP "(?<=text: ).*" | claude -p -
Method 3 — Use a voice input app
Some apps are built for voice-to-Claude specifically, and are easier than writing a script.
| App / tool | Platform | How you use it |
|---|---|---|
| SuperWhisper | macOS | Press a shortcut, speak, paste the result |
| Whisper Dictation | macOS/Windows | A menu-bar app; press the hotkey and speak |
| Voice Control | macOS | Built into macOS, with Thai support |
| Talon Voice | Every platform | Advanced voice control for developers |
An example voice + Claude Code workflow
Press the hotkey to open the microphone
Say: “build a login API endpoint using a JWT token, and write tests too”
The system transcribes the speech automatically
The text lands in the Claude Code input field
Press Enter to send it
💡 Speaking so it works
Speak slowly and clearly, pronounce technical loanwords in English — say “function” rather than a transliteration — and always give the context first, as in “in a Next.js TypeScript project, create…”
Glossary for this chapter
| Node.js | A runtime for running JavaScript on your machine, outside a web browser |
|---|---|
| npm | Node Package Manager, the package manager for JavaScript |
| nvm | Node Version Manager, a tool for handling several Node.js versions |
| API Key | A secret code for reaching an AI service; keep it secret and never put it in code |
| WSL2 | Windows Subsystem for Linux 2, which runs Linux on Windows |
| MCP | Model Context Protocol, the standard for connecting AI to external tools |
| Diff | The difference between two versions of a file, showing what was added, removed or changed |
| Context Window | The largest amount of information the AI can take in at once (200K tokens) |
| Speech-to-Text | Technology that turns spoken words into text |
| Whisper | A speech-to-text model from OpenAI, supporting many languages including Thai |
| ripgrep (rg) | A very fast text search tool, far faster than grep |
| Environment Variable | A system variable holding config values, read by a program at startup; safer than putting them in code |
| One-shot Mode | Running Claude Code once and done with claude -p, without opening an interactive session |