opencode-data-model
OpenCode Plugin — npm

Schemas that compile.
Models you can trust.

An OpenCode plugin for generating normalized, high-performance database schemas and compile-safe TypeScript or JavaScript data models — backed by a strong prompt contract, forced validation, and optional AI double-checking to catch hallucinated fields, missing relations, weak indexes, dialect errors, and type drift before they reach your codebase.

npm version npm downloads GitHub stars License
2
SQL Dialects
TS + JS
Typed Models
7
Commands
AI
Double-check

Normalized Schemas

Write models are normalized first, with explicit nullability, ownership, deletion behavior, and constraints. Indexes are added for real access patterns — without over-indexing.

Forced Validation

A validation gate rejects drafts that contain hallucinated fields, missing relations, weak indexes, SQL dialect errors, or TypeScript/interface drift.

AI Double-check

Optional AI review re-examines the generated model for correctness, query performance, and migration safety before it lands in your repository.

MySQL · Postgres · TS · JS

Generate MySQL and PostgreSQL schemas plus compile-safe TypeScript and JSDoc-annotated JavaScript models — all boundary-aware and migration-ready.

Installation

Add the package to the plugin array in your OpenCode config. npm plugins are installed automatically with Bun at startup.

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-data-model"]
}

The same package works under npm or Bun (bun add opencode-data-model).

Commands

CommandToolPurpose
/modelmodel_docData model blueprint
/schema-mysqlschema_mysqlMySQL schema
/schema-pgschema_pgPostgreSQL schema
/types-tstypes_tsTypeScript models
/types-jstypes_jsJSDoc-annotated JS models
/data-model-roadmaproadmap_modelQuality roadmap
/model-checkaudit_modelValidation gate

Classic /data-model-* commands and generate_* tool names remain available for compatibility.