OpenCode: AI Agent That Reads and Edits Code in Terminal
I spend most of my day in the terminal, whether I’m debugging a systemd service on a RHEL server or writing Bash scripts for the Pro TecMint courses. So when I first tried OpenCode, I didn’t expect much. I had already used a few AI coding tools that felt like add-ons to an IDE and could only guess what was happening based on the file that was open.
OpenCode was different from the start. I pointed it to a messy Node.js project with around 40 files and asked why a background job kept failing silently. It traced the dependencies on its own, opened the right three files, and showed me that the retry logic was swallowing an exception. The whole process took about 90 seconds of typing and a few minutes of waiting.
What made me continue using it was its terminal-first design. It isn’t a browser wrapper or a plugin competing with your editor’s shortcuts. It’s a proper terminal user interface (TUI) with a client-server architecture underneath, so the agent process can keep running even if your terminal session disconnects.
इससे जुड़ी जानकारी
Since it’s not tied to a single AI provider, I can use Claude, OpenAI, or even a local model, depending on the task and how much I want to spend that day.
What OpenCode Actually Does
OpenCode is an open-source AI coding agent that runs inside your terminal and uses a language model to read, write, and modify code in a real project. Instead of copying and pasting code snippets into a chat window, you simply point OpenCode to a project directory, explain what you want to do, and it works directly with your files, runs commands, and applies changes when needed.
Two things make it different from a basic AI chatbot wrapper.
First, it comes with built-in agent modes that you can switch between by pressing the Tab key. The build mode can edit files and run commands, making it useful when you want the agent to implement changes. The plan mode is read-only and is meant for analysis, helping you explore and understand a codebase before allowing it to modify anything.
Second, OpenCode is provider-agnostic, which means you’re not tied to a single AI service. You can connect it to Claude, OpenAI, Google, GitHub Copilot, or even a self-hosted model. You can also switch providers whenever needed, which is useful if one service is rate-limited or becomes too expensive for a particular task.
Prerequisites
Before installing OpenCode, make sure you have the following:
- A 64-bit Linux system. Ubuntu, Debian, RHEL, and Rocky Linux all work fine.
curlinstalled, as the official installation script downloads the OpenCode binary over HTTPS.- A terminal emulator that supports modern terminal user interfaces (TUIs), such as GNOME Terminal, Alacritty, Kitty, or a terminal running inside tmux.
- An account with at least one supported AI provider, such as Claude, OpenAI, Google, or GitHub Copilot.
- You can also use a self-hosted local model if that’s what you prefer.
- A regular user account with
sudoprivileges if you want to install OpenCode system-wide.
You do not need Node.js installed if you use the official installation script. Node.js is only required if you choose to install OpenCode using npm. In the next sections, I’ll show both installation methods.
Step 1: Install curl and Basic Prerequisites
Most Linux distributions already include curl, but it’s a good idea to verify that it’s installed before continuing. The official OpenCode installer uses curl to download the binary, so the installation cannot proceed without it.
On Ubuntu and Debian:
sudo apt update && sudo apt install curl -y
On RHEL and Rocky Linux:
sudo dnf install curl -y
The sudo command runs the package manager with administrative privileges because installing software requires write access to system directories. If curl is already installed, both commands will simply report that the package is already present and exit without making any changes.
Step 2: Install OpenCode
The easiest way to install OpenCode is by using the official installation script. It automatically detects your Linux distribution and system architecture, downloads the correct binary, and installs it into a directory that’s already in your PATH.
curl -fsSL https://opencode.ai/install | bash
You should see output similar to this:
Installing opencode version: 1.17.18 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100% Successfully added opencode to $PATH in /home/ravi/.bashrc ▄ █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█ █░░█ █░░█ █▀▀▀ █░░█ █░░░ █░░█ █░░█ █▀▀▀ ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀ ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ OpenCode includes free models, to start: cd # Open directory opencode # Run command For more information visit https://opencode.ai/docs
Here’s what the command does:
curl -fmakescurlfail if the server returns an error instead of downloading an error page.-srunscurlin silent mode and hides the progress meter.-Sdisplays an error message if something goes wrong while still keeping silent mode enabled.-Ltellscurlto follow redirects automatically.| bashsends the downloaded script directly to Bash, which executes it immediately instead of saving it to a file first.
By default, OpenCode installs into a directory under your home folder. If you want to install it somewhere else, such as/usr/local/bin, set the OPENCODE_INSTALL_DIR environment variable before running the installer:</p…
Leave a Reply