You've probably seen the same thing we did: your teammates compare AI coding tools by screenshots, but nobody actually shows you how to get one running on Windows and start being productive with it the same evening. This tutorial fixes exactly that. It's the setup guide we send to every engineer who joins the IBITS team, written as step-by-step commands you can copy — not a marketing comparison that ends with "try our favourite tool!"

By the end of this guide you'll have opencode — the open-source, terminal-native AI coding agent — installed and driving real edits on a sample PHP project, and you'll understand precisely how it differs from the GUI editors (Cursor, VS Code + Copilot) so you can pick the right one per task instead of arguing about it.

What You Need Before You Start

  • Windows 10 or 11 (we test on 10 and 11; the Powershell steps are identical).
  • Node.js LTS (18 or newer). If you don't have it: winget install OpenJS.NodeJS.LTS from an elevated terminal, then open a fresh terminal.
  • A terminal you like — Windows Terminal (comes with Win 11) or the built-in PowerShell.
  • An API key for one of opencode's supported providers. We use Anthropic's Claude for heavy agentic work and a cheaper model for routine edits; the setup is the same either way.

Step 1 — Install opencode

opencode is distributed as an npm package and a standalone binary. The npm route is the most reliable on Windows because it handles the PATH for you:

npm install -g opencode
opencode --version

If opencode --version prints a version string, you're done with this step. If Windows says "not recognized", your npm global bin isn't on PATH — the usual fix is to reopen your terminal (or check that %APPDATA%\npm is in your PATH environment variable).

Tip: if you'd rather not touch the global npm store, the official installer downloads a self-contained exe and adds it to PATH — but the npm package is what we use internally because it also keeps the CLI autocompletable.

Step 2 — Point it at your API key

opencode reads provider credentials from environment variables (the modern, secret-safe way — never put keys in your source files). Opencode uses a configuration file, typically ~/.config/opencode/opencode.json. For most people the zero-config path is just:

# Windows PowerShell — this only lives for the current terminal session
$env:ANTHROPIC_API_KEY = "sk-ant-your-key-here"

# To make it permanent, set it once via the GUI:
#   System Properties → Environment Variables → New → ANTHROPIC_API_KEY

Then verify the connection with the simplest possible prompt:

opencode run "name every file in this project's routes file"

If it answers with real content, your provider is wired correctly.

Step 3 — First Real Edit: run it on this very codebase

The magic of opencode over a chat-pane tool is that it can actually edit files and run commands. Let's prove it on a CodeIgniter view — the same kind of work we do for our own site's blog and shop pages.

Create a tiny test file and let opencode modify it with agent mode:

# 1. make a scratch PHP file
Set-Content -Path scratch.php -Value "<?php echo 'hello';"

# 2. ask opencode to refactor it, adding validation
opencode run "edit scratch.php to add a CSRF token check and a default-value fallback, then lint it with php -l"

What this does (that a chat pane won't): opencode writes the file, runs php -l to prove it's syntactically valid, and reports the result. That loop — edit, verify, report — is the single biggest productivity difference versus copying code out of a chat window.

Step 4 — The "agent" workflow: whole-feature scaffolding

For our Q&A leaderboard product we used opencode's agent mode to scaffold an entire feature: model, controller, routes and a publishable view, in one prompt. The pattern that works reliably:

  1. Give context: point at the exact files it should mimic (e.g. the existing shop product controller).
  2. Describe the feature narrowly: "create a points-redemption model + controller + view that follows the style of ShopController, add routes, and run php -l."
  3. Review the diff, not the prose. opencode shows you the exact lines it changed; accept per-file.

That's how our <a href="/blog/how-we-built-our-it-services-website-on-codeigniter-4-no-plugin-no-pagebuilder">own CI4 site's community features got built fast enough to stay fun</a>.

opencode vs Cursor vs VS Code — when to use which

Here's the honest matrix we operate by every day:

  • opencode — terminal-native, scriptable, runs on any project regardless of editor. Best for: multi-file changes, project-wide refactors, features that need "edit + lint + run" feedback loops, and automation.
  • Cursor — GUI editor with deep context indexing. Best for: reading and editing a large unfamiliar codebase, interactive debugging while you watch the editor, inline autocomplete.
  • VS Code + GitHub Copilot / continue — the widely-known baseline. Best for: teams that already live in VS Code and want the least new tooling. Copilot's autocomplete is excellent; it's the multi-file agentic edits where the dedicated tools pull ahead.

A practical company rule we stole from our own engineering culture: if the change touches more than one file or needs verification, use opencode; if it's a quick edit inside a file you're already reading, use the editor. Both, not either-or.

Troubleshooting the three things that actually go wrong

  • "opencode is not recognized" — PATH issue. Reinstall the npm package with npm install -g opencode and open a fresh terminal, or check %APPDATA%\npm is on PATH.
  • It installs but never answers — almost always a missing or mistyped API key in the environment variable. Print it with $env:ANTHROPIC_API_KEY (or your provider's name) to confirm it's set in the same terminal you launch opencode from.
  • Edits fail with a "no write access" style error — the working directory it's allowed to touch is constrained. Run from your project root and check the project's agent/opencode config for a permission section.

Wrapping up

Agentic CLI coding tools aren't a gimmick for our team — opencode built real, shipped features on our own CI4 website. Start with the two-minute install in Step 1, do one real edit in Steps 2–3, and before the evening is over you'll have personally verified what we mean when we say the loop edit → verify → report beats copy-paste every single time.

Want this kind of hands-on, from-the-trenches engineering content for your own IT business? Talk to our team — and if you're evaluating a full site build, our services page is a good next stop.