How to use Claude Code in terminal — Windows, macOS, and Linux

To use Claude Code in a terminal, install the claude command-line tool, open your project folder in the terminal, type claude and describe the coding task in plain English.

This guide covers installation on Windows, macOS and Linux, the first sign-in, your first session, code changes, Git, the commands worth knowing, CLAUDE.md project memory and fixes for common errors.

How to use Claude Code in terminal — Windows, macOS, and Linux
The native installer script sets up the claude binary, and claude –version confirms the install worked. (Image: Microsoft)

How to use Claude Code in terminal

Claude Code is Anthropic's agentic coding tool. It reads your codebase, edits files, runs commands and works with your development tools, all from a terminal prompt.

  1. Install Claude Code: on macOS, Linux, WSL or Git Bash run curl -fsSL https://claude.ai/install.sh | bash; in Windows PowerShell run irm https://claude.ai/install.ps1 | iex.
  2. Run claude --version to confirm the claude command is on your PATH.
  3. Change to your project folder, for example cd your-project.
  4. Type claude and press Enter to start an interactive session.
  5. Sign in with your Claude account or API billing account when Claude Code asks for it.
  6. Type a request such as "Summarize this project's structure" and press Enter.

For a single answer without opening a session, pass the request in quotes: claude "explain the code in src/".

What you need before starting

Requirement Details
Operating system macOS 13 or later, Ubuntu 20.04+ or Debian 10+, Windows 10 or later (native PowerShell, Git Bash or WSL)
Memory 4 GB RAM minimum, 8 GB recommended
Account A Claude Pro, Max, Team or Enterprise subscription, or pay-as-you-go API billing
Git Optional but recommended; version 2.23 or later for the pull request helpers
Windows shell Git Bash (part of Git for Windows) or WSL2 for full Linux compatibility; PowerShell works for the native installer
Node.js Not needed for the native installer; the old npm install method is deprecated
Claude Code system requirements table with operating system, RAM and Git versions
Claude Code needs macOS 13+, Ubuntu 20.04+, Debian 10+ or Windows 10+, plus 4 GB of RAM at minimum. (Image: Microsoft)

Installing Claude Code on macOS

macOS has two supported routes: the native installer, which updates itself in the background, and the Homebrew cask, which you update by hand.

  1. Open Terminal from Applications > Utilities.
  2. Run the native installer: curl -fsSL https://claude.ai/install.sh | bash.
  3. Or, if you use Homebrew, run brew install --cask claude-code instead.
  4. Run claude --version to confirm the install.
  5. If the shell reports command not found, add ~/.local/bin to your PATH in ~/.zshrc and open a new Terminal window.

Homebrew installs do not auto-update, so run brew upgrade claude-code from time to time to get new features and security fixes.

Install Claude Code on macOS with the brew install --cask claude-code command
Homebrew installs do not auto-update, so run brew upgrade claude-code from time to time. (Image: Microsoft)

Installing Claude Code on Linux

Ubuntu 20.04 and later and Debian 10 and later are supported. The same script runs inside WSL on Windows.

  1. Open a terminal window.
  2. Run curl -fsSL https://claude.ai/install.sh | bash to download and set up the claude binary.
  3. Run claude --version to confirm the install.
  4. If claude is not found, run echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc.
  5. Run claude --version again in the same terminal.

Homebrew on Linux also carries the claude-code cask for x86_64 and ARM64 machines, so brew install --cask claude-code is an option if you already manage tools with Homebrew.

Claude Code command not found fix adding ~/.local/bin to PATH in bashrc
If claude –version is not found on Linux, add $HOME/.local/bin to PATH and reload ~/.bashrc. (Image: Microsoft)

Installing Claude Code on Windows

Claude Code runs on Windows 10 and later. Pick the shell that matches how you already work; WSL2 gives the closest match to Linux and macOS behavior.

Your setup Install command Notes
Windows PowerShell (native) irm https://claude.ai/install.ps1 |iex No WSL or Git Bash needed to install; native installs update themselves
Git Bash (Git for Windows) curl -fsSL https://claude.ai/install.sh |bash Git Bash ships with Git for Windows and gives you Git in the same shell
WSL2 with Ubuntu or Debian curl -fsSL https://claude.ai/install.sh |bash inside the Linux shell Recommended for full Linux compatibility; run wsl --install first if WSL is missing

After any of the three, close and reopen the terminal and run claude --version. Windows Terminal holds PowerShell, Git Bash and WSL tabs side by side, which suits switching between them.

Install WSL on Windows for Claude Code with the wsl --install command
Run wsl –install in an administrator PowerShell window first if WSL2 is missing, then restart the PC. (Image: Microsoft)

Logging in for the first time

By default Claude Code connects to the Anthropic API and asks you to sign in the first time you start it.

  1. Open a terminal in any folder and type claude.
  2. Choose how to sign in when prompted: your Claude subscription account or an API billing account.
  3. Follow the sign-in prompts until the session shows its input prompt.
  4. Type /status in the session to see the version, model and API provider in use.
  5. Type /logout and then /login later if you need to switch accounts.

Companies that run Claude through Microsoft Foundry skip this sign-in: they set CLAUDE_CODE_USE_FOUNDRY=1 and ANTHROPIC_FOUNDRY_RESOURCE, sign in with az login, and /login and /logout are disabled.

Your first session — getting to know your codebase

Start Claude Code from the project's root folder. It works on the files under the folder where you launch it.

  1. Run cd your-project to move into the project root.
  2. Type claude and press Enter.
  3. Ask for an overview, for example "Summarize this project's structure."
  4. Ask follow-up questions about specific folders, such as "Explain what src/workflows does."
  5. Ask where a feature lives before asking for changes, such as "Which files handle user login?"
  6. Type /rename to give the session a name you can recognize later.

Making code changes

Describe the result you want, not the keystrokes. Claude Code reads the relevant files, edits them and can run your build or test commands to confirm the change.

  1. Commit or stash your current work so the change is easy to review and undo.
  2. Describe one change in a sentence, for example "Add input validation to the signup form and show an error under each field."
  3. Name the files or folders involved if you already know them.
  4. Ask Claude Code to run the test command, for example "run pytest tests/ -v and fix any failures."
  5. Review the result with git diff before you keep it.
  6. Ask for a revision in plain language if anything is off, such as "keep the old error message text."

Using Git through Claude Code

Git is optional, but it is what makes changes reviewable and reversible. Git 2.23 or later unlocks the pull request helpers.

  1. Run git init in the project if it is not a repository yet.
  2. Ask Claude Code for status in plain English: "What files have changed since the last commit?"
  3. Ask it to create a branch for the work, for example "Create a branch called fix-login-validation."
  4. Ask it to commit with a descriptive message once the tests pass.
  5. Ask it to undo a change you do not want, such as "Revert the edits to config.yaml."
  6. Push the branch and open the pull request when you are happy with the commits.

Claude Code also runs in GitHub Actions through anthropics/claude-code-action@v1, so it can review pull requests or answer @claude mentions in PR comments.

Essential commands to know

Command Where you type it What it does
claude Shell Starts an interactive session in the current folder
claude "your request" Shell Runs a one-off request, for example claude "explain src/workflows/"
claude --version Shell Prints the installed version and proves claude is on your PATH
claude --model <name> Shell Starts a session with a specific model
claude install Shell Migrates an old npm install to the native installer
/status Inside a session Shows version, session ID, working folder, API provider and model
/login and /logout Inside a session Signs in to or out of your Anthropic account
/rename Inside a session Gives the current session a name
/plugin marketplace add <owner/repo> Inside a session Adds a plugin marketplace, such as microsoftdocs/mcp
/plugin install <plugin>@<marketplace> Inside a session Installs a plugin from an added marketplace; restart Claude Code afterwards

Setting up CLAUDE.md — project memory

CLAUDE.md is a Markdown file of standing instructions that Claude Code loads at the start of every session. Put the project overview, tech stack, folder layout and the exact build and test commands in it.

Claude Code merges the files top-down, so a later, more specific file overrides an earlier one. Start a new session after editing a CLAUDE.md file so it loads.

File Scope
~/.claude/CLAUDE.md Your global defaults across every project
./CLAUDE.md The repository root; commit it so the whole team shares it
./<subfolder>/CLAUDE.md Specifics for that folder
.claude/rules/*.md Separate rule files for finer control
CLAUDE.local.md Local memory for your machine only
Claude Code CLAUDE.md project memory locations merged from global to folder level
Later, more specific CLAUDE.md files override earlier ones, and CLAUDE.local.md stays on your machine only. (Image: Microsoft)

Practical tips for getting better results

Tip Why it helps
Launch claude from the project root Claude Code works on the folder it starts in, so it sees the whole codebase
Keep build and test commands in CLAUDE.md Every session starts knowing how to verify its own changes
Ask for one change per request Smaller diffs are easier to review and revert
Name the files and the expected behavior Less searching, fewer edits in the wrong place
Ask it to run the tests after each change Failures surface while the context is still fresh
Commit before large changes git diff and git restore give you a clean way back
Use plan mode for bigger tasks in the VS Code extension You agree on the approach before any file changes

Claude Code –version and /status check

  1. Run claude --version in a new terminal; a version number means the install and PATH are correct.
  2. Run claude inside your project folder.
  3. Type /status and confirm the cwd line shows your project folder.
  4. Confirm the API provider and Model lines show the account and model you expect.
  5. Send a test prompt such as "Summarize this project's structure" and confirm you get an answer without an authentication error.

Update Claude Code on Windows, macOS and Linux

How you installed it How it updates
Native installer (install.sh or install.ps1) Updates itself automatically in the background
Homebrew cask Run brew upgrade claude-code
npm (deprecated) Run claude install once to move to the native installer

Troubleshooting common issues

`claude: command not found` after installing

The install folder, ~/.local/bin, is not on your shell's PATH yet.

  1. Close the terminal and open a new one, then run claude --version.
  2. If it still fails in Bash, run echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc.
  3. On macOS with zsh, add the same export PATH line to ~/.zshrc instead.

Why can't I use Claude Code?

Claude Code needs a paid Claude plan or API billing; a free account is not enough.

  1. Type /status to see which account and provider the session uses.
  2. Type /logout, then /login, and sign in with an account that has a Pro, Max, Team or Enterprise plan or API billing.
  3. Run claude again from your project folder.

Claude Code asks for an Anthropic login on a Foundry setup

CLAUDE_CODE_USE_FOUNDRY is not set, so Claude Code falls back to the default Anthropic API.

  1. Set CLAUDE_CODE_USE_FOUNDRY=1 and ANTHROPIC_FOUNDRY_RESOURCE in the shell ($env:CLAUDE_CODE_USE_FOUNDRY = "1" in PowerShell).
  2. Run az login, or set ANTHROPIC_FOUNDRY_API_KEY.
  3. Add the variables to ~/.bashrc or ~/.zshrc so they persist, then start claude again.

The VS Code extension does not connect

Environment variables were set after VS Code started, or only on one side of a WSL setup.

  1. Set the variables, then launch VS Code from that same terminal.
  2. With WSL, set the variables on both Windows and inside WSL.
  3. Open a new WSL terminal and run code ..

Claude Code in terminal FAQ

Can I use Claude Code for free?

No. Claude Code runs on a Claude Pro, Max, Team or Enterprise subscription, or on pay-as-you-go API billing. The CLI itself is free to install, but each session uses your plan's allowance or bills API usage.

How do I use Claude Code in Windows?

Install it in PowerShell with irm https://claude.ai/install.ps1 | iex, or in Git Bash or WSL with the install.sh script. Then open your project folder in that shell and type claude. WSL2 gives the most Linux-like behavior.

Can I use Claude Code in VS Code?

Yes. Install the Claude Code extension from the Visual Studio Marketplace (VS Code 1.98.0 or later) and open it from the Spark icon in the sidebar. You can also run claude in the integrated terminal of Visual Studio Code.

How do I use Claude Code in IntelliJ or PyCharm?

Install the Claude Code [Beta] plugin from the JetBrains Marketplace. It needs the Claude Code CLI installed separately, then shares IDE errors and warnings with Claude Code as you work in IntelliJ IDEA, PyCharm and other JetBrains IDEs.

Why do I need Git to use Claude Code?

You do not strictly need it; Git is optional. It is recommended because it lets you review every change with git diff and roll back edits, and Git 2.23 or later is required for the pull request helpers.

Why use Claude Code instead of a chat window?

Claude Code works inside your project. It reads the codebase, edits files directly and runs your commands and tests, so you do not copy code between a browser and your editor.

Does npm install -g still work for Claude Code?

The npm install method is deprecated. Use the native installer or Homebrew instead. If you installed through npm earlier, run claude install once to migrate to the native method, which updates itself.

How do I run Claude Code in the terminal without an interactive session?

Pass the request as an argument in quotes, for example claude "explain the code in src/workflows/". Claude Code answers that one request about the current folder.

Philip Celasco

Philip is a Texas-based technology writer and IT administrator at Techdows.com with more than 10 years of experience creating practical content for everyday users and professionals. He specializes in web browsers, particularly Chromium-based platforms such as Google Chrome, Microsoft Edge, Brave, and Opera. Through his work as an IT administrator, Philip has hands-on experience managing devices, configuring browser policies, troubleshooting software and network issues, and helping people resolve problems that affect productivity and security. His articles are based on practical testing and real-world technical experience. He covers browser settings, extensions, performance problems, privacy controls, security features, and Windows troubleshooting. Outside work, Philip enjoys the quieter side of life in Texas and stepping away from the screen when he can. He has two kids, two cats and loves to play golf with his mother during the weekends.

Leave a Reply

Your email address will not be published. Required fields are marked *