/apache-cayenne-6:cayenne-db-importfrom apache-cayenne-6
Imports database schema metadata into a Cayenne DataMap (DbEntity/DbAttribute/DbRelationship layer only). Use for reverse engineering, schema import, or adding tables/columns/FKs from a database.
Ships in apache-cayenne-6. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Import a database schema into a Cayenne DataMap using the dbimport_run MCP tool. If a DBConnector is already stored in preferences for the DataMap the import runs directly without any GUI interaction. When the connection has not been configured yet, the workflow launches CayenneModeler and walks the user through the dialog once to save the connection, then re-runs dbimport_run.
${CLAUDE_PLUGIN_ROOT}/references/project-layout.md — locate or create the project descriptor.${CLAUDE_PLUGIN_ROOT}/references/dbimport-config.md — field semantics for every dialog screen, so you can explain options in user terms.${CLAUDE_PLUGIN_ROOT}/references/mcp-tools.md — dbimport_run and open_project tool references and failure modes.DB import owns the DB layer of the DataMap: <dbEntity>, <dbAttribute> and <dbRelationship> elements are derived from DB metadata, never typed by hand. This applies to a one-column change as much as to a full schema import — the DB schema is changed first, then the import brings it into the model. The Object layer, queries and config blocks are hand-edited via cayenne-modeling.
The one exception is a user who has explicitly said they do not use DB import for the project. Then cayenne-modeling hand-edits the DB layer and this skill is not used. Never assume that exception yourself: a <dbImport> block in the DataMap means DB import is in use; without one, and without an earlier answer from the user, cayenne-modeling asks once and saves the answer to persistent memory.
After a successful import into a DataMap whose status was unclear, save to persistent memory (if you have one) that the project uses DB import.
dbimport_run is a merge that applies every difference without prompting:
<dbImport> filters — are removed, including tables and relationships somebody added by hand. If the user mentions such elements, warn them before running, and suggest excluding them in <dbImport> or creating them in the DB first.<skipRelationshipsLoading>true</skipRelationshipsLoading> in <dbImport>, the import neither reads FKs nor removes relationships from the model — DbRelationships are then the user's, hand-edited via cayenne-modeling. With false (the default), every FK is imported and a hand-made relationship with no FK in the DB is removed. Don't change this setting unless the user asks.Ask the user (one question, only if not obvious from the request):
Follow project-layout.md to find the existing cayenne-*.xml. If none exists, the user is starting from scratch:
cayenne-modeling's patterns — namespace http://cayenne.apache.org/schema/12/domain, project-version="12", one empty <map name="..."/> plus a sibling empty *.map.xml), orThe descriptor path needs to be absolute when passed to the MCP tools.
dbimport_runCall the MCP tool:
dbimport_run({ "projectPath": "<absolute path to cayenne-*.xml>", "dataMap": "<DataMap name>" })
If the tool is not available, follow "When the MCP server is unavailable" in mcp-tools.md and stop. Do not suggest mvn cayenne:cdbimport or any Gradle equivalent — those build plugins are out of scope.
imported — success. Surface the summary counters (entities added/removed/modified, relationships added) to the user. Call out a non-zero entitiesRemoved explicitly — those entities were dropped from the model without a prompt.up_to_date — the DataMap already matches the database. Tell the user nothing changed.error — import started but failed mid-run. Show the error.message and the partial summary.validation_failed — a pre-flight check failed. Use the error.code to guide next steps (see below).| Code | What failed | What to do |
|---|---|---|
project_not_found | Project path not readable | Verify path. |
project_parse_failed | File is not a valid Cayenne descriptor | Confirm the file is a cayenne-*.xml. |
datamap_not_found | DataMap name not in project | The error message lists available names; use one. |
dbconnector_not_configured | No connection saved for this DataMap | → Go to Step 4 to configure via the Modeler dialog. |
jdbc_driver_not_loadable | Driver jar not on the Modeler classpath | Open CayenneModeler → Preferences → Classpath, add the driver jar, save, then re-run. |
jdbc_connection_failed | Connection could not be opened | Check JDBC URL, credentials, and network access. |
This step is only needed when dbimport_run returns dbconnector_not_configured.
open_project({ "projectPath": "<absolute path to cayenne-*.xml>" })
If open_project returns a non-launched status, surface the error code and message (e.g. modeler_download_failed, project_not_found, launch_not_confirmed; see open_project in mcp-tools.md). Don't retry blindly — diagnose first.
The user now has the Modeler open. Give them the exact GUI sequence:
org.postgresql.DriverTABLE; add VIEW if needed.dbimport-config.md for what each does.skipPrimaryKeyLoading, skipRelationshipsLoading, etc.After the user saves, the DBConnector is written to CayenneModeler preferences.
dbimport_runGo back to Step 3 and call dbimport_run again. This time it should find the saved connection and proceed.
Once the import succeeds:
<dbImport> block inside the DataMap for repeat runs.cayenne-cgen to regenerate Java classes for the new/changed entities. Quote the DataMap name so the cgen skill can pass it to cgen_run.team1-style relationship names, a table prefix leaking into relationships), you can offer the cayenne-model-naming skill to polish them — ideally before cgen. Only run it if the user asks; do not invoke it automatically.mvn cayenne:cdbimport, the Gradle cdbimport task, or hand-running the cayenne-dbsync Java APIs. dbimport_run is the only supported execution path.<dbEntity>, <dbAttribute> or <dbRelationship> "because it's just one". The import handles JDBC types, PK detection, FK relationships, and naming consistently; hand-rolling produces subtle mistakes and is overwritten by the next import. The only exception is a user who explicitly does not use DB import (see "Ownership").forceDataMapCatalog / forceDataMapSchema defensively. They suppress legitimate DB metadata and cause hard-to-debug issues in multi-catalog setups.mcp-tools.md and stop.dbimport_run is available — the GUI path is only for the first-time connection setup.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
cayenne, db-import, reverse-engineering, datamap, schema-import
npx claudepluginhub apache/cayenne --plugin apache-cayenne-69 skills in this plugin
/cayenne-cgenUse this skill whenever the user wants to (re)generate Cayenne entity Java classes from a DataMap. Trigger on phrases like 'generate Java classes', 'regenerate entities', 'run cgen', 'create the entity classes', 'why is the Artist class missing fields', 'where did the `_Abstract*` classes come from', 'sync the entity classes with the model', or any request to materialize Java from the DataMap. Also trigger as a follow-up after modeling changes (someone added an entity, attribute, or relationship and now the Java side is stale). This skill exclusively uses the `cgen_run` MCP tool — it does NOT use `mvn cayenne:cgen` or the Gradle cgen task./cayenne-full-db-syncUse this skill when the user wants to bring their WHOLE Cayenne project in line with the database in one shot — the mapping, the Object-layer names, and the generated Java classes together. This is the end-to-end 'sync with the DB' workflow, and it orchestrates three skills in order: `cayenne-db-import` (import schema metadata into the DataMap) → `cayenne-model-naming` (polish the just-imported names) → `cayenne-cgen` (regenerate Java classes). Trigger on holistic phrases like 'sync my project with the database', 'sync with the DB', 'my schema changed, update everything', 'update my entities/classes from the database', 'reverse engineer and regenerate the classes', 'import the new tables and rebuild the entities', 'full DB sync', 'bring the model and classes up to date with the DB'. The distinguishing signal is scope: the user wants the whole project (mapping + names + Java code), not just one stage. For the *model/mapping only* (no name cleanup, no class generation) use `cayenne-db-import`; to (re)generate classes alone use `cayenne-cgen`; to clean names alone use `cayenne-model-naming`. Uses the `dbimport_run` and `cgen_run` MCP tools via the sub-skills; does NOT use Maven or Gradle goals.Other plugins' skills for the same job