Skip to main content

OpenCode quick start with CodeGraph

Launch the current OpenCode integration and use its supported command set. The page explains the purpose, usage steps, and result checks.

User Guides

The repository launcher configures the CodeGraph MCP server, LSP server, and opencode-codegraph plugin for the current checkout. Run it only after the CodeGraph project has been imported and its CPG freshness has been checked.

Start an interactive session

python scripts/run_opencode_codegraph.py --project <project-name>

The current launcher default is openai/gpt-5.4. Override the model only when it is approved and available in your OpenCode environment:

python scripts/run_opencode_codegraph.py --project <project-name> --model <provider/model>

The source package version is opencode-codegraph 0.1.38. The launcher derives the published dependency version from the package manifest; do not freeze an older npm range in local setup instructions.

Supported CodeGraph commands

The current .opencode/commands directory contains:

  • /audit — run a bounded CodeGraph audit workflow;
  • /continue — continue the current explicit CodeGraph session;
  • /explain — explain selected code with project evidence;
  • /next — inspect session state and select the next governed action;
  • /onboard — bind the current repository and project context;
  • /review — review a bounded change;
  • /status — show CodeGraph session and context status;
  • /update — refresh the project context according to the command contract.

If a slash command is absent from .opencode/commands, use the current command catalog and help output for the supported surface.

Headless use

For one non-interactive request:

python scripts/run_opencode_codegraph.py `
  --project <project-name> `
  --run "Explain the impact of changing <symbol> and cite source locations"

Use --session <id> or --continue-last only when continuing the intended session. Confirm the project name in the response and keep freshness or degraded-mode warnings with the result.

Verification and recovery

  1. Confirm the launcher reports the intended project and API endpoint.
  2. Run /status before the first code task.
  3. If MCP is unavailable, verify CodeGraph health and project scope; do not compensate with raw database arguments.
  4. If the plugin is stale, rerun the launcher without --no-plugin-install.
  5. If evidence is stale, refresh the project before accepting the answer.

An agent answer is advisory until a professional reviewer verifies the referenced code and project revision.

Contract sources

  • scripts/run_opencode_codegraph.py — model default, project/session flags, and integration setup;
  • integrations/opencode/opencode-codegraph/package.json — plugin version;
  • .opencode/commands — supported repository command files;
  • .opencode/agents/codegraph.md — CodeGraph agent profile.

See also: CLI guide · Troubleshooting