← ClaudeAtlas

opencode-sdklisted

Use this skill when using the OpenCode JavaScript/TypeScript SDK (@opencode-ai/sdk) to programmatically control OpenCode, create sessions, send prompts, manage files, control the TUI, stream events, or build external integrations. Covers both full lifecycle (server+client) and client-only modes, all API methods, structured output, and type safety.
Timmy6942025/opencode-builder-skill · ★ 1 · AI & Automation · score 72
Install: claude install-skill Timmy6942025/opencode-builder-skill
# OpenCode JavaScript/TypeScript SDK (`@opencode-ai/sdk`) > **📚 Official Docs:** For the latest information, always refer to the official documentation: > [https://opencode.ai/docs/sdk/](https://opencode.ai/docs/sdk/) Type-safe JavaScript/TypeScript client for the OpenCode server. Use it to build integrations, automate workflows, and control OpenCode programmatically. All types are auto-generated from the server's OpenAPI 3.1 specification and available in the [types file](https://github.com/anomalyco/opencode/blob/dev/packages/sdk/js/src/gen/types.gen.ts). --- ## Installation ```bash npm install @opencode-ai/sdk # or bun add @opencode-ai/sdk ``` --- ## Two Client Modes ### Full Lifecycle (`createOpencode`) Starts an OpenCode server and returns a connected client. Use this when you own the server lifecycle. ```typescript import { createOpencode } from "@opencode-ai/sdk" const { client, server } = await createOpencode({ hostname: "127.0.0.1", port: 4096, timeout: 5000, config: { model: "anthropic/claude-3-5-sonnet-20241022", }, }) console.log(`Server running at ${server.url}`) // Use the client... server.close() ``` **Options:** | Option | Type | Description | Default | |---|---|---|---| | `hostname` | `string` | Server hostname | `127.0.0.1` | | `port` | `number` | Server port | `4096` | | `signal` | `AbortSignal` | Abort signal for cancellation | `undefined` | | `timeout` | `number` | Timeout in ms for server start | `5000` | | `config` | `Con