OpenCode Tutorial

repository·main·Indexed 23 days ago

https://github.com/vbgate/learn-opencode

A practical, zero-base tutorial designed to teach users how to use AI for real-world work. The curriculum covers installation across Windows, macOS, and Linux, basic setup, and a five-stage learning path ranging from quick start and daily usage to efficient workflows, scenario practice (content creation, programming, office efficiency), and deep customization of Agents, Skills, and MCP extensions.

Tokens
289.2K
Snippets
764
Records
1.3K
Agent score
81%

What's inside OpenCode

  1. Overview of the OpenCode tutorial curriculum

    main

    The OpenCode tutorial is structured into five progressive stages designed to take users from zero base to advanced customization:

    • Stage 1: Quick Start (Required, ~30 mins): Installation, network configuration, connecting models, and your first conversation.
    • Stage 2: Daily Usage (Required, ~1.5 hours): Interface operations, session management, and file referencing.
    • Stage 3: Efficient Workflows (Required, ~1 hour): Plan/Build modes, Agent collaboration, and project initialization.
    • Stage 4: Scenario Practice (Elective): Choose a track based on your needs:
      • Content Creation: Official accounts, Xiaohongshu, novels, scripts, marketing copy.
      • Programmer: Daily development, refactoring, testing, Git documentation, CI/CD.
      • Efficiency/Office: File organization, data processing, automation scripts.
    • Stage 5: Deep Customization (Elective): Custom Agents, Skills, commands, MCP extensions, and IDE integration.
  2. What is OpenCode?

    main

    OpenCode is an open-source AI coding assistant that runs in your terminal (TUI-based). It follows the concept of Vibe Coding, where the user acts as a commander rather than an executor. Instead of manually finding files and editing code, you provide natural language instructions, and the AI understands your project, modifies code, executes commands, and completes multi-step tasks automatically.

    Key advantages of OpenCode over IDE-based tools (like Cursor or GitHub Copilot) include:

    • Model Freedom: Supports over 75 models (Claude, GPT, Gemini, Llama, DeepSeek, Qwen, etc.).
    • Open Source: Provides control and data privacy via direct API or local model usage.
    • TUI-based Workflow: Lightweight, fast, and suitable for automation or CI/CD embedding.
  3. Overview of Phase 5: Deep Customization

    main

    Phase 5 is a reference-oriented guide designed for users who want to move beyond basic usage and deeply customize OpenCode. Instead of a linear tutorial, this phase serves as a manual to be consulted on-demand when you need to build personalized AI tools, extend functionality, or integrate OpenCode into your existing development workflow.

    Key capabilities covered in this phase:

    • Configuration: Mastering the complete opencode.json system.
    • Personalization: Creating custom Agents, Skills, and Quick Commands.
    • Security & UI: Configuring permission controls, themes, and keyboard shortcuts.
    • Extensibility: Implementing MCP extensions, Plugins, Hooks, and SDK development.
    • Integration: Connecting with IDEs (VS Code, Zed, JetBrains), GitHub, GitLab, and Remote Mode (Server/Web interface).
    • Advanced Management: Using Context Compaction for long conversations and Enterprise-grade features.
  4. Overview of OpenCode Advanced Customization

    main

    The Advanced Customization stage (Phase 5) is designed as a reference manual for developers looking to deeply customize OpenCode. Instead of a linear tutorial, it is intended to be used as a lookup guide when specific needs arise.

    By exploring these advanced modules, you can master the complete configuration system, create custom Agents, Skills, and commands, configure permissions and themes, implement MCP extensions, and integrate OpenCode with IDEs or remote environments.

  5. Overview of Opencode SDK Modules

    main

    The OpencodeClient class provides access to 21 specialized API modules. These modules allow developers to manage sessions, files, projects, configuration, authentication, and more. Key modules include:

    • session: Core module for message sending and history management.
    • project: Project management.
    • file: File operations.
    • find: Search functionality.
    • config: Configuration management.
    • auth: Authentication management.
    • tui: TUI (Terminal User Interface) control.
    • mcp: MCP server management.
    • lsp: LSP server status.
  6. Overview of Phase 2: Daily Usage

    main

    Phase 2 focuses on mastering the OpenCode interface and core operations required for daily AI coding tasks. The primary goal is to enable users to perform file operations, code reading, and text generation independently.

    Key Learning Objectives:

    • Familiarity with the OpenCode interface and core operations.
    • Mastery of session management, including creating, switching, undoing, and exporting sessions.
    • Proficiency with core command triggers: @ for referencing files, ! for executing commands, and / for slash commands.
  7. Explore OpenCode features and capabilities

    main

    OpenCode provides several key capabilities for working with AI assistants:

    • Global Model Support: Native support for various models including Claude, OpenAI, DeepSeek, and Ollama.
    • Multi-file Context: Ability to read entire projects at once to understand code relationships, rather than feeding files one by one.
    • Deep Customization: Support for creating custom Agents, Skills, Commands, and Themes to build personalized AI tools.
    • Source Code Analysis: Features are taught based on official OpenCode source code analysis rather than theoretical tutorials.
  8. OpenCode Quick Reference Index

    main
    The OpenCode Quick Reference provides a centralized index for all essential technical documentation, including keyboard shortcuts, slash commands, CLI arguments, configuration schemas, and model provider details. Use this index to navigate to specific technical guides for troubleshooting, automation, or advanced configuration.
  9. OpenCode Quick Reference Guide Overview

    main

    The OpenCode Quick Reference Guide (速查手册) provides a centralized directory for all technical specifications and troubleshooting resources. Use this guide to navigate between keyboard shortcuts, slash commands, CLI references, configuration options, model providers, and prompt templates.

    How to use the guide:

  10. What is Chrome DevTools MCP?

    main

    Chrome DevTools MCP is an official Google browser MCP that allows an AI agent to connect directly to your active Chrome browser session.

    Unlike traditional browser automation (like Puppeteer or Playwright) which typically launches a fresh, isolated instance, Chrome DevTools MCP:

    • Reuses your existing logged-in state: You don't need to sign in to websites again.
    • Connects to an already open Chrome: It works with your current session.
    • Uses uid for element targeting: Instead of CSS or XPath, it uses temporary identifiers from the page's accessibility tree. Note that uid values are not permanent and will change if the page refreshes.
    • Provides DevTools-level access: The AI can read the Network panel, inspect the Elements panel, and analyze performance data directly.
  11. What is the ACP Protocol

    main

    The Agent Client Protocol (ACP) is an open protocol that standardizes communication between code editors and AI coding agents.

    OpenCode implements this protocol by running opencode acp as a child process. The editor communicates with the process via stdin/stdout using the nd-JSON (newline-delimited JSON) format for JSON-RPC communication.

    Communication Flow: Editor <-> JSON-RPC (stdio) <-> opencode acp

  12. What is a Rule File and how does it work?

    main

    A rule file is a Markdown file containing instructions you want the AI to follow. OpenCode automatically reads these files and injects their content into the system prompt for every message sent.

    Key Feature: Hot-Reloading Rule file changes take effect immediately. You do not need to restart OpenCode or create a new session after modifying a rule file. OpenCode re-reads the file every time a message is sent.