/apache-cayenne-6:cayenne-modelingfrom apache-cayenne-6
Edits Cayenne ORM DataMap XML files — adds/modifies ObjEntities, attributes, relationships, embeddables, named queries, stored procedures, and DataNodes. Hand-edits the Object layer; DB layer changes route to cayenne-db-import.
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.
Edit Cayenne DataMap (*.map.xml) and project descriptor (cayenne-*.xml) files directly. This is the default path for granular model changes — adding one entity, one relationship, one query. Use the Modeler GUI (cayenne-modeler skill) only for inherently visual work like bulk relationship layout.
A DataMap has two halves with different owners. The owner is decided by the layer being changed, not by the size of the change.
| Part of the model | Owner | How to change it |
|---|---|---|
DB layer — <dbEntity>, <dbAttribute> (type, length, scale, mandatory, PK flags), <dbRelationship> and its joins | The database, via DB import | Change the DB schema, then run cayenne-db-import. Do not hand-edit. One settings-based carve-out for <dbRelationship> — see "DbRelationships follow the import settings". |
Object layer — <objEntity>, <objAttribute>, <objRelationship>, inheritance, callbacks | The user | Hand-edit here. |
Everything else — queries, <embeddable>, <procedure>, <cgen>, <dbImport> filters, the project descriptor | The user | Hand-edit here. |
The only exception: hand-edit the DB layer when the user has explicitly said they do not use DB import for this project (e.g. "we don't reverse engineer", "the model is the source of truth and the schema is generated from it"). Then this skill owns both layers.
When a request needs a DB-layer change, settle whether the project uses DB import, in this order:
<dbImport> block — the project uses DB import. Don't ask.<dbImport> block is "unclear", not an opt-out — the block is optional and import works without one. The same goes for a missing DBConnector, an MCP server that isn't connected, or a table that doesn't exist in the DB yet.cayenne-db-import (after the user has applied the schema change to the DB, if it isn't there yet). This holds for a single table, column, nullability flag or FK just as for a bulk import.dbimport_run merges the DB into the model and applies every difference without prompting. Hand-written DB-layer elements that don't match the DB are overwritten or dropped on the next import, and hand-written types, PK flags and joins tend to be subtly wrong.Customer entity for the new CUSTOMER table") is split: import brings in the DB layer, usually along with a default ObjEntity; then adjust the Object layer here.Whether DB import owns <dbRelationship> elements depends on <skipRelationshipsLoading> in the DataMap's <dbImport> block. Read it before adding, removing or changing a DbRelationship in a project that uses DB import:
<skipRelationshipsLoading> | Who owns DbRelationships | What to do |
|---|---|---|
true | The user. Import neither reads FKs nor removes relationships from the model. | Hand-edit <dbRelationship> elements here, both directions. <dbEntity> / <dbAttribute> still come from import. |
false, absent, or no <dbImport> block | DB import. Every FK becomes a relationship; a relationship with no matching FK is dropped by the next import. | Don't hand-edit. A relationship backed by an FK comes from cayenne-db-import. For one with no FK in the DB, see below. |
When the user wants a relationship that has no FK in the DB and the setting is not true, don't write it and don't change the setting on your own. Explain that the next import would drop it, and offer the two ways out:
cayenne-db-import.<skipRelationshipsLoading>true</skipRelationshipsLoading> in <dbImport> (creating the block if needed) and add the relationship by hand. Spell out the cost: from then on import stops bringing in any relationships, so FKs added to the DB later must also be mapped by hand.Make the change only after the user picks one.
cayenne-model-naming.Read these before making any edit — they describe the XML formats this skill operates on:
${CLAUDE_PLUGIN_ROOT}/references/project-layout.md — locate the project descriptor and DataMaps in the user's repo.${CLAUDE_PLUGIN_ROOT}/references/datamap-schema.md — every element shape for *.map.xml.${CLAUDE_PLUGIN_ROOT}/references/project-descriptor-schema.md — cayenne-*.xml shape.Follow project-layout.md. If the user has multiple Cayenne projects and the request is ambiguous, ask which one. Cache the answer for the rest of the session.
Check the project-version attribute in the descriptor before editing. If it is lower than the version in project-descriptor-schema.md, the project was saved by an older Cayenne version: stop and hand off to the cayenne-upgrade skill to upgrade it. Don't edit an old-format file and don't migrate the format by hand — the references here describe the current format only.
Decide whether the change belongs in a DataMap or the project descriptor (table at the end of project-layout.md):
*.map.xml).cayenne-*.xml).Apply the change following the schema in datamap-schema.md or project-descriptor-schema.md.
The parts of these rules about writing <dbEntity>, <dbAttribute> and <dbRelationship> elements apply only when the user has opted out of DB import — or, for <dbRelationship> alone, when <skipRelationshipsLoading> is true (see "Who owns what"). Otherwise treat the DB layer as read-only input that the Object layer must reference correctly.
Element order matters. The DataMap schema requires this order inside <dataMap>: <comment>, <embeddable>, <procedure>, <dbEntity>, <objEntity>, <dbRelationship>, <objRelationship>, the queries (<objectQuery>, <sqlQuery>, <procedureQuery>), <dbImport>, <cgen>. Insert at the right place — don't append blindly. A <comment> always goes first in its element, see datamap-schema.md.
Cross-link consistently.
<objEntity> references a <dbEntity> by dbEntityName="...". Make sure that DbEntity exists.<objAttribute> references a DbAttribute by dbAttributePath="COLUMN_NAME". Make sure that column exists on the DbEntity (or on a related one if using a dotted path through a relationship).<objRelationship> requires a backing <dbRelationship> (or chain of them) via dbRelationshipPath. Never add an ObjRelationship without the DB-layer counterpart. If the DbRelationship is missing and DB import owns relationships (<skipRelationshipsLoading> is not true), it has to come from an FK in the DB via cayenne-db-import — don't write it by hand.<dbRelationship> entries, one per direction. They are not auto-derived.Use the right type on attributes.
dbAttribute type — JDBC type names: VARCHAR, INTEGER, BIGINT, DATE, TIMESTAMP, BOOLEAN, NUMERIC, BLOB, CLOB, VARBINARY, etc. VARCHAR/CHAR/VARBINARY also need length. NUMERIC/DECIMAL also need scale.objAttribute type — Java FQN: java.lang.String, java.lang.Integer, java.util.Date, java.math.BigDecimal, byte[], etc. Use wrapper types (Integer, not int) for nullable columns.PK handling. PK columns get primaryKey="true" mandatory="true" on the DbAttribute. They are normally not mirrored as ObjAttributes — Cayenne handles them implicitly. Map a PK as an ObjAttribute only if the user wants a "meaningful PK" (visible on the Java side).
Preserve formatting. Match the indentation and quote style of the file (the standard Cayenne style uses tabs and double quotes, but follow what's actually in the file you're editing).
Changing defaultPackage on a DataMap. If the user asks to change the DataMap-level defaultPackage attribute, ask whether entity-level packages should be updated too. Otherwise, every existing objEntity will keep its old package. Ask: "Do you also want me to update the className values on individual <objEntity> elements that currently use the old package?" Update them only if the user confirms.
After writing the XML, mentally walk through:
objEntity.dbEntityName resolve to an existing <dbEntity>?objAttribute.dbAttributePath resolve to a column on the right DbEntity?objRelationship.dbRelationshipPath resolve to a chain of existing <dbRelationship> entries?mandatory="true" where the DB enforces NOT NULL?<dbEntity> and <dbAttribute> untouched — and every <dbRelationship> too, unless <skipRelationshipsLoading> is true?If anything fails, fix it before reporting done.
<cgen> block: suggest invoking the cayenne-cgen skill to regenerate Java classes. Mention which entities are affected.cayenne-cgen.cayenne-db-import, or to cayenne-full-db-sync when they want names and classes updated too. Do not script it via XML edits.Gametype/team1-style names, normalizing entity/attribute/relationship names across the model): hand off to cayenne-model-naming — it knows the naming conventions and the rename cross-reference checklist.project-version below the current one): hand off to cayenne-upgrade to upgrade it before any edit.cayenne-modeler skill. Otherwise do not.CayenneModeler watches the project XML files and automatically detects on-disk changes. When you edit a *.map.xml file directly, the Modeler will prompt the user to reload the project the next time they interact with it. There is no risk of the Modeler silently overwriting your edits. Do not warn the user that the Modeler may overwrite changes or tell them to close the Modeler before editing — that is incorrect and unnecessary.
project-version or rewriting namespaces and elements yourself. The upgrade_project MCP tool runs the real upgrade handlers; use cayenne-upgrade.<dbEntity>, <dbAttribute> or <dbRelationship> additions, removals or attribute changes — not even "just one column". The single carve-out is <dbRelationship> when <skipRelationshipsLoading> is true.<skipRelationshipsLoading> to true on your own to make room for a hand-written relationship. It turns off relationship import for the whole DataMap — the user decides. Don't guess the opt-out from the state of the project — when there is no <dbImport> block and no earlier answer, ask once and save the answer. See "Who owns what"._<Entity>.java superclass files. They are regenerated by cgen and your changes will be overwritten. Edit the user <Entity>.java subclass instead.objRelationship without a dbRelationship. Cayenne will validate-fail at runtime.int, long, boolean) as objAttribute type for nullable columns. Primitives can't represent NULL. Use wrappers.cayenne-cgen's job — invoke that skill instead of calling the MCP tool directly here.mvn cayenne:cdbimport or any Maven/Gradle plugin goal. Those are explicitly out of scope for this plugin.What SKILL.md sets; muted values are Claude Code's defaults
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-db-importUse this skill when the user wants to import database schema metadata into a Cayenne DataMap — the *model/mapping only*, not names or Java classes. Trigger on phrases like 'reverse engineer the database', 'import the schema', 'generate a DataMap from my DB', 'add the new tables from the DB into the model', 'import the customer table', 'create entities from these tables', or any request to read database metadata to populate or update a DataMap's XML. This is the only way the DB layer of the model (DbEntity, DbAttribute, DbRelationship) gets created or changed, whatever the size — a full schema, a batch of tables, or a single new table, column or FK. Hand-editing the DB layer in `cayenne-modeling` is allowed only when the user has explicitly said they do not use DB import; Object-layer edits (ObjEntity, ObjAttribute, ObjRelationship) always belong in `cayenne-modeling`. IMPORTANT — scope: this imports the mapping ONLY; it does not clean up the Object-layer names or (re)generate Java classes. When the user wants their whole project brought in line with the DB ('sync my project with the database', 'my schema changed, update everything', 'update my entities/classes from the DB'), that is the end-to-end `cayenne-full-db-sync` skill, which runs this import and then name cleanup and class generation. To regenerate classes alone use `cayenne-cgen`. The skill runs reverse engineering directly via the `dbimport_run` MCP tool when a DBConnector is already configured; otherwise it opens the CayenneModeler GUI via `open_project` to configure the connection first./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./cayenne-modelerUse this skill when the user explicitly wants to open CayenneModeler (the GUI) on a Cayenne project, or when the modeling task is one the Modeler has to do — first-time DB connection setup for reverse engineering (delegated to cayenne-db-import), bulk relationship layout, multi-entity visual refactoring. Trigger on phrases like 'open the Modeler', 'open in CayenneModeler', 'launch the GUI', 'edit visually', 'show me the project in the Modeler'. Do NOT trigger for upgrading a project saved by an older Cayenne version — that's the cayenne-upgrade skill. Do NOT trigger as a fallback for ordinary a-la-carte XML edits — those belong in the cayenne-modeling skill, which is faster and doesn't require the user to context-switch./cayenne-model-namingUse this skill to clean up Object-layer names in a Cayenne DataMap — ObjEntity, ObjAttribute, and ObjRelationship names, plus DbRelationship names (the first-class unit of relationship cleanup — every FK has one whether or not an ObjRelationship was generated; the ObjRelationship name is synced to it when one exists) — so they read as descriptive, consistent Java. Trigger on phrases like 'clean up the model names', 'fix the entity names', 'these names look ugly', 'make the names descriptive', 'normalize the ObjEntity/attribute/relationship names', 'why is this relationship called team1', 'rename entities to be consistent', 'the import produced Gametype instead of GameType'. Invoke it on an explicit user request, or as a manual follow-up after a `cayenne-db-import` to polish the just-imported additions — it is never triggered automatically. IMPORTANT: this is a LIGHT polish pass — CayenneModeler's reverse-engineering already produces good names for the common case; only improve the specific things its deterministic algorithm cannot (run-together names with no separators like `gametype`, meaningless numbered names like `team1` from multiple relationships between two tables, and a common entity prefix that leaks into relationship names like `aaOrders`). Do NOT rewrite names that are already correct. This is Obj-layer naming polish; for structural model edits use `cayenne-modeling`, and for regenerating classes afterward use `cayenne-cgen`./cayenne-queryUse this skill whenever the user wants to write or modify a Cayenne query — fetching entities by criteria, joining, prefetching to avoid N+1, ordering, paginating, aggregating, or running raw SQL through Cayenne. Trigger on phrases like 'query for X', 'fetch all artists where ...', 'write an ObjectSelect', 'use SQLQuery', 'add a prefetch', 'get distinct values', 'count rows', 'find by ID', 'load by primary key', 'build a Cayenne expression', 'why am I getting N+1', 'how do I paginate', 'select a single column', 'select columns into a DTO', 'named query in the DataMap'. Do NOT trigger for modeling changes (use cayenne-modeling) or runtime bootstrap (use cayenne-runtime).Other plugins' skills for the same job