sql2er skill
A skill that builds Chen-model ER diagrams from SQL and DBML, tidies the layout and exports SVG, PNG, drawio and HTML.
- 194 ★ on the repository
- Last commit
- AGPL-3.0
Minimal access
Why this level
- The skill runs a local script and writes state and export files next to your project.
Install
- Works in
In your terminal, with SkillFoxx CLI
npx skillfoxx add skills/sql2erDetects the agents on your machine, shows the access level and pins the version.
Other ways to install
Access and checks
How we reviewMinimal accessThe tool runs nothing and makes no network calls.
- The skill runs a local script and writes state and export files next to your project.
This is third-party code. Review the repository files before installing.
What it does
The `sql2er` skill works with the `skills/sql2er/scripts/sql2er-agent.mjs` CLI. The `generate --input schema.sql --state er.json` command builds a Chen diagram from `CREATE TABLE` statements or DBML code and keeps everything in one JSON state file. The `--hide-attrs` flag removes attributes for an overview and `--comment` takes labels from comments. Next the agent reads `describe` diagnostics: crossings, overlaps and disconnected components. Layout is tuned with `layout optimal`, `attrs compact`, `swap`, `move`, `nudge` and `rotate 90`, and relation labels are set through `labels`. The result exports with `export` to SVG, PNG, drawio or HTML, and before handing over the agent looks at the image. For manual tuning the HTML carries a built-in editor.
Who it is for. Developers and students who need a tidy ER diagram of a database schema with no online sign-in and no manual layout.
Good fit when
- A Chen diagram is needed from `schema.sql` for a report or coursework.
- A schema with dozens of tables is shown as a skeleton without attributes for an overview.
- A DBML diagram is exported to drawio for hand editing.
- Several disconnected table groups are exported as separate files with `--split`.
Not a fit when
- You need a logical model rather than a Chen diagram, for which the author recommends dbdiagram.io.
- The schema exists only in a database with no SQL or DBML text.
- You need reverse engineering by connecting to a live database.
Example request
Build a Chen diagram from schema.sql, tidy the layout so nothing crosses and export SVG and drawio.Limitations
The skill builds diagrams from SQL or DBML text and does not connect to a database. Attribute visibility is fixed at `generate` and export does not change it. Regeneration resets positions, so labels are set before layout tuning. Node.js is needed to run it. The AGPL-3.0 licence requires opening the code of derived network services. Main documentation is written in Chinese. Before handing over, export SVG or PNG and look at them: labels and nodes must not overlap.
How to disable. Delete the `sql2er` skill folder from the agent skills directory. State and export files (`er.json`, `er.svg`) live in your project; delete them by hand.
FAQ
How do I install the skill?
With `npx skills add ystemsrx/sql-to-ER`. The skill sits in `skills/sql2er/` with `commands.md` and `data-model.md` references beside it.
Which export formats exist?
SVG, PNG, drawio, JSON and HTML. For HTML set `--lang zh` or `--lang en` if you want a portable page with an editor.
How do I hide attributes?
Add `--hide-attrs` to `generate`. Attribute visibility is set at generation and export does not change it.
How do I deal with crossings?
Run `layout optimal`, and for a local crossing try `swap`. If attributes are the problem, compare `attrs compact` with `attrs moderate`.
Is there a web version?
Yes, the project includes a free React and Vite web page where you paste SQL or DBML and get a diagram. The skill uses the same engine.
Discussion
No questions or reviews yet.
Related
SkillsMCP server for the ERD Editor: an agent adds tables, relations and indexes and the edits show up live on the canvas in VS Code, Obsidian and JetBrains
A data visualization skill for agents: turns data into polished interactive HTML charts and full reports with one visual language
ReskillSQL analyses failed agent SQL runs and ships query-writing skill versions only after checks on held-out examples.
A Python library and MCP server that give the model only the tables a question needs and a role may read
Skill and CLI for tables: cleaning with recorded decisions, level-based statistics, a PDF report and a separate audit.
A template for data scientists: AGENTS.md, CLAUDE.md and skills for Python, SQL, Polars and model diagnostics.
README in short
The project began as a free web page with no sign-in, because popular services demand registration or payment and draw diagrams carelessly. Later came the agent skill installer and a CLI with state in JSON.
README badge
Original SKILL.md
--- name: sql2er description: Use when the user wants a Chen-model ER diagram from SQL CREATE TABLE statements or DBML, wants to rearrange or clean up an existing sql2er state, wants a skeleton-only overview with attributes hidden at generate time, or needs drawio/svg/png/json/html exports with final visual review. --- # sql2er Use the bundled CLI from the repo root: ```bash AGENT=skills/sql2er/scripts/sql2er-agent.mjs ``` State lives in one JSON file passed with `--state <path>`; reuse the same state path for every command in a diagram session. ## Core workflow 1. Generate the diagram: ```bash node $AGENT generate --input schema.sql --state er.json ``` Use `--hide-attrs` only when the user wants an overview/skeleton, the schema is dense, or attributes are not important. Attribute visibility is fixed at `generate`; export never adds or removes attributes. If fields, PKs, or column-level semantics matter, generate with attributes. Use `--comment` when table/column/ref comments carry readable business labels. Set labels before tuning layout because regenerating resets positions. If generated names are not semantic enough, relabel nodes before layout tuning: ```bash node $AGENT labels mode comment --state er.json node $AGENT labels set rel-orders-users-user_id-7 "placed by" --state er.json node $AGENT labels batch --file labels.json --state er.json ``` 2. Inspect diagnostics: ```bash node $AGENT describe --state er.json ``` Use `DIAGNOSTICS` for structural decisions: crossings, overlaps, disconnected components, attribute overlaps, and attribute-line crossings. Use the ASCII map only as a rough orientation aid. If `PARSER WARNINGS` is present, fix every reported issue. If an issue cannot be fixed, report it to the user. Copy exact entity ids from the `ENTITIES` block for manual position edits.