April 30, 2026
OpenCode Cheatsheet for Software Engineers
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.
Core Modes & Model Selection
| 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. |
File & Context Tricks to Save Tokens
-
@filenamereferences
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.
Shell Mode & Workspace
-
!commandto enter shell mode
Type!npm run testand it runs in the project’s context. Start with!to stay in the shell. Exit shell mode withexitorCtrl+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.
Multi-Agent Superpowers
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/. |
Custom Agent Example
.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.
Custom Commands & Project Setup
/init— Bootstraps a fine‑tunedAGENTS.mdfile that describes your project’s stack, conventions, and goals. Start every project with this.- Custom slash commands — Create
.opencode/commands/super-commit.md. Inside, define a prompt like:
”Review all changes, write a concise git commit message following conventional commits, and executegit commit -m '…'.”
Then just type/super-commit. .opencode/config.json— Store default models, temperature, and other settings. Example:{ "models": { "plan": "gpt-4o-mini", "build": "claude-sonnet-4-20250514" } }
Skills & Design
- skills.sh – Download a curated skill pack for a specific technology (e.g., React, FastAPI). Run once, and the agent gains deep, current knowledge of that stack.
- autoskills (github.com/midudev) – Analyses your project and suggests the best skill packs to install. Perfect when you’re starting on an unfamiliar codebase.
- DESIGN.md from Google – Drop a copy of Google’s open‑source
DESIGN.mdtemplate into your repo. Use it with/compactto enforce thoughtful architectural decisions during long sessions.
Bonus: Show Off Your Project
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./initif noAGENTS.mdexists yet; thenskills.shorautoskills.- Run
@exploreto map the relevant parts of the code. - Switch to Build mode with an expensive model,
@filethe key modules,!test,@reviewercheck,/compactwhen context fills up. - Use
/super-commitand keep shipping.
Happy building!