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


Tags: ai   agent   coding   tool   specification driven development  

Last modified 06 April 2026