OpenCode Setup
Set up an AI coding agent with your GitHub Student Developer Pack.
This page is not linked from the course navigation. You found it on your own.
OpenCode is a free, open-source AI coding agent that runs in your terminal. It can read your code, write files, run commands, and work through errors — but you decide what it does and when. Think of it as a very fast assistant that still needs you to think.
You are going to connect it to GitHub Copilot (free with your Student Developer Pack) and use it as a coding assistant from the command line.
Before You Start
You need:
- A terminal. You already have one — it is what you have been using in this course.
- macOS: Terminal.app or iTerm2
- Windows: WSL (Windows Subsystem for Linux). If you do not have WSL, see Microsoft’s install guide. All commands below run inside WSL, not PowerShell.
- Linux / Chromebook (Crostini): Your default terminal
- GitHub Student Developer Pack with Copilot enabled. Check at github.com/settings/copilot. If Copilot is not listed, activate your Student Pack at education.github.com/pack — it takes a few minutes.
Quick Start — 5 Steps, One Screen
Step 1: Install OpenCode
Pick the method that matches your system:
# Option A — Universal install script (works on macOS, Linux, WSL, Chromebook)
curl -fsSL https://opencode.ai/install | bash
# Option B — Homebrew (macOS or Linux with Homebrew installed)
brew install anomalyco/tap/opencode
# Option C — npm (any platform with Node.js installed)
npm install -g opencode-ai
If you are not sure which to use, Option A works everywhere. It downloads the correct binary for your system.
Steps 2–5: Verify, Launch, Connect, Use
# 2. Verify it installed — you should see a version number like 1.3.2
opencode --version
# 3. Open one of your lab projects and launch OpenCode
cd ~/cscd240/lab1 # <-- replace with YOUR actual project folder
opencode
# 4. Connect GitHub Copilot (first time only)
# You are now inside OpenCode's chat interface.
# It looks like a text prompt at the bottom of your terminal.
# Type this command (include the slash):
/connect
# Select "GitHub Copilot" from the list.
# It shows a code like AB12-CD34.
# Open a browser, go to: github.com/login/device
# Paste the code, click Authorize, come back to the terminal.
# Done. This only happens once.
# 5. Try it — type a question at the prompt (do NOT type the >)
explain what this project does
Everything below is reference material.
What Just Happened?
When you ran opencode, it:
- Started an interactive session connected to GitHub Copilot’s AI model
- Gave you a chat interface where you can type questions or give instructions
You can also run /init inside OpenCode to create an .opencode/ config folder in your project — this helps OpenCode understand your project structure.
The /connect command set up authentication so OpenCode can talk to GitHub Copilot through your Student Developer Pack subscription. This is a one-time setup — it remembers your login.
Details: What Can OpenCode Do?
Read and Write Files
> read server.py and explain the main function
> create a new file called utils.py with helper functions for date formatting
> refactor the database connection code into its own module
Run Terminal Commands
> run the test suite and fix any failures
> compile this Java project and show me the errors
> install the missing dependencies
Multi-Step Tasks
> add input validation to all the form handlers, then write tests for each one
> set up a basic Express server with three routes: GET /, GET /api/status, POST /api/data
OpenCode breaks big requests into steps, shows you a plan, and executes each step. You can interrupt anytime.
Providers: Where the AI Comes From
OpenCode is provider-agnostic — it is just the interface. The AI brain comes from a provider you choose. OpenCode supports 75+ providers; here are the ones relevant to you:
| Provider | Cost | How to Connect |
|---|---|---|
| GitHub Copilot | Free (Student Pack) | /connect then select GitHub Copilot |
| OpenAI (ChatGPT Plus) | Subscription | /connect then select OpenAI |
| Anthropic | API key (paid) | /connect then select Anthropic |
| Ollama (local) | Free (runs on your machine) | Requires local setup — see docs |
Use GitHub Copilot. It is free with your Student Developer Pack and gives you access to current-generation models.
Permissions: How Much Freedom Does the Agent Get?
OpenCode uses a permission config to decide whether an action should run automatically, prompt you, or be blocked:
| Action | What Happens |
|---|---|
ask (default) |
Asks before every file write or command |
allow |
Auto-approves everything — full autonomy |
deny |
Blocks the operation |
You can set this in your project’s opencode.json:
{
"permission": {
"*": "ask"
}
}
Start with ask. Once you trust the workflow, you can switch to allow for specific tools. You can also set granular rules:
{
"permission": {
"bash": {
"*": "ask",
"git *": "allow",
"gcc *": "allow"
},
"edit": {
"*": "ask",
"src/**": "allow"
}
}
}
CLI Run Mode: Scripting with AI
You do not have to use the interactive chat. You can run one-off commands:
# Ask a question
opencode run "what does the main function in server.py do?"
# Perform a task
opencode run "add error handling to all database queries in src/"
# Use in a script
opencode run "generate a changelog from the last 10 git commits" > CHANGELOG.md
This is how you build launch scripts — shell scripts that invoke OpenCode with specific prompts for repeatable tasks.
Custom Agents: Teaching OpenCode New Roles
You can create specialized agents by adding markdown files to .opencode/agents/:
---
name: code-reviewer
description: Reviews code for CSCD 240 standards
mode: subagent
tools:
write: false
edit: false
---
You are a code reviewer for a university CS course.
Review code for:
- Correct logic and edge cases
- Clean variable and function names
- Proper comments (explain WHY, not WHAT)
- No hardcoded values that should be constants
- Consistent formatting
Be encouraging but specific about improvements.
Invoke this agent inside OpenCode by typing @code-reviewer before your message:
@code-reviewer review all .c files in src/
You can also switch between the built-in Build and Plan agents using the Tab key. Plan mode analyzes without making changes; Build mode executes.
Privacy and Security
When you use OpenCode with GitHub Copilot, your code is sent over the network to GitHub’s servers for processing. Here is what you should know:
- What is sent: The contents of files you ask the agent to read, plus your prompts.
- What is NOT sent: Files the agent does not read. It only accesses what you point it at.
- Storage: GitHub’s Copilot privacy policy explains what they retain. As of 2026, code suggestions are not stored for training when using Copilot for Individuals.
- Academic integrity: Using AI tools is permitted in this course for learning. The work you submit must reflect YOUR understanding. If the AI writes code you cannot explain line-by-line, you have not learned the material.
- Credentials: Never paste API keys, passwords, or tokens into an OpenCode prompt. The
.envfile is blocked by default for a reason.
Troubleshooting
“command not found: opencode” The install did not add OpenCode to your PATH. Try:
export PATH="$HOME/.opencode/bin:$PATH"
Add that line to your shell config to make it permanent:
- macOS (zsh):
~/.zshrc - Linux / WSL / Chromebook (bash):
~/.bashrc
If you installed via npm and it is not found, try npx opencode-ai to confirm it works, then check that your npm global bin directory is on your PATH.
GitHub Copilot connection fails
- Make sure you have the GitHub Student Developer Pack activated
- Go to github.com/settings/copilot and verify Copilot is enabled
- Try
/connectagain — sometimes the device code expires, just get a new one
“model not available”
Your Copilot subscription may not include the model OpenCode is requesting. Run /connect again and let it auto-detect available models.
Slow responses
This is usually network latency to the AI provider. Check your internet connection. If using campus WiFi, try ewu-secure instead of ewu-guest.
Windows-specific issues
- Run all commands inside WSL, not PowerShell or Command Prompt.
- If
curlis not found in WSL, run:sudo apt update && sudo apt install curl - If you see SSL certificate errors, run:
sudo apt install ca-certificates
Next Steps
You have OpenCode installed and connected to GitHub Copilot. Here is where to go from here:
- Coding Agents and Launch Scripts — learn what coding agents actually are, create custom agents, and write shell scripts that automate AI workflows
- Student Launcher — a 78-line bash task runner that sends tasks from a plain text file to OpenCode. Read the script — it uses only commands from this course.
How You Found This Page
This page is not linked from anywhere on the course site. The only way to find it is to explore the site structure from the terminal:
# One way to discover it
find site/guides -name "*.md" | sort
# Or browse the rendered site paths
grep -r "permalink" site/guides/*.md
If you found it by reading the source or exploring the file structure — that is the right instinct.
Sources and Further Reading
- OpenCode documentation — official docs for installation, configuration, and features
- OpenCode CLI reference —
runcommand, flags, and scripting - OpenCode providers — 75+ supported providers including GitHub Copilot
- OpenCode permissions — permission config syntax and granular rules
- GitHub Copilot docs — setup, privacy, and subscription details
- GitHub Copilot privacy — what is sent, what is stored
- GitHub Student Developer Pack — free Copilot access for students
- WSL install guide — Windows Subsystem for Linux setup
- OpenCode source code — open source, MIT license