# How to use OpenCode: install it, connect a model, start coding

> The steps from the official docs for OpenCode V2: install, /connect, prompts with attached files and shell commands, undo, resuming sessions, skills and updates.

URL: https://claudegpt.si/news/how-to-use-opencode  
Published: 2026-11-29T14:59:09.886Z  
Author: ClaudeGPT Si Newsroom  
Section: Guides  
Topics: OpenCode, How to, Coding agents, Developer tools, Open source  
Publisher: ClaudeGPT Si

## Key takeaways

- Install OpenCode with the script at opencode.ai/v2/install or a package manager, run opencode in your project folder, and connect a model provider with /connect.
- In the terminal interface, @ attaches files, /undo reverts the last message and its file changes, and /sessions reopens an earlier session.
- opencode upgrade updates the tool; the newest release on the changelog is v2.4.2, dated November 26, 2026.

To use OpenCode, install it with one command, run `opencode` inside your project folder, connect a model provider with `/connect`, and type what you want done in plain English. OpenCode is an open source coding agent, a program that reads your code, edits files and runs shell commands for you, and it works in a terminal, a desktop app or a browser.

This guide covers how to use OpenCode from the first install to the daily habits: prompts, sessions, undo, skills and updates. Every step comes from the [OpenCode docs](https://opencode.ai/docs/) as of November 29, 2026, which describe OpenCode V2. The newest release on the [changelog](https://opencode.ai/changelog) is v2.4.2, dated November 26, 2026. The commands below are quoted from the docs and were not run for this article.

## What you need first

- A terminal. The [CLI docs](https://opencode.ai/docs/cli/) suggest Ghostty, WezTerm, Alacritty or Kitty, and say truecolor support gives themes their most accurate colors.
- A model to run it on. That can be an API key or account at a provider such as Anthropic or OpenAI, an OpenCode Console account, or one of the free models OpenCode lists for a limited time. Our article on [whether OpenCode is free](https://claudegpt.si/news/is-opencode-free) covers what each option costs.
- A project folder. A Git repository is best, because undo relies on it (see below).

## How to install OpenCode

The docs give one install script for macOS and Linux:

```bash
curl -fsSL https://opencode.ai/v2/install | bash
```

Or use a package manager. These are the commands on the docs' intro page:

| Method | Command |
| --- | --- |
| Homebrew | `brew install anomalyco/tap/opencode-v2` |
| npm | `npm install -g @opencode/cli` |
| Bun | `bun install -g --trust @opencode/cli` |
| pnpm | `pnpm add -g --allow-build=@opencode/cli @opencode/cli` |
| Yarn | `yarn global add @opencode/cli` |
| Arch Linux (AUR) | `paru -S opencode-beta` |
| mise | `mise use -g opencode` |

Two notes from the same page. The mise command needs mise 2026.10.9 or later, because older versions install OpenCode 1. And Windows package managers are not supported: on Windows, download the standalone CLI binary (x64 or ARM64) or the desktop installer from the [intro page](https://opencode.ai/docs/). The desktop app also ships for macOS and for Linux as .deb, .rpm and AppImage files.

## How to start OpenCode and connect a model

1. Open a terminal in your project and start the full-screen terminal interface (the docs call it the TUI):

   ```bash
   cd ~/code/my-project
   opencode
   ```

   You can also pass the folder instead: `opencode ~/code/my-project`. The folder you start in is where OpenCode searches files and runs shell commands.

2. Connect a provider. Type this in the prompt box:

   ```text
   /connect
   ```

   Pick a provider, choose an authentication method if it offers more than one, and follow the prompts. The [providers docs](https://opencode.ai/docs/cli/providers/) say the TUI supports API keys and OAuth, the browser sign-in flow. From a shell, `opencode auth login` does the same job, and `opencode auth login anthropic --method key` goes straight to pasting an Anthropic API key.

3. Pick a model with `/models`, or press `Ctrl+X` and then `M`. `F2` cycles through the models you used recently. Our guide on [how to change the model in OpenCode](https://claudegpt.si/news/opencode-how-to-change-model) covers defaults and reasoning effort.

## How to use OpenCode day to day

Type a request and press `Enter`. The [TUI docs](https://opencode.ai/docs/cli/tui/) use this as a first prompt:

```text
Explain how authentication works in this project
```

`Shift+Enter` adds a new line. If you press `Enter` while OpenCode is working, the message steers the session in progress. `Ctrl+X` then `Enter` queues it for later instead.

Four things make prompts more precise:

- **Attach files with `@`.** Type `@` and start typing a file name, then select it. `Review @src/auth.ts for error handling problems` sends that file along. Add a line range with `#`, as in `@src/auth.ts#20-45`.
- **Run a shell command with `!`.** Type `!` at the start of an empty prompt, then the command, such as `!git status`. The output stays in the session, so the model can see it.
- **Use slash commands.** Type `/` to list them. The docs name `/new`, `/sessions`, `/models`, `/agents`, `/undo`, `/redo` and `/editor` as the common ones. `Ctrl+P` opens a palette with every action.
- **Ask a side question.** `/btw why did the test in step 2 fail?` answers from the session's context without adding anything to the conversation.

### Plan first, then build

OpenCode ships with two main agents, according to the [agents docs](https://opencode.ai/docs/agents/). Build is the default and can edit files and use tools. Plan explores and plans without editing normal project files. Press `Shift+Tab` to cycle between agents, or run `/agents`. A common routine is to ask Plan for an approach, read it, then switch to Build to carry it out.

### Undo a change you don't like

Run `/undo`, or press `Ctrl+X` then `U`. OpenCode reverts your latest message and the work that followed, restores the files, and puts the prompt back in the box so you can reword it. `/redo` cancels the undo. The [snapshots docs](https://opencode.ai/docs/snapshots/) say this covers the session's directory inside a Git worktree, skips Git-ignored files, and is best effort, so keep Git commits for anything important.

### Give it standing instructions

Add an `AGENTS.md` file at the root of your project with build commands, conventions and rules such as "Do not edit generated files directly". OpenCode loads it in every session, per the [instructions docs](https://opencode.ai/docs/instructions/). If a folder has no `AGENTS.md`, OpenCode reads `CLAUDE.md` instead, which helps if you are moving over from Claude Code. Our [Claude Code vs OpenCode comparison](https://claudegpt.si/news/claude-code-vs-opencode) covers the other differences.

### Control what it may do

When no rule matches an action, OpenCode asks you first. To change that, add ordered rules to `opencode.jsonc` in your project. This example from the [permissions docs](https://opencode.ai/docs/permissions/) asks before shell commands, allows `git status` and blocks pushes:

```jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "permissions": [
    { "action": "shell", "resource": "*", "effect": "ask" },
    { "action": "shell", "resource": "git status *", "effect": "allow" },
    { "action": "shell", "resource": "git push *", "effect": "deny" }
  ]
}
```

The last matching rule wins, so the exceptions go after the broad rule.

## How to resume a session in OpenCode

Each session is a separate conversation with its own history, and earlier ones stay available. Inside the TUI, run `/sessions` or press `Ctrl+X` then `L`, and pick the one you want. In that list, `Ctrl+A` switches between sessions in the current folder and sessions in all projects. `Ctrl+O` opens recent sessions and projects together. `/new` starts a fresh session.

From the shell, the [CLI commands page](https://opencode.ai/docs/cli/commands/) documents two flags on `opencode run`, which sends one prompt without opening the interface, and on `opencode mini`, the minimal interactive interface:

```bash
opencode session list
opencode run --continue "Now handle the expired case"
opencode run --session ses_4f2a1c "Check edge cases"
opencode mini --continue
```

`--continue` picks up the last session. `--session` takes a session ID from `opencode session list`.

## How to use skills in OpenCode

A skill is a reusable set of instructions for one kind of task, such as preparing a release. To create one, put a `SKILL.md` file in `.opencode/skills/<skill-id>/` and say when to use it in the `description` line:

```markdown
---
name: Git Release
description: Prepare release notes, version bumps, and GitHub releases
---

1. Summarize merged changes since the previous tag.
2. Propose the version bump before changing files.
```

There are two ways to use it, per the [skills docs](https://opencode.ai/docs/skills/). OpenCode shows the model each skill's name and description, and the model loads the full text when a task matches. Or you load one yourself by mentioning its ID in a prompt as `@git-release`. The ID comes from the folder name, not the `name` field, and a skill with no description is never offered to the model.

Global skills go in `~/.config/opencode/skills`. OpenCode also reads `.claude/skills` and `.agents/skills`, in a project or in your home folder, so skills written for other agents work without copying.

## How to update OpenCode

Run:

```bash
opencode upgrade
```

`opencode update` is an alias. To pin a version and a package manager, the docs give `opencode upgrade 2.0.21 --method bun`.

By default OpenCode checks for updates and tells you when one is available. The `update` setting in the global config changes that: `"notify"` is the default, `"auto"` installs updates automatically and `"disable"` skips the checks. The [config docs](https://opencode.ai/docs/config/) add that an automatic install does not restart a running server, so restart it to get the new version. After an update, the home screen shows what is new once, and `/highlights` shows it again.

## Common problems

- **Something is stuck.** OpenCode runs a shared background server that owns sessions and tool runs. The [troubleshooting page](https://opencode.ai/docs/troubleshooting/) says to check it with `opencode service status` and restart it with `opencode service restart`.
- **A model is missing from `/models`.** Connect its provider with `/connect` first.
- **You need the logs.** They are in `~/.local/share/opencode/log/opencode.log`.
- **You want it gone.** `opencode uninstall --dry-run` previews what would be removed. Session data, configuration and state are kept.

For scripts and CI, `opencode run "Explain this repository"` prints the reply straight to the terminal, and `--format json` emits newline-delimited JSON. The code is on [GitHub](https://github.com/anomalyco/opencode) under the MIT license, and bugs go to its issue tracker.

## Frequently asked questions

### How do I install OpenCode?

On macOS and Linux, run curl -fsSL https://opencode.ai/v2/install | bash, or use a package manager, for example npm install -g @opencode/cli or brew install anomalyco/tap/opencode-v2. Windows package managers are not supported, so Windows users download the standalone binary or the desktop app from the docs.

### How do I resume a session in OpenCode?

In the terminal interface, run /sessions or press Ctrl+X then L and pick the session. From the shell, opencode run --continue and opencode mini --continue pick up the last session, and --session with an ID from opencode session list opens a specific one.

### How do I use skills in OpenCode?

Put a SKILL.md file in .opencode/skills/<skill-id>/ with a description of when to use it. OpenCode offers the skill to the model when a task matches, and you can load it yourself by typing @skill-id in a prompt.

### How do I update OpenCode?

Run opencode upgrade, or its alias opencode update. By default OpenCode notifies you about new versions; setting update to "auto" in the global config installs them automatically.

### Is OpenCode free?

The agent is open source under the MIT license and free to install. Models can cost money: you pay your own provider, use OpenCode Console, or subscribe to OpenCode Go, which the docs list at $10 a month as of November 29, 2026. The docs also list free models that are available for a limited time.

## Sources

- [Intro](https://opencode.ai/docs/), OpenCode
- [TUI](https://opencode.ai/docs/cli/tui/), OpenCode
- [CLI intro](https://opencode.ai/docs/cli/), OpenCode
- [CLI commands](https://opencode.ai/docs/cli/commands/), OpenCode
- [CLI providers](https://opencode.ai/docs/cli/providers/), OpenCode
- [Skills](https://opencode.ai/docs/skills/), OpenCode
- [Agents](https://opencode.ai/docs/agents/), OpenCode
- [Instructions](https://opencode.ai/docs/instructions/), OpenCode
- [Permissions](https://opencode.ai/docs/permissions/), OpenCode
- [Snapshots](https://opencode.ai/docs/snapshots/), OpenCode
- [Config](https://opencode.ai/docs/config/), OpenCode
- [Troubleshooting](https://opencode.ai/docs/troubleshooting/), OpenCode
- [Go](https://opencode.ai/docs/console/go/), OpenCode
- [Console models](https://opencode.ai/docs/console/models/), OpenCode
- [Changelog](https://opencode.ai/changelog), OpenCode
- [anomalyco/opencode](https://github.com/anomalyco/opencode), GitHub
