2025-05-21 18:24:53 +00:00
---
2025-09-03 03:30:26 +00:00
title: Intro
2025-10-03 17:46:56 +00:00
description: Get started with OpenCode.
2025-05-21 18:24:53 +00:00
---
2025-09-03 03:30:26 +00:00
import { Tabs, TabItem } from "@astrojs/starlight/components"
2025-09-16 01:05:47 +00:00
import config from "../../../config.mjs"
export const console = config.console
2025-09-03 03:30:26 +00:00
2025-12-11 00:05:33 +00:00
[**OpenCode**](/) is an open source AI coding agent. It's available as a terminal-based interface, desktop app, or IDE extension.
2025-09-03 03:30:26 +00:00
2025-10-03 17:46:56 +00:00

2025-09-03 03:30:26 +00:00
Let's get started.
---
#### Prerequisites
2025-12-11 00:05:33 +00:00
To use OpenCode in your terminal, you'll need:
2025-09-03 03:30:26 +00:00
1. A modern terminal emulator like:
- [WezTerm](https://wezterm.org), cross-platform
- [Alacritty](https://alacritty.org), cross-platform
- [Ghostty](https://ghostty.org), Linux and macOS
- [Kitty](https://sw.kovidgoyal.net/kitty/), Linux and macOS
2. API keys for the LLM providers you want to use.
---
## Install
2025-10-03 17:46:56 +00:00
The easiest way to install OpenCode is through the install script.
2025-09-03 03:30:26 +00:00
```bash
curl -fsSL https://opencode.ai/install | bash
```
2025-09-23 17:35:42 +00:00
You can also install it with the following commands:
2025-09-03 03:30:26 +00:00
- **Using Node.js**
2025-11-10 14:51:24 +00:00
<Tabs>
2025-11-10 06:41:40 +00:00
2025-11-10 14:51:24 +00:00
<TabItem label="npm">
2025-11-10 06:41:40 +00:00
```bash
2025-11-10 14:51:24 +00:00
npm install -g opencode-ai
2025-11-10 06:41:40 +00:00
```
2025-11-10 05:59:57 +00:00
2025-11-10 14:51:24 +00:00
</TabItem>
2025-11-10 06:00:38 +00:00
2025-11-10 14:51:24 +00:00
<TabItem label="Bun">
```bash
bun install -g opencode-ai
```
2025-11-10 05:59:57 +00:00
2025-11-10 14:51:24 +00:00
</TabItem>
2025-11-10 06:00:38 +00:00
2025-11-10 14:51:24 +00:00
<TabItem label="pnpm">
```bash
pnpm install -g opencode-ai
```
</TabItem>
<TabItem label="Yarn">
```bash
yarn global add opencode-ai
```
</TabItem>
2025-11-10 06:41:40 +00:00
2025-11-10 14:51:24 +00:00
</Tabs>
2025-09-03 03:30:26 +00:00
- **Using Homebrew on macOS and Linux**
```bash
2026-01-07 17:06:48 +00:00
brew install anomalyco/tap/opencode
2025-09-03 03:30:26 +00:00
```
2026-01-07 17:06:48 +00:00
> We recommend using the OpenCode tap for the most up to date releases. The official `brew install opencode` formula is maintained by the Homebrew team and is updated less frequently.
2026-02-13 15:07:48 +00:00
- **Installing on Arch Linux**
2025-09-03 03:30:26 +00:00
```bash
2026-02-13 15:07:48 +00:00
sudo pacman -S opencode # Arch Linux (Stable)
paru -S opencode-bin # Arch Linux (Latest from AUR)
2025-09-03 03:30:26 +00:00
```
#### Windows
2026-02-01 16:52:43 +00:00
:::tip[Recommended: Use WSL]
For the best experience on Windows, we recommend using [Windows Subsystem for Linux (WSL)](/docs/windows-wsl). It provides better performance and full compatibility with OpenCode's features.
:::
2025-09-16 07:40:19 +00:00
- **Using Chocolatey**
```bash
choco install opencode
```
- **Using Scoop**
```bash
2026-01-18 15:58:34 +00:00
scoop install opencode
2025-09-16 07:40:19 +00:00
```
- **Using NPM**
```bash
npm install -g opencode-ai
```
2025-11-16 03:44:28 +00:00
- **Using Mise**
```bash
2026-01-02 21:02:52 +00:00
mise use -g github:anomalyco/opencode
2025-11-16 03:44:28 +00:00
```
2025-11-22 19:13:04 +00:00
- **Using Docker**
```bash
2026-01-02 21:02:52 +00:00
docker run -it --rm ghcr.io/anomalyco/opencode
2025-11-22 19:13:04 +00:00
```
2025-10-03 17:46:56 +00:00
Support for installing OpenCode on Windows using Bun is currently in progress.
2025-09-16 07:40:19 +00:00
2026-01-02 21:02:52 +00:00
You can also grab the binary from the [Releases](https://github.com/anomalyco/opencode/releases).
2025-09-03 03:30:26 +00:00
---
## Configure
2025-10-03 17:46:56 +00:00
With OpenCode you can use any LLM provider by configuring their API keys.
2025-09-03 03:30:26 +00:00
2025-10-03 17:46:56 +00:00
If you are new to using LLM providers, we recommend using [OpenCode Zen](/docs/zen).
It's a curated list of models that have been tested and verified by the OpenCode
2025-09-16 01:05:47 +00:00
team.
2025-12-02 23:08:19 +00:00
1. Run the `/connect` command in the TUI, select opencode, and head to [opencode.ai/auth](https://opencode.ai/auth).
```txt
/connect
```
2025-09-16 17:26:49 +00:00
2. Sign in, add your billing details, and copy your API key.
2025-09-16 01:06:51 +00:00
2025-12-02 23:08:19 +00:00
3. Paste your API key.
2025-09-16 01:06:51 +00:00
2025-12-02 23:08:19 +00:00
```txt
┌ API key
2025-09-16 17:26:49 +00:00
│
│
2025-12-02 23:08:19 +00:00
└ enter
2025-09-16 01:05:47 +00:00
```
2025-09-03 03:30:26 +00:00
Alternatively, you can select one of the other providers. [Learn more](/docs/providers#directory).
---
## Initialize
Now that you've configured a provider, you can navigate to a project that
you want to work on.
```bash
cd /path/to/project
```
2025-10-03 17:46:56 +00:00
And run OpenCode.
2025-09-03 03:30:26 +00:00
```bash
opencode
```
2025-10-03 17:46:56 +00:00
Next, initialize OpenCode for the project by running the following command.
2025-09-03 03:30:26 +00:00
```bash frame="none"
/init
```
2025-10-03 17:46:56 +00:00
This will get OpenCode to analyze your project and create an `AGENTS.md` file in
2025-09-03 03:30:26 +00:00
the project root.
:::tip
You should commit your project's `AGENTS.md` file to Git.
:::
2025-10-03 17:46:56 +00:00
This helps OpenCode understand the project structure and the coding patterns
2025-09-03 03:30:26 +00:00
used.
---
## Usage
2025-10-03 17:46:56 +00:00
You are now ready to use OpenCode to work on your project. Feel free to ask it
2025-09-03 03:30:26 +00:00
anything!
If you are new to using an AI coding agent, here are some examples that might
help.
---
### Ask questions
2025-10-03 17:46:56 +00:00
You can ask OpenCode to explain the codebase to you.
2025-09-03 03:30:26 +00:00
:::tip
Use the `@` key to fuzzy search for files in the project.
:::
```txt frame="none" "@packages/functions/src/api/index.ts"
How is authentication handled in @packages/functions/src/api/index.ts
```
This is helpful if there's a part of the codebase that you didn't work on.
---
### Add features
2025-10-03 17:46:56 +00:00
You can ask OpenCode to add new features to your project. Though we first recommend asking it to create a plan.
2025-09-03 03:30:26 +00:00
1. **Create a plan**
2025-10-03 17:46:56 +00:00
OpenCode has a _Plan mode_ that disables its ability to make changes and
2025-09-03 03:30:26 +00:00
instead suggest _how_ it'll implement the feature.
Switch to it using the **Tab** key. You'll see an indicator for this in the lower right corner.
```bash frame="none" title="Switch to Plan mode"
<TAB>
```
Now let's describe what we want it to do.
```txt frame="none"
When a user deletes a note, we'd like to flag it as deleted in the database.
Then create a screen that shows all the recently deleted notes.
From this screen, the user can undelete a note or permanently delete it.
```
2025-10-03 17:46:56 +00:00
You want to give OpenCode enough details to understand what you want. It helps
2025-09-03 03:30:26 +00:00
to talk to it like you are talking to a junior developer on your team.
:::tip
2025-10-03 17:46:56 +00:00
Give OpenCode plenty of context and examples to help it understand what you
2025-09-03 03:30:26 +00:00
want.
:::
2. **Iterate on the plan**
Once it gives you a plan, you can give it feedback or add more details.
```txt frame="none"
We'd like to design this new screen using a design I've used before.
[Image #1] Take a look at this image and use it as a reference.
```
:::tip
Drag and drop images into the terminal to add them to the prompt.
:::
2025-10-03 17:46:56 +00:00
OpenCode can scan any images you give it and add them to the prompt. You can
2025-09-03 03:30:26 +00:00
do this by dragging and dropping an image into the terminal.
3. **Build the feature**
Once you feel comfortable with the plan, switch back to _Build mode_ by
hitting the **Tab** key again.
```bash frame="none"
<TAB>
```
And asking it to make the changes.
```bash frame="none"
Sounds good! Go ahead and make the changes.
```
---
### Make changes
2025-10-03 17:46:56 +00:00
For more straightforward changes, you can ask OpenCode to directly build it
2025-09-03 03:30:26 +00:00
without having to review the plan first.
```txt frame="none" "@packages/functions/src/settings.ts" "@packages/functions/src/notes.ts"
We need to add authentication to the /settings route. Take a look at how this is
handled in the /notes route in @packages/functions/src/notes.ts and implement
the same logic in @packages/functions/src/settings.ts
```
2025-10-03 17:46:56 +00:00
You want to make sure you provide a good amount of detail so OpenCode makes the right
2025-09-03 03:30:26 +00:00
changes.
---
### Undo changes
2025-10-03 17:46:56 +00:00
Let's say you ask OpenCode to make some changes.
2025-09-03 03:30:26 +00:00
```txt frame="none" "@packages/functions/src/api/index.ts"
Can you refactor the function in @packages/functions/src/api/index.ts?
```
But you realize that it is not what you wanted. You **can undo** the changes
using the `/undo` command.
```bash frame="none"
/undo
```
2025-10-03 17:46:56 +00:00
OpenCode will now revert the changes you made and show your original message
2025-09-03 03:30:26 +00:00
again.
```txt frame="none" "@packages/functions/src/api/index.ts"
Can you refactor the function in @packages/functions/src/api/index.ts?
```
2025-10-03 17:46:56 +00:00
From here you can tweak the prompt and ask OpenCode to try again.
2025-09-03 03:30:26 +00:00
:::tip
You can run `/undo` multiple times to undo multiple changes.
:::
Or you **can redo** the changes using the `/redo` command.
```bash frame="none"
/redo
```
---
## Share
2025-10-03 17:46:56 +00:00
The conversations that you have with OpenCode can be [shared with your
2025-09-03 03:30:26 +00:00
team](/docs/share).
```bash frame="none"
/share
```
This will create a link to the current conversation and copy it to your clipboard.
:::note
Conversations are not shared by default.
:::
2025-10-03 17:46:56 +00:00
Here's an [example conversation](https://opencode.ai/s/4XP1fce5) with OpenCode.
2025-09-03 03:30:26 +00:00
---
## Customize
2025-10-03 17:46:56 +00:00
And that's it! You are now a pro at using OpenCode.
2025-09-03 03:30:26 +00:00
2025-10-03 17:46:56 +00:00
To make it your own, we recommend [picking a theme](/docs/themes), [customizing the keybinds](/docs/keybinds), [configuring code formatters](/docs/formatters), [creating custom commands](/docs/commands), or playing around with the [OpenCode config](/docs/config).