### Install OpenCode with Mise Source: https://opencode.ai/docs Install OpenCode using Mise. ```bash mise use -g github:anomalyco/opencode ``` -------------------------------- ### Install OpenCode via script Source: https://opencode.ai/docs The easiest way to install OpenCode is through this install script. ```bash curl -fsSL https://opencode.ai/install | bash ``` -------------------------------- ### Install OpenCode with Yarn Source: https://opencode.ai/docs Install OpenCode globally using Yarn. ```bash yarn global add opencode-ai ``` -------------------------------- ### Run OpenCode Source: https://opencode.ai/docs Start OpenCode in your project directory. ```bash opencode ``` -------------------------------- ### Install OpenCode with Bun Source: https://opencode.ai/docs Install OpenCode globally using Bun. ```bash bun install -g opencode-ai ``` -------------------------------- ### Install OpenCode with npm Source: https://opencode.ai/docs Install OpenCode globally using npm. ```bash npm install -g opencode-ai ``` -------------------------------- ### Install OpenCode with Scoop Source: https://opencode.ai/docs Install OpenCode on Windows using Scoop. ```bash scoop install opencode ``` -------------------------------- ### Ask OpenCode a question Source: https://opencode.ai/docs Example of asking OpenCode a question about the codebase, using the @ key for file search. ```cli How is authentication handled in @packages/functions/src/api/index.ts ``` -------------------------------- ### Install OpenCode with pnpm Source: https://opencode.ai/docs Install OpenCode globally using pnpm. ```bash pnpm install -g opencode-ai ``` -------------------------------- ### Example: Start Web Backend and Attach TUI (Bash) Source: https://opencode.ai/docs/cli Demonstrates how to start an OpenCode backend server for web/mobile access and then attach a TUI from another terminal to that running backend. ```bash # Start the backend server for web/mobile access opencode web --port 4096 --hostname 0.0.0.0 ``` ```bash # In another terminal, attach the TUI to the running backend opencode attach http://10.20.30.40:4096 ``` -------------------------------- ### Provide feedback on plan Source: https://opencode.ai/docs Example of providing feedback and additional details to OpenCode's plan, including an image reference. ```text We'd like to design this new screen using a design I've used before. [Image #1] Take a look at this image and use it as a reference. ``` -------------------------------- ### Install OpenCode with Chocolatey Source: https://opencode.ai/docs Install OpenCode on Windows using Chocolatey. ```bash choco install opencode ``` -------------------------------- ### Describe feature to OpenCode in Plan mode Source: https://opencode.ai/docs Example of describing a new feature to OpenCode in Plan mode. ```text When a user deletes a note, we'd like to flag it as deleted in the database. Then create a screen that shows all the recently deleted notes. From this screen, the user can undelete a note or permanently delete it. ``` -------------------------------- ### API key input prompt Source: https://opencode.ai/docs Example of the API key input prompt when configuring OpenCode. ```text ┌ API key │ │ └ enter ``` -------------------------------- ### Install OpenCode on Arch Linux Source: https://opencode.ai/docs Install OpenCode on Arch Linux using pacman or paru. ```bash sudo pacman -S opencode # Arch Linux (Stable) paru -S opencode-bin # Arch Linux (Latest from AUR) ``` -------------------------------- ### Run OpenCode with Docker Source: https://opencode.ai/docs Run OpenCode using Docker. ```bash docker run -it --rm ghcr.io/anomalyco/opencode ``` -------------------------------- ### Requesting a Feature Implementation Source: https://opencode.ai/docs An example of a detailed prompt to OpenCode AI asking it to implement authentication for a specific route, referencing existing code for guidance. ```plaintext We need to add authentication to the /settings route. Take a look at how this is handled in the /notes route in @packages/functions/src/notes.ts and implement the same logic in @packages/functions/src/settings.ts ``` -------------------------------- ### Install OpenCode with Homebrew Source: https://opencode.ai/docs Install OpenCode on macOS and Linux using Homebrew. ```bash brew install anomalyco/tap/opencode ``` -------------------------------- ### Initialize AGENTS.md in OpenCode TUI Source: https://opencode.ai/docs/tui Start a guided setup to create or update the "AGENTS.md" file using "/init". ```bash /init ``` -------------------------------- ### Initialize OpenCode for project Source: https://opencode.ai/docs Initialize OpenCode for the current project to analyze it and create an AGENTS.md file. ```cli /init ``` -------------------------------- ### Install GitHub Agent Source: https://opencode.ai/docs/cli Sets up the necessary GitHub Actions workflow and guides through the configuration process for the GitHub agent in a repository. ```bash opencode github install ``` -------------------------------- ### Authentication Setup Source: https://opencode.ai/docs/sdk Provides an example of how to set API authentication credentials for a specific provider. ```javascript await client.auth.set({ path: { id: "anthropic" }, body: { type: "api", key: "your-api-key" }, }) ``` -------------------------------- ### Switch to Plan mode Source: https://opencode.ai/docs Use the Tab key to switch to Plan mode. ```text ``` -------------------------------- ### Navigate to project directory Source: https://opencode.ai/docs Change the current directory to your project path before running OpenCode. ```bash cd /path/to/project ``` -------------------------------- ### Project API Examples Source: https://opencode.ai/docs/sdk Examples of using the `project.list()` method to list all projects and `project.current()` to get the current project. ```javascript // List all projects const projects = await client.project.list() // Get current project const currentProject = await client.project.current() ``` -------------------------------- ### Start OpenCode Web Interface (Bash) Source: https://opencode.ai/docs/cli Starts a headless OpenCode server with a web interface, opening a browser to access it. HTTP basic auth can be enabled with OPENCODE_SERVER_PASSWORD. ```bash opencode web ``` -------------------------------- ### Start Web Interface Source: https://opencode.ai/docs/web Command to start the OpenCode web interface. ```bash opencode web ``` -------------------------------- ### Example tui.json Configuration Source: https://opencode.ai/docs/tui This snippet shows a complete example of a `tui.json` file, demonstrating various configuration options for the TUI, including theme, keybinds, scrolling, diff style, mouse, and attention settings. ```json { "$schema": "https://opencode.ai/tui.json", "theme": "opencode", "leader_timeout": 2000, "keybinds": { "leader": "ctrl+x", "command_list": "ctrl+p" }, "scroll_speed": 3, "scroll_acceleration": { "enabled": false }, "diff_style": "auto", "mouse": true, "attention": { "enabled": true, "notifications": true, "sound": true, "volume": 0.4, "sound_pack": "opencode.default", "sounds": { "error": "./sounds/error.mp3" } } } ``` -------------------------------- ### Confirm changes in Build mode Source: https://opencode.ai/docs Confirm to OpenCode to proceed with making changes based on the plan. ```text Sounds good! Go ahead and make the changes. ``` -------------------------------- ### Install OpenCode Plugin (Bash) Source: https://opencode.ai/docs/cli Installs a plugin and updates the OpenCode configuration. An alias `plug` is also available. ```bash opencode plugin ``` ```bash opencode plug ``` -------------------------------- ### Run /connect command Source: https://opencode.ai/docs Run the /connect command in the TUI to configure API keys. ```cli /connect ``` -------------------------------- ### Config File Example Source: https://opencode.ai/docs/web Example configuration for OpenCode web server settings in opencode.json. ```json { "server": { "port": 4096, "hostname": "0.0.0.0", "mdns": true, "cors": ["https://example.com"] } } ``` -------------------------------- ### Config API Examples Source: https://opencode.ai/docs/sdk Examples of using the `config.get()` method to retrieve configuration information and `config.providers()` to list providers and default models. ```javascript const config = await client.config.get() const { providers, default: defaults } = await client.config.providers() ``` -------------------------------- ### Install SDK Source: https://opencode.ai/docs/sdk Command to install the OpenCode SDK from npm. ```bash npm install @opencode-ai/sdk ``` -------------------------------- ### App API Examples Source: https://opencode.ai/docs/sdk Examples of using the `app.log()` method to write a log entry and `app.agents()` to list available agents. ```javascript // Write a log entry await client.app.log({ body: { service: "my-app", level: "info", message: "Operation completed", }, }) // List available agents const agents = await client.app.agents() ``` -------------------------------- ### Install xclip for Copy/Paste on X11 Linux Source: https://opencode.ai/docs/troubleshooting Install xclip on X11-based Linux systems to enable copy/paste functionality within OpenCode. ```bash apt install -y xclip ``` -------------------------------- ### Example TUI Configuration File (tui.json) Source: https://opencode.ai/docs/config This JSON example demonstrates how to configure OpenCode's Terminal User Interface settings, including scroll behavior, mouse support, and attention notifications. It references the `tui.json` schema for validation. ```json { "$schema": "https://opencode.ai/tui.json", "scroll_speed": 3, "scroll_acceleration": { "enabled": true }, "diff_style": "auto", "mouse": true, "attention": { "enabled": true, "notifications": true, "sound": true, "volume": 0.4 } } ``` -------------------------------- ### Start OpenCode TUI with Project (Bash) Source: https://opencode.ai/docs/cli Starts the OpenCode terminal user interface, optionally specifying a project to load. ```bash opencode [project] ``` -------------------------------- ### Install wl-clipboard for Copy/Paste on Wayland Linux Source: https://opencode.ai/docs/troubleshooting Install wl-clipboard on Wayland-based Linux systems to enable copy/paste functionality within OpenCode. ```bash apt install -y wl-clipboard ``` -------------------------------- ### Start OpenCode TUI in current directory Source: https://opencode.ai/docs/tui Launch the OpenCode TUI for the current working directory. ```bash opencode ``` -------------------------------- ### Example AGENTS.md File Source: https://opencode.ai/docs/rules An example of content that can be placed in an `AGENTS.md` file, demonstrating project structure, code standards, and monorepo conventions. ```markdown # SST v3 Monorepo Project This is an SST v3 monorepo with TypeScript. The project uses bun workspaces for package management. ## Project Structure - `packages/` - Contains all workspace packages (functions, core, web, etc.) - `infra/` - Infrastructure definitions split by service (storage.ts, api.ts, web.ts) - `sst.config.ts` - Main SST configuration with dynamic imports ## Code Standards - Use TypeScript with strict mode enabled - Shared code goes in `packages/core/` with proper exports configuration - Functions go in `packages/functions/` - Infrastructure should be split into logical files in `infra/` ## Monorepo Conventions - Import shared modules using workspace names: `@my-app/core/example` ``` -------------------------------- ### Start OpenCode ACP Server (Bash) Source: https://opencode.ai/docs/cli Starts an ACP (Agent Client Protocol) server that communicates via stdin/stdout using nd-JSON. ```bash opencode acp ``` -------------------------------- ### Install Helicone Session Tracking Plugin Source: https://opencode.ai/docs/providers Installs the OpenCode plugin for automatic Helicone session tracking via npm. ```bash npm install -g opencode-helicone-session ``` -------------------------------- ### .ignore Source: https://opencode.ai/docs/tools Example .ignore file to include normally ignored directories. ```text !node_modules/ !dist/ !build/ ``` -------------------------------- ### Start OpenCode TUI for a specific directory Source: https://opencode.ai/docs/tui Launch the OpenCode TUI for a project at a specified path. ```bash opencode /path/to/project ``` -------------------------------- ### opencode.json Source: https://opencode.ai/docs/tools Example configuration using wildcards to control multiple tools from an MCP server. ```json { "$schema": "https://opencode.ai/config.json", "permission": { "mymcp_*": "ask" } } ``` -------------------------------- ### opencode.json Source: https://opencode.ai/docs/commands Example of using the `description` option to provide a brief description for a command. ```json { "command": { "test": { "description": "Run tests with coverage" } } } ``` -------------------------------- ### Running a custom command Source: https://opencode.ai/docs/commands Example of executing a custom command in the TUI. ```bash /my-command ``` -------------------------------- ### Example SKILL.md Source: https://opencode.ai/docs/skills Content for a `SKILL.md` file, demonstrating frontmatter and markdown. ```markdown --- name: git-release description: Create consistent releases and changelogs license: MIT compatibility: opencode metadata: audience: maintainers workflow: github --- ## What I do - Draft release notes from merged PRs - Propose a version bump - Provide a copy-pasteable `gh release create` command ## When to use me Use this when you are preparing a tagged release. Ask clarifying questions if the target versioning scheme is unclear. ``` -------------------------------- ### Configure skill permissions Source: https://opencode.ai/docs/skills Example `opencode.json` configuration for skill permissions. ```json { "permission": { "skill": { "*": "allow", "pr-review": "allow", "internal-*": "deny", "experimental-*": "ask" } } } ``` -------------------------------- ### Schedule Example Source: https://opencode.ai/docs/github Run OpenCode on a schedule to perform automated tasks. ```yaml name: Scheduled OpenCode Task on: schedule: - cron: "0 9 * * 1" # Every Monday at 9am UTC jobs: opencode: runs-on: ubuntu-latest permissions: id-token: write contents: write pull-requests: write issues: write steps: - name: Checkout repository uses: actions/checkout@v6 with: persist-credentials: false - name: Run OpenCode uses: anomalyco/opencode/github@latest env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} with: model: anthropic/claude-sonnet-4-20250514 prompt: | Review the codebase for any TODO comments and create a summary. If you find issues worth addressing, open an issue to track them. ``` -------------------------------- ### Using the mcp_everything Tool in a Prompt Source: https://opencode.ai/docs/mcp-servers Demonstrates how to invoke the 'mcp_everything' tool within a prompt after it has been configured as a local MCP server. ```txt use the mcp_everything tool to add the number 3 and 4 ``` -------------------------------- ### Attach OpenCode Run to a Headless Server (Bash) Source: https://opencode.ai/docs/cli Demonstrates how to start a headless OpenCode server and then attach a `run` command to it, avoiding cold boot times for subsequent runs. ```bash # Start a headless server in one terminal opencode serve ``` ```bash # In another terminal, run commands that attach to it opencode run --attach http://localhost:4096 "Explain async/await in JavaScript" ``` -------------------------------- ### Initial Connect Command Output Source: https://opencode.ai/docs/providers Shows the initial output of the `/connect` command, prompting the user to select a provider, with 'Other' as an option for custom integration. ```bash $ /connect ┌ Add credential │ ◆ Select provider │ ... │ ● Other └ ``` -------------------------------- ### Requesting a Function Refactor Source: https://opencode.ai/docs An example of a prompt to OpenCode AI asking it to refactor a function in a specified file. ```plaintext Can you refactor the function in @packages/functions/src/api/index.ts? ``` -------------------------------- ### Automatic GitHub Installation Command Source: https://opencode.ai/docs/github Command to run for automatic setup of OpenCode's GitHub integration, including app installation, workflow creation, and secret setup. ```bash opencode github install ``` -------------------------------- ### Launch OpenCode with Inline Google Vertex AI Credentials Source: https://opencode.ai/docs/providers Starts OpenCode by setting Google Cloud project ID and service account credentials as temporary environment variables. ```bash GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json GOOGLE_CLOUD_PROJECT=your-project-id opencode ``` -------------------------------- ### Redo Command Source: https://opencode.ai/docs The command to reapply changes that were previously undone. ```shell /redo ``` -------------------------------- ### Undo Command Source: https://opencode.ai/docs The command to revert the last changes made by OpenCode AI. ```shell /undo ``` -------------------------------- ### opencode.json Configuration Example Source: https://opencode.ai/docs/rules Demonstrates how to use the `instructions` field in `opencode.json` to specify paths to rule files, including glob patterns for multiple locations. ```json { "$schema": "https://opencode.ai/config.json", "instructions": ["docs/development-standards.md", "test/testing-guidelines.md", "packages/*/AGENTS.md"] } ``` -------------------------------- ### Share Command Source: https://opencode.ai/docs The command to generate a shareable link for the current conversation with OpenCode AI. ```shell /share ``` -------------------------------- ### Get Current Path Source: https://opencode.ai/docs/sdk Example of calling the `path.get()` method to retrieve current path information. ```javascript // Get current path information const pathInfo = await client.path.get() ``` -------------------------------- ### Flow configuration Source: https://opencode.ai/docs/gitlab Example GitLab CI/CD job configuration for running OpenCode, including installation, authentication, and execution steps. ```yaml image: node:22-slim commands: - echo "Installing opencode" - npm install --global opencode-ai - echo "Installing glab" - export GITLAB_TOKEN=$GITLAB_TOKEN_OPENCODE - apt-get update --quiet && apt-get install --yes curl wget gpg git && rm --recursive --force /var/lib/apt/lists/* - curl --silent --show-error --location "https://raw.githubusercontent.com/upciti/wakemeops/main/assets/install_repository" | bash - apt-get install --yes glab - echo "Configuring glab" - echo $GITLAB_HOST - echo "Creating OpenCode auth configuration" - mkdir --parents ~/.local/share/opencode - | cat > ~/.local/share/opencode/auth.json << EOF { "anthropic": { "type": "api", "key": "$ANTHROPIC_API_KEY" } } EOF - echo "Configuring git" - git config --global user.email "opencode@gitlab.com" - git config --global user.name "OpenCode" - echo "Testing glab" - glab issue list - echo "Running OpenCode" - | opencode run " You are an AI assistant helping with GitLab operations. Context: $AI_FLOW_CONTEXT Task: $AI_FLOW_INPUT Event: $AI_FLOW_EVENT Please execute the requested task using the available GitLab tools. Be thorough in your analysis and provide clear explanations. Please use the glab CLI to access data from GitLab. The glab CLI has already been authenticated. You can run the corresponding commands. If you are asked to summarize an MR or issue or asked to provide more information then please post back a note to the MR/Issue so that the user can see it. You don't need to commit or push up changes, those will be done automatically based on the file changes you make. " - git checkout --branch $CI_WORKLOAD_REF origin/$CI_WORKLOAD_REF - echo "Checking for git changes and pushing if any exist" - | if ! git diff --quiet || ! git diff --cached --quiet || [ --not --zero "$(git ls-files --others --exclude-standard)" ]; then echo "Git changes detected, adding and pushing..." git add . if git diff --cached --quiet; then echo "No staged changes to commit" else echo "Committing changes to branch: $CI_WORKLOAD_REF" git commit --message "Codex changes" echo "Pushing changes up to $CI_WORKLOAD_REF" git push https://gitlab-ci-token:$GITLAB_TOKEN@$GITLAB_HOST/gl-demo-ultimate-dev-ai-epic-17570/test-java-project.git $CI_WORKLOAD_REF echo "Changes successfully pushed" fi else echo "No git changes detected, skipping push" fi variables: - ANTHROPIC_API_KEY - GITLAB_TOKEN_OPENCODE - GITLAB_HOST ``` -------------------------------- ### Define Grep by Vercel Usage Rule in AGENTS.md Source: https://opencode.ai/docs/mcp-servers Add a rule to your `AGENTS.md` file to guide the agent to use `gh_grep` for searching code examples from GitHub when unsure how to proceed. ```md If you are unsure how to do something, use `gh_grep` to search code examples from GitHub. ``` -------------------------------- ### Configure Xvfb for Headless Copy/Paste on Linux Source: https://opencode.ai/docs/troubleshooting After installing xvfb, execute these commands to start a virtual display server and set the DISPLAY environment variable, enabling copy/paste in headless OpenCode environments. ```bash Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & export DISPLAY=:99.0 ``` -------------------------------- ### opencode.json with Remote Instruction Files Source: https://opencode.ai/docs/rules An example `opencode.json` configuration demonstrating how to load instruction files from a remote URL. ```json { "$schema": "https://opencode.ai/config.json", "instructions": ["https://raw.githubusercontent.com/my-org/shared-rules/main/style.md"] } ``` -------------------------------- ### Initialize MCP Servers Configuration in opencode.json Source: https://opencode.ai/docs/config Use the `mcp` option to configure MCP servers, starting with an empty object if no specific servers are defined yet. ```json { "$schema": "https://opencode.ai/config.json", "mcp": {} } ``` -------------------------------- ### Configure Multiple References in opencode.jsonc Source: https://opencode.ai/docs/references This example shows how to configure both local directory and Git repository references in the `opencode.jsonc` file, including descriptions for agent context. ```jsonc { "$schema": "https://opencode.ai/config.json", "references": { "docs": { "path": "../product-docs", "description": "Use for product behavior and documentation conventions" }, "sdk": { "repository": "anomalyco/opencode-sdk-js", "branch": "main", "description": "Use for JavaScript SDK implementation details" } } } ``` -------------------------------- ### Start OpenCode TUI (Bash) Source: https://opencode.ai/docs/cli Starts the OpenCode terminal user interface by default when no arguments are provided. ```bash opencode ``` -------------------------------- ### Basic Usage of `opencode serve` Source: https://opencode.ai/docs/server Shows the command-line syntax for running the opencode server with optional parameters. ```bash opencode serve [--port ] [--hostname ] [--cors ] ``` -------------------------------- ### Start Headless OpenCode Server (Bash) Source: https://opencode.ai/docs/cli Initiates an HTTP server for API access to OpenCode functionality without the TUI. Set `OPENCODE_SERVER_PASSWORD` for basic auth. ```bash opencode serve ``` -------------------------------- ### Configure Instruction Files for the Model in opencode.json Source: https://opencode.ai/docs/config Provide an array of paths and glob patterns to instruction files, such as `CONTRIBUTING.md` or `docs/guidelines.md`, for the model to follow. ```json { "$schema": "https://opencode.ai/config.json", "instructions": ["CONTRIBUTING.md", "docs/guidelines.md", ".cursor/rules/*.md"] } ``` -------------------------------- ### Install xsel for Copy/Paste on X11 Linux Source: https://opencode.ai/docs/troubleshooting Install xsel on X11-based Linux systems as an alternative to xclip for enabling copy/paste functionality in OpenCode. ```bash apt install -y xsel ``` -------------------------------- ### opencode.json with Local Instruction Files Source: https://opencode.ai/docs/rules An example `opencode.json` configuration showing how to include local instruction files using relative paths and glob patterns. ```json { "$schema": "https://opencode.ai/config.json", "instructions": ["CONTRIBUTING.md", "docs/guidelines.md", ".cursor/rules/*.md"] } ``` -------------------------------- ### Example of Using a Reference in TUI Autocomplete Source: https://opencode.ai/docs/references This example demonstrates how to use the `@alias` syntax in the TUI to attach a reference or search for files within it. ```text Compare this implementation with @sdk/src/client.ts ``` -------------------------------- ### Use Context7 MCP in a Prompt Source: https://opencode.ai/docs/mcp-servers Add `use context7` to your prompts to instruct the agent to use the Context7 MCP server for searching documentation. ```txt Configure a Cloudflare Worker script to cache JSON API responses for five minutes. use context7 ``` -------------------------------- ### Install Xvfb for Headless Copy/Paste on Linux Source: https://opencode.ai/docs/troubleshooting Install xvfb to provide a virtual display server, which is required for copy/paste functionality in OpenCode within headless Linux environments. ```bash apt install -y xvfb ``` -------------------------------- ### Connect Command: Enter API Key Source: https://opencode.ai/docs/providers Displays the prompt for entering the API key for the custom provider after its ID has been specified, noting that further configuration is required in `opencode.json`. ```bash $ /connect ┌ Add credential │ ▲ This only stores a credential for myprovider - you will need to configure it in opencode.json, check the docs for examples. │ ◇ Enter your API key │ sk-... └ ``` -------------------------------- ### OpenCode Models Command Overview Source: https://opencode.ai/docs/cli Displays all available models from configured providers, formatted as `provider/model`. Optionally filter by a specific provider. ```bash opencode models [provider] ``` -------------------------------- ### Run OpenCode with a Specific Prompt (Bash) Source: https://opencode.ai/docs/cli Provides an example of running OpenCode with a specific natural language prompt directly from the command line. ```bash opencode run Explain the use of context in Go ``` -------------------------------- ### Start OpenCode server in WSL for external connections Source: https://opencode.ai/docs/windows-wsl Command to start the OpenCode server in WSL, making it accessible from outside the WSL environment by specifying the hostname and port. ```bash opencode serve --hostname 0.0.0.0 --port 4096 ``` -------------------------------- ### ~/.config/opencode/agents/security-auditor.md Source: https://opencode.ai/docs/agents Example configuration for a security auditor subagent. ```markdown --- description: Performs security audits and identifies vulnerabilities mode: subagent permission: edit: deny --- You are a security expert. Focus on identifying potential security issues. Look for: - Input validation vulnerabilities - Authentication and authorization flaws - Data exposure risks - Dependency vulnerabilities - Configuration security issues ``` -------------------------------- ### .opencode/plugins/example.js Source: https://opencode.ai/docs/plugins Basic structure of a JavaScript plugin, showing the plugin function signature and context object. ```javascript export const MyPlugin = async ({ project, client, $, directory, worktree }) => { console.log("Plugin initialized!") return { // Hook implementations go here } } ``` -------------------------------- ### opencode.json Source: https://opencode.ai/docs/tools Example configuration for tool permissions, allowing, denying, or asking for approval for specific tools. ```json { "$schema": "https://opencode.ai/config.json", "permission": { "edit": "deny", "bash": "ask", "webfetch": "allow" } } ``` -------------------------------- ### ~/.config/opencode/agents/docs-writer.md Source: https://opencode.ai/docs/agents Example configuration for a documentation writing subagent. ```markdown --- description: Writes and maintains project documentation mode: subagent permission: bash: deny --- You are a technical writer. Create clear, comprehensive documentation. Focus on: - Clear explanations - Proper structure - Code examples - User-friendly language ``` -------------------------------- ### opencode.json Source: https://opencode.ai/docs/agents Example of overriding the model for a specific agent. ```json { "agent": { "plan": { "model": "anthropic/claude-haiku-4-20250514" } } } ``` -------------------------------- ### tui.json Source: https://opencode.ai/docs/themes Example of specifying a theme in the tui.json configuration file. ```json { "$schema": "https://opencode.ai/tui.json", "theme": "tokyonight" } ``` -------------------------------- ### Basic OpenCode Configuration in JSONC Source: https://opencode.ai/docs/config This snippet shows a basic OpenCode configuration file using JSONC format, including schema reference, model selection, autoupdate setting, and server port. ```jsonc { "$schema": "https://opencode.ai/config.json", "model": "anthropic/claude-sonnet-4-5", "autoupdate": true, "server": { "port": 4096, }, } ``` -------------------------------- ### opencode.json Source: https://opencode.ai/docs/models Example OpenCode configuration file specifying a model. ```json { "$schema": "https://opencode.ai/config.json", "model": "anthropic/claude-sonnet-4-20250514" } ```