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.
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
| Command | Tool | Purpose |
|---|---|---|
| /model | model_doc | Data model blueprint |
| /schema-mysql | schema_mysql | MySQL schema |
| /schema-pg | schema_pg | PostgreSQL schema |
| /types-ts | types_ts | TypeScript models |
| /types-js | types_js | JSDoc-annotated JS models |
| /data-model-roadmap | roadmap_model | Quality roadmap |
| /model-check | audit_model | Validation gate |
Classic /data-model-* commands and generate_* tool names remain available for compatibility.