Website | Source

Configuration

  1. Choose your provider. To configure your provider, create a config file:
    ## Global config
    ~/.config/opencode/opencode.json
    

or:

    ## Project-specific
    ./opencode.json
  1. Set your API Key

    export ANTHROPIC_API_KEY="your-key-here"
    ## or
    export OPENAI_API_KEY="your-key-here"
    
  2. Launch opencode: $ opencode

  3. 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
    

Practical Uses

Example 1: Understanding a Codebase

"Explain the authentication flow in this project": OpenCode will analyze your files and provide a detailed explanation of how authentication works.

Example 2: Adding a Feature

"Add a dark mode toggle to the settings page": OpenCode will:

Example 3: Debugging

"The login form is not submitting. Here's the error: [paste error]": OpenCode will trace the issue and suggest fixes.

Example 4: Refactoring

"Refactor the UserService class to use dependency injection": OpenCode will modernize your code while maintaining functionality.

GitHub Integration

OpenCode can work directly in your GitHub workflow:

  1. Mention /opencode or /oc in an issue or PR comment
  2. OpenCode runs in your GitHub Actions runner
  3. It creates a new branch and submits a PR with changes

Example comment:

/opencode Fix the bug described in this issue

Free Models Available

OpenCode offers several free models:

These are great for trying OpenCode without any cost!


Tips for Beginners

1. Be Specific

❌ "Make it better" ✅ "Refactor the handleSubmit function to use async/await and add error handling"

2. Provide Context

❌ "Fix the bug" ✅ "The login form throws 'undefined is not a function' when clicking submit. The error occurs in auth.ts line 45"

3. Use Plan Mode First

For complex features, ask OpenCode to create a plan before implementation.

4. Leverage Image Support

Drag and drop screenshots or mockups into the terminal—OpenCode can understand images!

5. Create Project-Specific Configs

Different projects may need different settings. Use local opencode.json files.


OpenCode vs Other Tools

Feature OpenCode Claude Code Cursor
Open Source ✅ ❌ ❌
Free Tier ✅ Limited Limited
Terminal-first ✅ ✅ ❌
Provider Agnostic ✅ ❌ (Claude only) ❌
Local Models ✅ ❌ ✅
IDE Integration ✅ ✅ Native

Summary

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:

Resources

Articles, Blogs, Essays

CLI Interface

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


Tags: ai   agent   coding   tool   specification driven development  

Last modified 03 November 2026