How to Set Up an AI Coding Assistant on Windows: A Complete Guide

    Learn how to install and configure an AI coding assistant on Windows, from setting up Node.js and Git to installing the CLI tool, handling permission errors, configuring API key authentication securely, and verifying the setup with a final checklist.

    1. Identify the Type of Tool You Are Installing

    AI coding assistants generally come in two forms. The first is a command-line tool that runs in a terminal and reads or modifies files in the current directory. The second is an IDE plugin installed in editors such as VS Code or JetBrains IDEs. This guide focuses on the command-line form, but the process also applies to most similar tools distributed through npm.

    We use Anthropic’s Claude Code as the example; its npm package name is @anthropic-ai/claude-code. If you use a different tool, check its official documentation first for the package name, runtime requirements, and authentication method, then substitute accordingly in the commands below.

    2. Prepare the Runtime Environment

    2.1 Install Node.js

    Claude Code is installed via npm, which requires Node.js. The official documentation requires Node.js 18 or higher; the current LTS (Long Term Support) version is recommended. Download the Windows installer from nodejs.org and keep the default options during installation—the installer sets up npm as well.

    After installation, close and reopen PowerShell, then run:

    1. node -v
    2. npm -v

    If both commands print version numbers, the installation succeeded. If the Node version is lower than the tool requires, you can use nvm-windows to manage multiple versions. This is optional and only needed if you plan to switch versions.

    2.2 Install Git for Windows

    Claude Code needs to read repository history, so Git is required. Download Git for Windows from git-scm.com; the installer includes Git Bash by default. After installation, run:

    1. git --version

    A version number confirms success. If the tool later reports that it cannot find bash, set the CLAUDE_CODE_GIT_BASH_PATH environment variable to the full path of bash.exe, for example C:\Program Files\Git\bin\bash.exe. Adjust the path to the actual location on your machine.

    2.3 Choose a Terminal

    The built-in Windows PowerShell is sufficient for all steps. If you prefer multiple tabs and better copy-paste behavior, install Windows Terminal:

    1. winget install --id Microsoft.WindowsTerminal -e

    Alternatively, use the integrated terminal in VS Code, opened with Ctrl+`.

    3. Install the Assistant

    3.1 Global Installation

    Run the following in PowerShell:

    1. npm install -g @anthropic-ai/claude-code

    Verify the installation:

    1. claude --version

    3.2 Handling Permission Errors

    If you see EACCES or EPERM errors during installation, npm’s global directory is most likely in a system-protected location. Check the global prefix:

    1. npm config get prefix

    If the path is under a system directory like C:\Program Files, redirect npm to a user-writable directory instead of running the installer as administrator:

    1. mkdir "$env:APPDATA\npm-global" -Force
    2. npm config set prefix "$env:APPDATA\npm-global"

    Then add %APPDATA%\npm-global to your user PATH, reopen the terminal, and install again. This limits the installation to your current user account and avoids privilege escalation. If company policy restricts changing npm or PATH settings, contact your IT administrator.

    3.3 Using a Mirror Registry (Optional)

    If downloads from the default registry are slow, you can temporarily use an npm mirror provided by your organization or network provider. Only use mirror addresses from your own organization or service provider—never third-party mirrors of unknown origin, as they may serve tampered dependencies that compromise your code environment.

    Set the mirror and install:

    1. npm config set registry <your-mirror-url>
    2. npm install -g @anthropic-ai/claude-code

    After installation, immediately restore the official registry:

    1. npm config set registry https://registry.npmjs.org/

    Do not keep a custom registry configured long-term, or later dependencies may still come from the old mirror.

    4. Configure Authentication

    4.1 Choose a Login Method

    Claude Code requires either an Anthropic account or an API key—choose one of the following:

    • Account login: run claude in the terminal and follow the prompts to authorize in your browser.
    • API key: create a key in the Anthropic Console and provide it via an environment variable.

    4.2 Set the Key in PowerShell

    For a temporary, session-only setting, run:

    1. $env:ANTHROPIC_API_KEY = "your-api-key"

    The setting is lost when the terminal closes. To persist it, use setx:

    1. setx ANTHROPIC_API_KEY "your-api-key"

    setx writes a user-level environment variable that only takes effect after reopening the terminal. Note that setx stores the value in the registry, so any program on the same machine that can read user environment variables can also see it. On shared or company machines, prefer session-level settings or the system credential manager.

    When running these commands, the key may be exposed in command history or screenshots. Afterward, clear your terminal history and set a usage limit for the key in the console.

    4.3 Keep the Key Out of Your Repository

    Never write the key into project files. At the repository root, check whether .gitignore ignores the .env file:

    1. Select-String -Path .gitignore -Pattern "^\.env" -Quiet

    True means it is ignored. If it returns False, add a line .env to .gitignore. Before committing, run git status to confirm no sensitive files are staged.

    5. Verify the Installation

    Navigate to a project directory that has been set up with git init or git clone, then run:

    1. claude

    In the interactive interface, enter a read-only prompt such as “List the main files in the current directory and describe the project structure.” If the assistant lists the files correctly, read access works.

    Next, test modifications in a test repository. Ask it to change a trivial file, then inspect the result with git diff. Only move on to real projects once you confirm there are no unexpected changes.

    6. Troubleshooting

    6.1 “Command Not Found”

    If running claude returns “not recognized as an internal or external command,” npm’s global directory is probably not in your PATH. Run npm config get prefix to find the path and confirm it is in your user PATH. You must reopen the terminal after modifying PATH.

    6.2 Download Timeouts

    Check your proxy settings first. Run npm config get proxy and npm config get https-proxy to view the current configuration. On a corporate network that requires a proxy, confirm the address with your IT department. If it still fails, switch to an organization-provided mirror.

    6.3 Authentication Failures

    Check for leading or trailing spaces in the key and verify it was copied in full. In the console, confirm the key has not expired and the account has sufficient quota. If you just set the key with setx, you need to reopen the terminal.

    6.4 The Assistant Cannot Modify Files

    Confirm the current directory is a Git repository and that you have write permissions. Projects under C:\Program Files usually require administrator rights—it is better to move them into your user directory. When the tool asks for authorization, only grant it access to the current project directory.

    7. Pre-Flight Checklist

    After completing the setup, verify each item:

    • node -v and npm -v print version numbers that meet the tool’s requirements
    • git --version prints a version number, and the tool can locate the bash path
    • npm config get registry returns the official registry or your organization’s official mirror
    • claude --version outputs normally
    • The API key exists only in environment variables or the credential manager, never in project files
    • The project’s .gitignore ignores .env and other sensitive files
    • You have completed one read-only Q&A session and one small modification in a test repository, checked with git diff

    Before use, check the official documentation for three things: the minimum runtime version, whether the package name has changed, and the authentication method and data usage terms. These tools evolve quickly.