Skip to content
The Code Street logo The Code Street
Featured image of post How to Use OpenCode on Windows for FREE (Install + First Project)

How to Use OpenCode on Windows for FREE (Install + First Project)

Install OpenCode V2 on Windows 11 the right way (@opencode/cli, not the old opencode-ai package), connect a free AI model, and build an expense tracker from one prompt. Plan vs Build, shortcuts and quick fixes.

Most OpenCode install guides for Windows still tell you to run npm install -g opencode-ai. Run that today and you get version 1.19. The current OpenCode is version 2, and it ships under a different npm package: @opencode/cli.

This guide installs the right version on Windows 11, connects a free AI model without paying anything, and builds a small working app from one prompt. You don’t need a GPU, because the model runs in the cloud.

This is part 1 of my OpenCode series. Everything later in the series builds on this setup.

🎥 Watch the Video

👉 Watch on YouTube: How to Use OpenCode on Windows for FREE


🧠 What Is OpenCode?

OpenCode is an open-source AI coding agent that runs in your terminal. You describe what you want in plain English. It reads your project, writes files and runs commands. It’s an open-source alternative to Claude Code, and you pick the model: a free one, a paid one with your own API key, or a local model through Ollama.

🧰 What You Need

  • Windows 10 or 11
  • Node.js (OpenCode installs with npm)
  • A terminal. I use Windows Terminal with PowerShell.

OpenCode runs natively on Windows, but the official docs recommend WSL (Windows Subsystem for Linux) for the best experience. For a beginner, native Windows is the simplest way to start, so that’s what this guide uses.

1️⃣ Step 1: Check Node.js

Open PowerShell and run:

1
2
node -v
npm -v

If both print a version number, you’re ready. If not, download the LTS installer from nodejs.org, install it with the defaults, then close and reopen your terminal. An old terminal window won’t see the new install.

2️⃣ Step 2: Install OpenCode V2 (the Right Package)

Most tutorials install opencode-ai (V1, 1.19.6). The current package is @opencode/cli (V2, 2.4.1).

This is where most tutorials go wrong. If you installed OpenCode before, remove the old V1 package first, then install V2:

1
2
3
npm uninstall -g opencode-ai     # only if you installed V1 before
npm install -g @opencode/cli
opencode --version               # should start with 2

If the version starts with 1, the old package is still on your machine. Uninstall it and run the install again.

Two more things:

  • The V2 docs say Windows package managers (Scoop, Chocolatey, winget) aren’t supported. Use npm.
  • If you prefer a normal app window, there’s a Windows desktop app on the OpenCode download page. This guide uses the terminal version.

3️⃣ Step 3: Open a Project

OpenCode works on whatever folder you start it in. Create a new one and launch it:

1
2
3
mkdir expense-tracker
cd expense-tracker
opencode

The prompt box at the bottom of the OpenCode screen is where you type.

4️⃣ Step 4: Connect a Free Model

Connect a free model: /connect, then /models

1
2
/connect   -> OpenCode -> sign in
/models    -> pick a free model

Type /connect, choose OpenCode and sign in with your OpenCode account. Then type /models and pick one of the free models. OpenCode’s docs list several models as free for a limited time, including Big Pickle and DeepSeek V4.1 Flash Free.

Two honest notes:

  • The free list changes, so check /models for what’s free today.
  • Some free models may keep your prompts to improve the model. Don’t paste client code, passwords or API keys into a free model. For practice projects, it’s fine.

If you already have an API key from OpenAI, Anthropic or Google Gemini, /connect is also where you add it.

5️⃣ Step 5: Plan vs Build

Plan explores and writes a plan; Build writes code and runs commands. Shift + Tab switches.

OpenCode has two main agents, and beginners often miss this:

Agent What it does
Build (default) Writes code, edits files and runs commands
Plan Explores your project and writes a plan. It doesn’t edit your project files.

Press Shift + Tab to switch between them. My rule: start every new task in Plan, read the plan, then switch to Build. It costs one extra step and saves a lot of undoing.

🚀 Your First Project: An Expense Tracker From One Prompt

In Plan mode, paste this prompt:

1
2
3
4
Plan a simple expense tracker web app using HTML, CSS and JavaScript.
I want to add an expense with an amount in rupees, a category and a date,
see the monthly total, and save everything in the browser's localStorage.
Keep it in three files.

Read the plan. If it looks right, press Shift + Tab to switch to Build and type: Go ahead and build it.

When it finishes, open index.html in your browser. Add an expense and check that the total updates. Then refresh the page: if the data is still there, localStorage is working. The video shows the full run.

⌨️ Shortcuts Worth Learning on Day One

Shortcut What it does
@ + file name Attaches a file to your prompt, e.g. @style.css add a dark mode
/undo Reverts your last message and the changes that came with it
/redo Brings an undone change back
! + command Runs a terminal command without leaving OpenCode, e.g. !dir
Esc Stops the agent mid-task
Ctrl + P Opens the command menu

⚠️ Honest Limits

  • Free models change and have limits. If one stops working or slows down, open /models and pick another.
  • Native Windows vs WSL. Native works, but the official recommendation is WSL for better file performance and terminal support. If you hit odd terminal problems, WSL is the fix.
  • Build runs commands without asking by default. OpenCode’s permission rules allow everything unless you add rules. If you want it to ask before every shell command, add an ask rule for shell (see Permissions). Either way, use Git or a test folder until you trust it.

🛠️ Quick Fixes

Problem Fix
opencode is not recognized Reopen the terminal. Still failing? Run npm config get prefix and add that folder to your PATH.
“Running scripts is disabled on this system” Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Version shows 1.x npm uninstall -g opencode-ai, then npm install -g @opencode/cli
No free models in /models Run /connect, choose OpenCode and sign in first

❓ FAQ

Is OpenCode free? OpenCode itself is open source and free. The models are separate: OpenCode offers some free models for a limited time, and paid models need your own API key or credits.

Do I need a GPU? Not for this setup. The free models run in the cloud. You only need a GPU if you run a local model, which is the next video.

Why does opencode --version show 1.x? You installed the old opencode-ai package. Uninstall it and install @opencode/cli.

Should I use WSL instead? The official docs recommend WSL for the best experience. Native Windows is simpler for a first setup, and you can switch later.

⏭️ Next in the Series

Next up: OpenCode + Ollama. You’ll run a model on your own PC, so you don’t need an account or an internet connection for the model. Subscribe to The Code Street so you don’t miss it.

📚 Sources

comments powered by Disqus