OpenCode is an open source AI coding agent.
Copy the config examples from ./config into ~/.config/opencode/.
- Copy
config/opencode.jsonto~/.config/opencode/opencode.json - Copy
config/tui.jsonto~/.config/opencode/tui.json
opencode.json contains runtime, provider, and MCP settings.
tui.json contains TUI-only settings like theme and keybinds.
The runtime config example includes:
- Settings for using local models through llama.cpp and LM Studio
- Playwright MCP configuration for local server using
@playwright/mcp@latest
Relevant documentation:
OpenCode reads AGENTS.md files for persistent instructions. Use global instructions for behavior that should apply everywhere, and project instructions for repository-specific context and stack choices.
Copy the global template to ~/.config/opencode/AGENTS.md:
cp instructions/global/AGENTS.md ~/.config/opencode/AGENTS.mdThe global template focuses on reusable behavior:
- Ask before assuming
- Prefer the simplest correct change
- Avoid touching unrelated code
- Flag uncertainty explicitly
- Confirm before destructive or external actions
Copy the project template into a repo that needs project-specific OpenCode context:
cp instructions/project/AGENTS.md /path/to/project/AGENTS.mdUse project instructions for:
- Project goals and audience
- Stack and tooling constraints
- Permanent architectural facts
- Project-specific behavior rules
Do not put project-specific stack choices in the global file. A decision that is correct for one repository may be wrong for another.
| Scope | Path | Description |
|---|---|---|
| Global | instructions/global/AGENTS.md |
Reusable OpenCode behavior and safety rules. |
| Project | instructions/project/AGENTS.md |
Project-specific context, stack, and behavior rules. |
Prefer AGENTS.md for OpenCode-specific setup. Use the instructions field in opencode.json only when you want to load extra non-standard files such as CONTRIBUTING.md, docs/guidelines.md, or globbed rule files.
If you want to use OpenCode with local models, start with the guide in ../llama-cpp.
For coding-agent use, OpenCode should connect to a running llama-server instance.
Coding tools usually need more prompt space than normal chat, so context size can matter more here than it does for casual terminal use.
Copy the commands folder to /Users/[your-username]/.config/opencode/commands/
Available commands:
| Command | Path | Description |
|---|---|---|
/git-commit |
commands/git-commit.md |
Stage and commit changes with safety checks and a generated message. |
/git-push |
commands/git-push.md |
Push the current branch with safety checks and optionally create a PR. |
You can define project-specific custom agents by adding an .opencode/agent/ folder inside your project.
This makes the custom mode available only for that project.
Copy the .opencode folder into your project to try it.
| Name | Scope | Path | Description |
|---|---|---|---|
FunMode |
Project-specific | .opencode/agent/funmode.md |
Example custom mode with a playful, high-personality response style. |
Once copied, init OpenCode and press Tab to switch modes, you should see a new FunMode available.