opencode-init

Generates and validates a project-scoped opencode.json configuration file for OpenCode.

6|Updated May 18, 2026
One-click install
npx skills add https://github.com/mokhtarabadi/cognitive-lead-hq --skill opencode-init-mokhtarabadi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: opencode-init
Source: https://github.com/mokhtarabadi/cognitive-lead-hq/tree/main/skill-templates/opencode-init
Command: npx skills add https://github.com/mokhtarabadi/cognitive-lead-hq --skill opencode-init-mokhtarabadi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Writing a correct opencode.json by hand is error-prone: the public schema has strict shapes for formatter, LSP, and permission blocks, and mixing global-only keys like mcp or plugin into a project file breaks the config. This Skill analyzes a project, asks the user for missing choices, and emits a validated configuration file. ## Core Features & Use Cases - Project Analysis: Reads package manifests, README, stack files, and existing config to determine formatter, LSP, instructions, and permission needs. - Schema-Compliant Generation: Emits only project-allowed keys ($schema, default_agent, instructions, formatter, lsp, permission) and enforces the mandatory ZAC bash deny set for git commands. - Pre-Write Validation: Runs scripts/validate-opencode.py to reject flat formatter objects, language-server wrappers, literal secrets, and invented placeholder values before writing. - Use Case: You start a new TypeScript project and need OpenCode configured with the typescript-language-server, a formatter, and safe git permissions. The Skill inspects the repo, confirms your default agent, and writes a validated opencode.json to the project root. ## Quick Start Analyze this project and generate a validated opencode.json configuration file for it.

Frequently Asked Questions about opencode-init

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate an opencode.json config file for my project?▼

Run the opencode-init Skill against your project root. It analyzes package manifests and stack files, asks you for missing choices like default_agent and formatter, then writes a validated opencode.json matching the public schema at opencode.ai/config.json.

What keys are allowed in a project-level opencode.json?▼

Only $schema, default_agent, instructions, formatter, lsp, and permission are allowed in project output. The mcp and plugin keys are global-only and must live in ~/.config/opencode/opencode.json or a global plugins directory.

Why does my opencode.json fail with 'Missing key formatter.command'?▼

This error occurs when formatter is written as a flat {command, extensions} object. The schema requires a named map like {"spotless-java": {"command": [...], "extensions": [...]}}, or the boolean values true or false.

Can I configure MCP servers in a project opencode.json?▼

No. MCP servers are global-only and are rejected by the validator if present in project output. Install shared servers in ~/.config/opencode/opencode.json, using {env:NAME} placeholders for secrets instead of literal values.

How do I configure an LSP server in opencode.json?▼

Define lsp as a flat map of server names to objects with a required command list, for example {"typescript": {"command": ["typescript-language-server", "--stdio"]}}. Do not wrap entries in a language-server key, and use env rather than environment for variables.

What is the ZAC bash deny set in opencode permissions?▼

ZAC (Zero Autonomous Commit) requires eight git command patterns set to deny in permission.bash: git add, git checkout, git commit, and git push, each with and without a trailing wildcard. The validator fails any generated file missing these entries.