30 de abril de 2026
OpenCode is a terminal-native AI coding agent that gives you powerful composability through agent modes, custom commands, and shell integration. This cheatsheet collects the most impactful tricks you need – from token-saving workflows to multi-agent setups.
| Trick | What it does |
|---|---|
Build (default) / Plan modes |
Press Tab to toggle between Plan (research & architect) and Build (implement). |
| Cheap model for Plan, expensive for Build | Set a fast, low-cost model (e.g., GPT-4o-mini) for planning and a powerful one (e.g., Claude Opus) for building. Saves tokens without losing quality. |
/model command |
Switch the active model mid‑session without leaving the terminal. |
@filename references
Type @ followed by a file path to attach files directly. This avoids the agent searching the whole codebase, saving context tokens and getting more accurate results.
/compact
Summarises the conversation so far, freeing up context window space while keeping the agent fully informed. Use it before long chains of changes.
/diff
Shows a clean diff of the changes the agent wants to make before applying them. Review fast, then accept or deny.
Comments in prompts with //
Add inline comments to your message (e.g., // don't touch the database layer). The agent respects them as meta-instructions.
!command to enter shell mode
Type !npm run test and it runs in the project’s context. Start with ! to stay in the shell. Exit shell mode with exit or Ctrl+D.
Multiple terminal instances
Open other terminal windows pointing to the same or a different project. Share context across workspaces or isolate risky experiments.
@terminal
Pipe the output of the last terminal command directly into the agent’s prompt – use it to feed logs, errors, or test results.
OpenCode ships with built‑in agents and lets you create your own, all runnable in parallel.
| Agent | Usage |
|---|---|
@general |
Handles broad coding tasks (default). |
@explore |
Searches the codebase, reads docs, gathers context. |
@reviewer |
Reviews code, suggests improvements, catches bugs. |
| Custom agents | Drop Markdown files into .opencode/agents/. |
.opencode/agents/security.md contains the agent’s personality and tools. Then invoke it with @security.
You can run @explore to research a library while @security audits the auth flow – true parallel work.
/init — Bootstraps a fine‑tuned AGENTS.md file that describes your project’s stack, conventions, and goals. Start every project with this..opencode/commands/super-commit.md. Inside, define a prompt like:git commit -m '…'.”/super-commit..opencode/config.json — Store default models, temperature, and other settings. Example:
{
"models": {
"plan": "gpt-4o-mini",
"build": "claude-sonnet-4-20250514"
}
}
DESIGN.md template into your repo. Use it with /compact to enforce thoughtful architectural decisions during long sessions.Use Heygen HyperFrames to generate a dynamic video demo of your project directly from the command line. Great for READMEs, hackathons, and stakeholder updates.
Final flow that saves you hours:
Tab → Plan, ask the cheap model to design the feature./init if no AGENTS.md exists yet; then skills.sh or autoskills.@explore to map the relevant parts of the code.@file the key modules, ! test, @reviewer check, /compact when context fills up./super-commit and keep shipping.Happy building!