## Global config
~/.config/opencode/opencode.json
or:
## Project-specific
./opencode.json
Set your API Key
export ANTHROPIC_API_KEY="your-key-here"
## or
export OPENAI_API_KEY="your-key-here"
Launch opencode: $ opencode
Create an AGENTS.md file:
## Project: My SaaS App
## Tech Stack
- Next.js 14 with App Router
- TypeScript
- Tailwind CSS
- PostgreSQL with Prisma
## Conventions
- Use functional components
- Prefer server components when possible
- Follow REST API naming conventions
- Write tests for all new features
## Structure
- /app - Next.js app router pages
- /components - Reusable UI components
- /lib - Utility functions and helpers
- /prisma - Database schema and migrations
"Explain the authentication flow in this project": OpenCode will analyze your files and provide a detailed explanation of how authentication works.
"Add a dark mode toggle to the settings page": OpenCode will:
"The login form is not submitting. Here's the error: [paste error]": OpenCode will trace the issue and suggest fixes.
"Refactor the UserService class to use dependency injection": OpenCode will modernize your code while maintaining functionality.
OpenCode can work directly in your GitHub workflow:
/opencode or /oc in an issue or PR commentExample comment:
/opencode Fix the bug described in this issue
OpenCode offers several free models:
These are great for trying OpenCode without any cost!
❌ "Make it better" ✅ "Refactor the handleSubmit function to use async/await and add error handling"
❌ "Fix the bug" ✅ "The login form throws 'undefined is not a function' when clicking submit. The error occurs in auth.ts line 45"
For complex features, ask OpenCode to create a plan before implementation.
Drag and drop screenshots or mockups into the terminal—OpenCode can understand images!
Different projects may need different settings. Use local opencode.json files.
| Feature | OpenCode | Claude Code | Cursor |
|---|---|---|---|
| Open Source | ✅ | ❌ | ❌ |
| Free Tier | ✅ | Limited | Limited |
| Terminal-first | ✅ | ✅ | ❌ |
| Provider Agnostic | ✅ | ❌ (Claude only) | ❌ |
| Local Models | ✅ | ❌ | ✅ |
| IDE Integration | ✅ | ✅ | Native |
OpenCode is a powerful, open-source AI coding assistant that brings intelligent help directly to your terminal. With its provider-agnostic design, free models, and deep IDE integration, it's an excellent choice for developers looking to boost their productivity.
Key Takeaways:
USAGE
opencode <subcommand> [flags] [<directory>]
ARGUMENTS
directory string Directory to start OpenCode in (optional)
FLAGS
--standalone Run with a private server instead of the background service
--server string Connect to a server URL instead of the background service
--auto Auto-approve permissions that are not explicitly denied
--continue, -c Continue the last session
--session, -s string Session ID to continue, or to create if it does not exist
--prompt string Prompt to use
GLOBAL FLAGS
--help, -h Show help information
--version, -v Show version information
--wizard Start wizard mode for a command
--completions <bash|zsh|fish|sh> Print shell completion script (choices: bash, zsh, fish, sh)
--log-level <all|trace|debug|info|warn|warning|error|fatal|none> Sets the minimum log level (choices: all, trace, debug, info, warn, warning, error, fatal, none)
--print-logs Print logs to stderr (server logs require --standalone)
SUBCOMMANDS
upgrade, update Upgrade OpenCode to the latest or a specific version
uninstall Uninstall OpenCode, keeping session data, configuration, and state
acp Start an Agent Client Protocol server
api Make a request to the running server
debug Debugging and troubleshooting tools
auth manage integrations and credentials
mcp Manage MCP (Model Context Protocol) servers
plugin Manage plugins
models List all available models
stats Show shareable usage statistics
mini Start the minimal interactive interface
run Run OpenCode with a message
session Manage sessions
service Manage the background server
reload Reload configuration
pair Print one-time links to connect a browser or app
serve Start the v2 API and web server
opencode --wizard: Walks through a console-based wizard to create a shell command for execution.
opencode run --model ollama/qwen3.8:27b "Create a singly-linked list class in Python." .: Run a prompt through the given model in the current directory
Last modified 03 November 2026