01. Install Node.js
Node.js is a JavaScript runtime that lets you run JS outside the browser. You need it for npm, build tools, and running OpenCode.
- Go to nodejs.org
- Download the LTS version
- Run the installer — accept all defaults, no changes needed
- Restart your terminal after installation
Verify it worked:
$ node --version
v22.x.x
$ npm --version
10.x.x
If you see version numbers, Node.js is installed correctly.
02. Install OpenCode
OpenCode is an open-source AI coding agent that lives in your terminal. It reads your codebase and helps you write, debug, and understand code using AI.
Option A — Install via curl (recommended for Linux/Mac)
$ curl -fsSL https://opencode.ai/install | bash
Option B — Install via npm (works on all OS)
$ npm i -g opencode-ai
Option C — Install via Homebrew (Mac only)
$ brew install anomalyco/tap/opencode
Verify it worked:
$ opencode --version
If it prints a version, you’re good to go.
03. Start Using OpenCode
Navigate to any project folder and launch OpenCode. It will read your files and understand your codebase automatically.
Linux / Mac:
$ mkdir my-project && cd my-project
$ opencode
Windows (PowerShell):
$ mkdir my-project; cd my-project
$ opencode
Once OpenCode is running, you can talk to it naturally. Here are some prompts to try:
Create a simple HTML page with a form that has name and email fields
Add validation to check that the email is valid before submitting
Style this page with a dark theme and centered layout
04. Context Engineering
The quality of AI output depends entirely on the quality of your input. Context engineering is the skill of giving AI the right information so it can help you effectively.
Be specific about the problem
Bad: “fix this bug”
Good: “There’s a TypeError on line 42 when the user submits the form — the email field is undefined because the input name attribute doesn’t match the destructured variable”
Show the surrounding code
AI works better when it can see the function calling the broken code, not just the broken line. Include the parent function, imports, and any related types.
State your constraints
Tell the AI what you can’t change: “I can’t modify the database schema”, “this must work with React 18”, “the API endpoint is fixed”. This prevents suggestions that don’t fit your situation.
Ask “why” not just “how”
Don’t just copy the generated code. Ask OpenCode to explain why it chose that approach. This is how you actually learn, not just produce output.
05. Deploy to Cloudflare Pages
Once your project works locally, deploy it for free on Cloudflare Pages. You get a live URL, HTTPS, and a global CDN — all on the free tier.
Method A — Direct Upload (quickest)
No GitHub needed. Just build your project and drag the folder to Cloudflare.
- Build your project:
npm run build - Find the output folder — usually called
distorbuild - Go to dash.cloudflare.com
- Navigate to Workers & Pages → Create application → Pages
- Click Upload assets
- Name your project and click Create project
- Drag your
distfolder into the upload area - Click Deploy — done! You get a
your-project.pages.devURL
Every time you make changes, just run npm run build again and re-upload the dist folder.
Method B — Git Integration (auto-deploy)
Push to GitHub and Cloudflare auto-deploys on every commit. More setup, but better long-term.
Push to GitHub first:
$ git init
$ git add .
$ git commit -m "first commit"
$ git remote add origin https://github.com/YOU/repo.git
$ git push -u origin main
Then on Cloudflare:
- Go to dash.cloudflare.com
- Navigate to Workers & Pages → Create application → Pages → Connect to Git
- Select your GitHub repo
- Set build command:
npm run build, output directory:dist - Click Save and Deploy
Now every git push automatically redeploys your site.
Summary
- Installed Node.js — the JavaScript runtime
- Installed OpenCode — your AI coding agent
- Started using OpenCode — running it in your project
- Learned context engineering — how to talk to AI effectively
- Deployed a project to Cloudflare Pages