opencode-data-modelOpenCode plugin for generating data model documentation, database schemas, and TypeScript or JavaScript models
0
34
6 in 7 days
25.5
Multi-signal model
2 months ago
2026-06-03
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-data-model@0.1.1"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-data-model@0.1.1"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D opencode-data-modelopencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
opencode-data-model
OpenCode plugin for generating normalized, high-performance schemas and compile-safe TypeScript or JavaScript data models.
Why
I asked LLMs to generate schemas a million times. Too often they looked right, then failed on relationships, constraints, nullability, indexes, SQL dialects, or TypeScript boundaries. This plugin adds a stronger prompt contract, forced validation, and optional AI double-checking to reduce those mistakes before the model reaches your codebase.
Install
OpenCode loads plugins from two sources.
From npm (recommended)
Add the package to the plugin array in your config file. OpenCode installs npm
plugins automatically with Bun at startup and caches them (and their
dependencies) under ~/.cache/opencode/node_modules/.
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-data-model"]
}
Both regular and scoped npm packages are supported. The same package works under
npm or Bun — bun add opencode-data-model resolves the identical artifact.
From local files
Drop the built JavaScript/TypeScript file into a plugin directory and OpenCode loads it automatically at startup:
.opencode/plugins/— project-level plugins~/.config/opencode/plugins/— global plugins
mise run build
mise run link # symlinks dist/index.js into ~/.config/opencode/plugins/
To use external packages from a local plugin, create a package.json inside your
config directory, or publish to npm and reference it from config instead.
Load order
Plugins load from all sources, and every hook runs in sequence:
- Global config (
~/.config/opencode/opencode.json) - Project config (
opencode.json) - Global plugin directory (
~/.config/opencode/plugins/) - Project plugin directory (
.opencode/plugins/)
Duplicate npm packages with the same name and version load once. A local plugin and an npm plugin with similar names load separately.
Objects
| Object | Command | Tool |
|---|---|---|
| Blueprint | /model |
model_doc |
| MySQL Forge | /schema-mysql |
schema_mysql |
| Postgres Forge | /schema-pg |
schema_pg |
| Type Loom | /types-ts |
types_ts |
| JSDoc Loom | /types-js |
types_js |
| Quality Map | /data-model-roadmap |
roadmap_model |
| Gatekeeper | /model-check |
audit_model |
Classic /data-model-* commands and generate_* tool names are still available
for compatibility.
Prompt Contract
- Act as a principal data architect.
- Normalize write models first; document read-model exceptions.
- Design for correctness, query performance, maintainability, and migrations.
- Add indexes for real access patterns without over-indexing.
- Make nullability, ownership, deletion behavior, and constraints explicit.
- Keep TypeScript and JavaScript models compile-safe and boundary-aware.
- Reject the draft if validation finds hallucinated fields, missing relations, weak indexes, dialect errors, or type/interface drift.
Development
mise trust
bun install
mise run build
mise run lint
mise run test
mise run typecheck
Validation uses Bun snapshots, Zod contract checks, SQL DDL parsing, and
TypeScript syntax checks. Update snapshots with mise run test_update.
Publishing
npm login
mise run publish --tag latest
# if your npm account enforces publish 2FA:
mise run publish --tag latest --otp <one-time-code>
License
MIT License. See LICENSE.